babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760
  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. /** @hidden */
  31390. _shaderProcessor: IShaderProcessor;
  31391. /**
  31392. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31393. */
  31394. forcePOTTextures: boolean;
  31395. /**
  31396. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31397. */
  31398. isFullscreen: boolean;
  31399. /**
  31400. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31401. */
  31402. cullBackFaces: boolean;
  31403. /**
  31404. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31405. */
  31406. renderEvenInBackground: boolean;
  31407. /**
  31408. * Gets or sets a boolean indicating that cache can be kept between frames
  31409. */
  31410. preventCacheWipeBetweenFrames: boolean;
  31411. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31412. validateShaderPrograms: boolean;
  31413. /**
  31414. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31415. * This can provide greater z depth for distant objects.
  31416. */
  31417. useReverseDepthBuffer: boolean;
  31418. /**
  31419. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31420. */
  31421. disableUniformBuffers: boolean;
  31422. /** @hidden */
  31423. _uniformBuffers: UniformBuffer[];
  31424. /**
  31425. * Gets a boolean indicating that the engine supports uniform buffers
  31426. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31427. */
  31428. readonly supportsUniformBuffers: boolean;
  31429. /** @hidden */
  31430. _gl: WebGLRenderingContext;
  31431. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31432. protected _windowIsBackground: boolean;
  31433. protected _webGLVersion: number;
  31434. protected _creationOptions: EngineOptions;
  31435. protected _highPrecisionShadersAllowed: boolean;
  31436. /** @hidden */
  31437. readonly _shouldUseHighPrecisionShader: boolean;
  31438. /**
  31439. * Gets a boolean indicating that only power of 2 textures are supported
  31440. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31441. */
  31442. readonly needPOTTextures: boolean;
  31443. /** @hidden */
  31444. _badOS: boolean;
  31445. /** @hidden */
  31446. _badDesktopOS: boolean;
  31447. private _hardwareScalingLevel;
  31448. /** @hidden */
  31449. _caps: EngineCapabilities;
  31450. private _isStencilEnable;
  31451. protected _colorWrite: boolean;
  31452. private _glVersion;
  31453. private _glRenderer;
  31454. private _glVendor;
  31455. /** @hidden */
  31456. _videoTextureSupported: boolean;
  31457. protected _renderingQueueLaunched: boolean;
  31458. protected _activeRenderLoops: (() => void)[];
  31459. /**
  31460. * Observable signaled when a context lost event is raised
  31461. */
  31462. onContextLostObservable: Observable<ThinEngine>;
  31463. /**
  31464. * Observable signaled when a context restored event is raised
  31465. */
  31466. onContextRestoredObservable: Observable<ThinEngine>;
  31467. private _onContextLost;
  31468. private _onContextRestored;
  31469. protected _contextWasLost: boolean;
  31470. /** @hidden */
  31471. _doNotHandleContextLost: boolean;
  31472. /**
  31473. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31475. */
  31476. doNotHandleContextLost: boolean;
  31477. /**
  31478. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31479. */
  31480. disableVertexArrayObjects: boolean;
  31481. /** @hidden */
  31482. protected _depthCullingState: DepthCullingState;
  31483. /** @hidden */
  31484. protected _stencilState: StencilState;
  31485. /** @hidden */
  31486. protected _alphaState: AlphaState;
  31487. /** @hidden */
  31488. _internalTexturesCache: InternalTexture[];
  31489. /** @hidden */
  31490. protected _activeChannel: number;
  31491. private _currentTextureChannel;
  31492. /** @hidden */
  31493. protected _boundTexturesCache: {
  31494. [key: string]: Nullable<InternalTexture>;
  31495. };
  31496. /** @hidden */
  31497. protected _currentEffect: Nullable<Effect>;
  31498. /** @hidden */
  31499. protected _currentProgram: Nullable<WebGLProgram>;
  31500. private _compiledEffects;
  31501. private _vertexAttribArraysEnabled;
  31502. /** @hidden */
  31503. protected _cachedViewport: Nullable<IViewportLike>;
  31504. private _cachedVertexArrayObject;
  31505. /** @hidden */
  31506. protected _cachedVertexBuffers: any;
  31507. /** @hidden */
  31508. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31509. /** @hidden */
  31510. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31511. /** @hidden */
  31512. _currentRenderTarget: Nullable<InternalTexture>;
  31513. private _uintIndicesCurrentlySet;
  31514. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31515. /** @hidden */
  31516. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31517. private _currentBufferPointers;
  31518. private _currentInstanceLocations;
  31519. private _currentInstanceBuffers;
  31520. private _textureUnits;
  31521. /** @hidden */
  31522. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31523. /** @hidden */
  31524. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31525. /** @hidden */
  31526. _boundRenderFunction: any;
  31527. private _vaoRecordInProgress;
  31528. private _mustWipeVertexAttributes;
  31529. private _emptyTexture;
  31530. private _emptyCubeTexture;
  31531. private _emptyTexture3D;
  31532. private _emptyTexture2DArray;
  31533. /** @hidden */
  31534. _frameHandler: number;
  31535. private _nextFreeTextureSlots;
  31536. private _maxSimultaneousTextures;
  31537. private _activeRequests;
  31538. protected _texturesSupported: string[];
  31539. /** @hidden */
  31540. _textureFormatInUse: Nullable<string>;
  31541. protected readonly _supportsHardwareTextureRescaling: boolean;
  31542. /**
  31543. * Gets the list of texture formats supported
  31544. */
  31545. readonly texturesSupported: Array<string>;
  31546. /**
  31547. * Gets the list of texture formats in use
  31548. */
  31549. readonly textureFormatInUse: Nullable<string>;
  31550. /**
  31551. * Gets the current viewport
  31552. */
  31553. readonly currentViewport: Nullable<IViewportLike>;
  31554. /**
  31555. * Gets the default empty texture
  31556. */
  31557. readonly emptyTexture: InternalTexture;
  31558. /**
  31559. * Gets the default empty 3D texture
  31560. */
  31561. readonly emptyTexture3D: InternalTexture;
  31562. /**
  31563. * Gets the default empty 2D array texture
  31564. */
  31565. readonly emptyTexture2DArray: InternalTexture;
  31566. /**
  31567. * Gets the default empty cube texture
  31568. */
  31569. readonly emptyCubeTexture: InternalTexture;
  31570. /**
  31571. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31572. */
  31573. readonly premultipliedAlpha: boolean;
  31574. /**
  31575. * Observable event triggered before each texture is initialized
  31576. */
  31577. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31578. /**
  31579. * Creates a new engine
  31580. * @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
  31581. * @param antialias defines enable antialiasing (default: false)
  31582. * @param options defines further options to be sent to the getContext() function
  31583. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31584. */
  31585. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31586. private _rebuildInternalTextures;
  31587. private _rebuildEffects;
  31588. /**
  31589. * Gets a boolean indicating if all created effects are ready
  31590. * @returns true if all effects are ready
  31591. */
  31592. areAllEffectsReady(): boolean;
  31593. protected _rebuildBuffers(): void;
  31594. private _initGLContext;
  31595. /**
  31596. * Gets version of the current webGL context
  31597. */
  31598. readonly webGLVersion: number;
  31599. /**
  31600. * Gets a string idenfifying the name of the class
  31601. * @returns "Engine" string
  31602. */
  31603. getClassName(): string;
  31604. /**
  31605. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31606. */
  31607. readonly isStencilEnable: boolean;
  31608. /** @hidden */
  31609. _prepareWorkingCanvas(): void;
  31610. /**
  31611. * Reset the texture cache to empty state
  31612. */
  31613. resetTextureCache(): void;
  31614. /**
  31615. * Gets an object containing information about the current webGL context
  31616. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31617. */
  31618. getGlInfo(): {
  31619. vendor: string;
  31620. renderer: string;
  31621. version: string;
  31622. };
  31623. /**
  31624. * Defines the hardware scaling level.
  31625. * By default the hardware scaling level is computed from the window device ratio.
  31626. * 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.
  31627. * @param level defines the level to use
  31628. */
  31629. setHardwareScalingLevel(level: number): void;
  31630. /**
  31631. * Gets the current hardware scaling level.
  31632. * By default the hardware scaling level is computed from the window device ratio.
  31633. * 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.
  31634. * @returns a number indicating the current hardware scaling level
  31635. */
  31636. getHardwareScalingLevel(): number;
  31637. /**
  31638. * Gets the list of loaded textures
  31639. * @returns an array containing all loaded textures
  31640. */
  31641. getLoadedTexturesCache(): InternalTexture[];
  31642. /**
  31643. * Gets the object containing all engine capabilities
  31644. * @returns the EngineCapabilities object
  31645. */
  31646. getCaps(): EngineCapabilities;
  31647. /**
  31648. * stop executing a render loop function and remove it from the execution array
  31649. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31650. */
  31651. stopRenderLoop(renderFunction?: () => void): void;
  31652. /** @hidden */
  31653. _renderLoop(): void;
  31654. /**
  31655. * Gets the HTML canvas attached with the current webGL context
  31656. * @returns a HTML canvas
  31657. */
  31658. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31659. /**
  31660. * Gets host window
  31661. * @returns the host window object
  31662. */
  31663. getHostWindow(): Nullable<Window>;
  31664. /**
  31665. * Gets the current render width
  31666. * @param useScreen defines if screen size must be used (or the current render target if any)
  31667. * @returns a number defining the current render width
  31668. */
  31669. getRenderWidth(useScreen?: boolean): number;
  31670. /**
  31671. * Gets the current render height
  31672. * @param useScreen defines if screen size must be used (or the current render target if any)
  31673. * @returns a number defining the current render height
  31674. */
  31675. getRenderHeight(useScreen?: boolean): number;
  31676. /**
  31677. * Can be used to override the current requestAnimationFrame requester.
  31678. * @hidden
  31679. */
  31680. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31681. /**
  31682. * Register and execute a render loop. The engine can have more than one render function
  31683. * @param renderFunction defines the function to continuously execute
  31684. */
  31685. runRenderLoop(renderFunction: () => void): void;
  31686. /**
  31687. * Clear the current render buffer or the current render target (if any is set up)
  31688. * @param color defines the color to use
  31689. * @param backBuffer defines if the back buffer must be cleared
  31690. * @param depth defines if the depth buffer must be cleared
  31691. * @param stencil defines if the stencil buffer must be cleared
  31692. */
  31693. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31694. private _viewportCached;
  31695. /** @hidden */
  31696. _viewport(x: number, y: number, width: number, height: number): void;
  31697. /**
  31698. * Set the WebGL's viewport
  31699. * @param viewport defines the viewport element to be used
  31700. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31701. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31702. */
  31703. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31704. /**
  31705. * Begin a new frame
  31706. */
  31707. beginFrame(): void;
  31708. /**
  31709. * Enf the current frame
  31710. */
  31711. endFrame(): void;
  31712. /**
  31713. * Resize the view according to the canvas' size
  31714. */
  31715. resize(): void;
  31716. /**
  31717. * Force a specific size of the canvas
  31718. * @param width defines the new canvas' width
  31719. * @param height defines the new canvas' height
  31720. */
  31721. setSize(width: number, height: number): void;
  31722. /**
  31723. * Binds the frame buffer to the specified texture.
  31724. * @param texture The texture to render to or null for the default canvas
  31725. * @param faceIndex The face of the texture to render to in case of cube texture
  31726. * @param requiredWidth The width of the target to render to
  31727. * @param requiredHeight The height of the target to render to
  31728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31729. * @param depthStencilTexture The depth stencil texture to use to render
  31730. * @param lodLevel defines le lod level to bind to the frame buffer
  31731. */
  31732. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31733. /** @hidden */
  31734. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31735. /**
  31736. * Unbind the current render target texture from the webGL context
  31737. * @param texture defines the render target texture to unbind
  31738. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31739. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31740. */
  31741. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31742. /**
  31743. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31744. */
  31745. flushFramebuffer(): void;
  31746. /**
  31747. * Unbind the current render target and bind the default framebuffer
  31748. */
  31749. restoreDefaultFramebuffer(): void;
  31750. /** @hidden */
  31751. protected _resetVertexBufferBinding(): void;
  31752. /**
  31753. * Creates a vertex buffer
  31754. * @param data the data for the vertex buffer
  31755. * @returns the new WebGL static buffer
  31756. */
  31757. createVertexBuffer(data: DataArray): DataBuffer;
  31758. private _createVertexBuffer;
  31759. /**
  31760. * Creates a dynamic vertex buffer
  31761. * @param data the data for the dynamic vertex buffer
  31762. * @returns the new WebGL dynamic buffer
  31763. */
  31764. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31765. protected _resetIndexBufferBinding(): void;
  31766. /**
  31767. * Creates a new index buffer
  31768. * @param indices defines the content of the index buffer
  31769. * @param updatable defines if the index buffer must be updatable
  31770. * @returns a new webGL buffer
  31771. */
  31772. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31773. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31774. /**
  31775. * Bind a webGL buffer to the webGL context
  31776. * @param buffer defines the buffer to bind
  31777. */
  31778. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31779. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31780. private bindBuffer;
  31781. /**
  31782. * update the bound buffer with the given data
  31783. * @param data defines the data to update
  31784. */
  31785. updateArrayBuffer(data: Float32Array): void;
  31786. private _vertexAttribPointer;
  31787. private _bindIndexBufferWithCache;
  31788. private _bindVertexBuffersAttributes;
  31789. /**
  31790. * Records a vertex array object
  31791. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31792. * @param vertexBuffers defines the list of vertex buffers to store
  31793. * @param indexBuffer defines the index buffer to store
  31794. * @param effect defines the effect to store
  31795. * @returns the new vertex array object
  31796. */
  31797. recordVertexArrayObject(vertexBuffers: {
  31798. [key: string]: VertexBuffer;
  31799. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31800. /**
  31801. * Bind a specific vertex array object
  31802. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31803. * @param vertexArrayObject defines the vertex array object to bind
  31804. * @param indexBuffer defines the index buffer to bind
  31805. */
  31806. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31807. /**
  31808. * Bind webGl buffers directly to the webGL context
  31809. * @param vertexBuffer defines the vertex buffer to bind
  31810. * @param indexBuffer defines the index buffer to bind
  31811. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31812. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31813. * @param effect defines the effect associated with the vertex buffer
  31814. */
  31815. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31816. private _unbindVertexArrayObject;
  31817. /**
  31818. * Bind a list of vertex buffers to the webGL context
  31819. * @param vertexBuffers defines the list of vertex buffers to bind
  31820. * @param indexBuffer defines the index buffer to bind
  31821. * @param effect defines the effect associated with the vertex buffers
  31822. */
  31823. bindBuffers(vertexBuffers: {
  31824. [key: string]: Nullable<VertexBuffer>;
  31825. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31826. /**
  31827. * Unbind all instance attributes
  31828. */
  31829. unbindInstanceAttributes(): void;
  31830. /**
  31831. * Release and free the memory of a vertex array object
  31832. * @param vao defines the vertex array object to delete
  31833. */
  31834. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31835. /** @hidden */
  31836. _releaseBuffer(buffer: DataBuffer): boolean;
  31837. protected _deleteBuffer(buffer: DataBuffer): void;
  31838. /**
  31839. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31840. * @param instancesBuffer defines the webGL buffer to update and bind
  31841. * @param data defines the data to store in the buffer
  31842. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31843. */
  31844. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31845. /**
  31846. * Apply all cached states (depth, culling, stencil and alpha)
  31847. */
  31848. applyStates(): void;
  31849. /**
  31850. * Send a draw order
  31851. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31852. * @param indexStart defines the starting index
  31853. * @param indexCount defines the number of index to draw
  31854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31855. */
  31856. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31857. /**
  31858. * Draw a list of points
  31859. * @param verticesStart defines the index of first vertex to draw
  31860. * @param verticesCount defines the count of vertices to draw
  31861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31862. */
  31863. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31864. /**
  31865. * Draw a list of unindexed primitives
  31866. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31867. * @param verticesStart defines the index of first vertex to draw
  31868. * @param verticesCount defines the count of vertices to draw
  31869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31870. */
  31871. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31872. /**
  31873. * Draw a list of indexed primitives
  31874. * @param fillMode defines the primitive to use
  31875. * @param indexStart defines the starting index
  31876. * @param indexCount defines the number of index to draw
  31877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31878. */
  31879. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31880. /**
  31881. * Draw a list of unindexed primitives
  31882. * @param fillMode defines the primitive to use
  31883. * @param verticesStart defines the index of first vertex to draw
  31884. * @param verticesCount defines the count of vertices to draw
  31885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31886. */
  31887. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31888. private _drawMode;
  31889. /** @hidden */
  31890. protected _reportDrawCall(): void;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. 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;
  31909. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31939. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to a number (int)
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param value defines the int number to store
  31969. */
  31970. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec2)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec3)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of int32 (stored as vec4)
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of int32 to store
  31993. */
  31994. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of number
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of number to store
  31999. */
  32000. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of number (stored as vec2)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of number to store
  32005. */
  32006. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of number (stored as vec3)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of number to store
  32011. */
  32012. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number (stored as vec4)
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32019. /**
  32020. * Set the value of an uniform to an array of float32 (stored as matrices)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param matrices defines the array of float32 to store
  32023. */
  32024. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32025. /**
  32026. * Set the value of an uniform to a matrix (3x3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32029. */
  32030. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32031. /**
  32032. * Set the value of an uniform to a matrix (2x2)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32035. */
  32036. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32037. /**
  32038. * Set the value of an uniform to a number (float)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param value defines the float number to store
  32041. */
  32042. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32043. /**
  32044. * Set the value of an uniform to a vec2
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param x defines the 1st component of the value
  32047. * @param y defines the 2nd component of the value
  32048. */
  32049. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32050. /**
  32051. * Set the value of an uniform to a vec3
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param x defines the 1st component of the value
  32054. * @param y defines the 2nd component of the value
  32055. * @param z defines the 3rd component of the value
  32056. */
  32057. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32058. /**
  32059. * Set the value of an uniform to a vec4
  32060. * @param uniform defines the webGL uniform location where to store the value
  32061. * @param x defines the 1st component of the value
  32062. * @param y defines the 2nd component of the value
  32063. * @param z defines the 3rd component of the value
  32064. * @param w defines the 4th component of the value
  32065. */
  32066. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32067. /**
  32068. * Gets the depth culling state manager
  32069. */
  32070. readonly depthCullingState: DepthCullingState;
  32071. /**
  32072. * Gets the alpha state manager
  32073. */
  32074. readonly alphaState: AlphaState;
  32075. /**
  32076. * Gets the stencil state manager
  32077. */
  32078. readonly stencilState: StencilState;
  32079. /**
  32080. * Clears the list of texture accessible through engine.
  32081. * This can help preventing texture load conflict due to name collision.
  32082. */
  32083. clearInternalTexturesCache(): void;
  32084. /**
  32085. * Force the entire cache to be cleared
  32086. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32087. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32088. */
  32089. wipeCaches(bruteForce?: boolean): void;
  32090. /** @hidden */
  32091. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32092. min: number;
  32093. mag: number;
  32094. };
  32095. /** @hidden */
  32096. _createTexture(): WebGLTexture;
  32097. /**
  32098. * Usually called from Texture.ts.
  32099. * Passed information to create a WebGLTexture
  32100. * @param urlArg defines a value which contains one of the following:
  32101. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32102. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32103. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32104. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32105. * @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)
  32106. * @param scene needed for loading to the correct scene
  32107. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32108. * @param onLoad optional callback to be called upon successful completion
  32109. * @param onError optional callback to be called upon failure
  32110. * @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
  32111. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32112. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32113. * @param forcedExtension defines the extension to use to pick the right loader
  32114. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32115. * @param mimeType defines an optional mime type
  32116. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32117. */
  32118. 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;
  32119. /**
  32120. * @hidden
  32121. */
  32122. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32123. /**
  32124. * Creates a raw texture
  32125. * @param data defines the data to store in the texture
  32126. * @param width defines the width of the texture
  32127. * @param height defines the height of the texture
  32128. * @param format defines the format of the data
  32129. * @param generateMipMaps defines if the engine should generate the mip levels
  32130. * @param invertY defines if data must be stored with Y axis inverted
  32131. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32132. * @param compression defines the compression used (null by default)
  32133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32134. * @returns the raw texture inside an InternalTexture
  32135. */
  32136. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32137. /**
  32138. * Creates a new raw cube texture
  32139. * @param data defines the array of data to use to create each face
  32140. * @param size defines the size of the textures
  32141. * @param format defines the format of the data
  32142. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32143. * @param generateMipMaps defines if the engine should generate the mip levels
  32144. * @param invertY defines if data must be stored with Y axis inverted
  32145. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32146. * @param compression defines the compression used (null by default)
  32147. * @returns the cube texture as an InternalTexture
  32148. */
  32149. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32150. /**
  32151. * Creates a new raw 3D texture
  32152. * @param data defines the data used to create the texture
  32153. * @param width defines the width of the texture
  32154. * @param height defines the height of the texture
  32155. * @param depth defines the depth of the texture
  32156. * @param format defines the format of the texture
  32157. * @param generateMipMaps defines if the engine must generate mip levels
  32158. * @param invertY defines if data must be stored with Y axis inverted
  32159. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32160. * @param compression defines the compressed used (can be null)
  32161. * @param textureType defines the compressed used (can be null)
  32162. * @returns a new raw 3D texture (stored in an InternalTexture)
  32163. */
  32164. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32165. /**
  32166. * Creates a new raw 2D array texture
  32167. * @param data defines the data used to create the texture
  32168. * @param width defines the width of the texture
  32169. * @param height defines the height of the texture
  32170. * @param depth defines the number of layers of the texture
  32171. * @param format defines the format of the texture
  32172. * @param generateMipMaps defines if the engine must generate mip levels
  32173. * @param invertY defines if data must be stored with Y axis inverted
  32174. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32175. * @param compression defines the compressed used (can be null)
  32176. * @param textureType defines the compressed used (can be null)
  32177. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32178. */
  32179. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32180. private _unpackFlipYCached;
  32181. /**
  32182. * In case you are sharing the context with other applications, it might
  32183. * be interested to not cache the unpack flip y state to ensure a consistent
  32184. * value would be set.
  32185. */
  32186. enableUnpackFlipYCached: boolean;
  32187. /** @hidden */
  32188. _unpackFlipY(value: boolean): void;
  32189. /** @hidden */
  32190. _getUnpackAlignement(): number;
  32191. /**
  32192. * Update the sampling mode of a given texture
  32193. * @param samplingMode defines the required sampling mode
  32194. * @param texture defines the texture to update
  32195. */
  32196. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32197. /** @hidden */
  32198. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32199. width: number;
  32200. height: number;
  32201. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32202. /** @hidden */
  32203. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32204. /** @hidden */
  32205. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32206. /** @hidden */
  32207. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32208. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32209. private _prepareWebGLTexture;
  32210. /** @hidden */
  32211. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32212. /** @hidden */
  32213. _releaseFramebufferObjects(texture: InternalTexture): void;
  32214. /** @hidden */
  32215. _releaseTexture(texture: InternalTexture): void;
  32216. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32217. protected _setProgram(program: WebGLProgram): void;
  32218. protected _boundUniforms: {
  32219. [key: number]: WebGLUniformLocation;
  32220. };
  32221. /**
  32222. * Binds an effect to the webGL context
  32223. * @param effect defines the effect to bind
  32224. */
  32225. bindSamplers(effect: Effect): void;
  32226. private _activateCurrentTexture;
  32227. /** @hidden */
  32228. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32229. /** @hidden */
  32230. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32231. /**
  32232. * Unbind all textures from the webGL context
  32233. */
  32234. unbindAllTextures(): void;
  32235. /**
  32236. * Sets a texture to the according uniform.
  32237. * @param channel The texture channel
  32238. * @param uniform The uniform to set
  32239. * @param texture The texture to apply
  32240. */
  32241. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32242. private _bindSamplerUniformToChannel;
  32243. private _getTextureWrapMode;
  32244. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32245. /**
  32246. * Sets an array of texture to the webGL context
  32247. * @param channel defines the channel where the texture array must be set
  32248. * @param uniform defines the associated uniform location
  32249. * @param textures defines the array of textures to bind
  32250. */
  32251. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32252. /** @hidden */
  32253. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32254. private _setTextureParameterFloat;
  32255. private _setTextureParameterInteger;
  32256. /**
  32257. * Unbind all vertex attributes from the webGL context
  32258. */
  32259. unbindAllAttributes(): void;
  32260. /**
  32261. * 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
  32262. */
  32263. releaseEffects(): void;
  32264. /**
  32265. * Dispose and release all associated resources
  32266. */
  32267. dispose(): void;
  32268. /**
  32269. * Attach a new callback raised when context lost event is fired
  32270. * @param callback defines the callback to call
  32271. */
  32272. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32273. /**
  32274. * Attach a new callback raised when context restored event is fired
  32275. * @param callback defines the callback to call
  32276. */
  32277. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32278. /**
  32279. * Get the current error code of the webGL context
  32280. * @returns the error code
  32281. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32282. */
  32283. getError(): number;
  32284. private _canRenderToFloatFramebuffer;
  32285. private _canRenderToHalfFloatFramebuffer;
  32286. private _canRenderToFramebuffer;
  32287. /** @hidden */
  32288. _getWebGLTextureType(type: number): number;
  32289. /** @hidden */
  32290. _getInternalFormat(format: number): number;
  32291. /** @hidden */
  32292. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32293. /** @hidden */
  32294. _getRGBAMultiSampleBufferFormat(type: number): number;
  32295. /** @hidden */
  32296. _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;
  32297. /**
  32298. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32299. * @returns true if the engine can be created
  32300. * @ignorenaming
  32301. */
  32302. static isSupported(): boolean;
  32303. /**
  32304. * Find the next highest power of two.
  32305. * @param x Number to start search from.
  32306. * @return Next highest power of two.
  32307. */
  32308. static CeilingPOT(x: number): number;
  32309. /**
  32310. * Find the next lowest power of two.
  32311. * @param x Number to start search from.
  32312. * @return Next lowest power of two.
  32313. */
  32314. static FloorPOT(x: number): number;
  32315. /**
  32316. * Find the nearest power of two.
  32317. * @param x Number to start search from.
  32318. * @return Next nearest power of two.
  32319. */
  32320. static NearestPOT(x: number): number;
  32321. /**
  32322. * Get the closest exponent of two
  32323. * @param value defines the value to approximate
  32324. * @param max defines the maximum value to return
  32325. * @param mode defines how to define the closest value
  32326. * @returns closest exponent of two of the given value
  32327. */
  32328. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32329. /**
  32330. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32331. * @param func - the function to be called
  32332. * @param requester - the object that will request the next frame. Falls back to window.
  32333. * @returns frame number
  32334. */
  32335. static QueueNewFrame(func: () => void, requester?: any): number;
  32336. /**
  32337. * Gets host document
  32338. * @returns the host document object
  32339. */
  32340. getHostDocument(): Document;
  32341. }
  32342. }
  32343. declare module "babylonjs/Maths/sphericalPolynomial" {
  32344. import { Vector3 } from "babylonjs/Maths/math.vector";
  32345. import { Color3 } from "babylonjs/Maths/math.color";
  32346. /**
  32347. * Class representing spherical harmonics coefficients to the 3rd degree
  32348. */
  32349. export class SphericalHarmonics {
  32350. /**
  32351. * Defines whether or not the harmonics have been prescaled for rendering.
  32352. */
  32353. preScaled: boolean;
  32354. /**
  32355. * The l0,0 coefficients of the spherical harmonics
  32356. */
  32357. l00: Vector3;
  32358. /**
  32359. * The l1,-1 coefficients of the spherical harmonics
  32360. */
  32361. l1_1: Vector3;
  32362. /**
  32363. * The l1,0 coefficients of the spherical harmonics
  32364. */
  32365. l10: Vector3;
  32366. /**
  32367. * The l1,1 coefficients of the spherical harmonics
  32368. */
  32369. l11: Vector3;
  32370. /**
  32371. * The l2,-2 coefficients of the spherical harmonics
  32372. */
  32373. l2_2: Vector3;
  32374. /**
  32375. * The l2,-1 coefficients of the spherical harmonics
  32376. */
  32377. l2_1: Vector3;
  32378. /**
  32379. * The l2,0 coefficients of the spherical harmonics
  32380. */
  32381. l20: Vector3;
  32382. /**
  32383. * The l2,1 coefficients of the spherical harmonics
  32384. */
  32385. l21: Vector3;
  32386. /**
  32387. * The l2,2 coefficients of the spherical harmonics
  32388. */
  32389. l22: Vector3;
  32390. /**
  32391. * Adds a light to the spherical harmonics
  32392. * @param direction the direction of the light
  32393. * @param color the color of the light
  32394. * @param deltaSolidAngle the delta solid angle of the light
  32395. */
  32396. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32397. /**
  32398. * Scales the spherical harmonics by the given amount
  32399. * @param scale the amount to scale
  32400. */
  32401. scaleInPlace(scale: number): void;
  32402. /**
  32403. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32404. *
  32405. * ```
  32406. * E_lm = A_l * L_lm
  32407. * ```
  32408. *
  32409. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32410. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32411. * the scaling factors are given in equation 9.
  32412. */
  32413. convertIncidentRadianceToIrradiance(): void;
  32414. /**
  32415. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32416. *
  32417. * ```
  32418. * L = (1/pi) * E * rho
  32419. * ```
  32420. *
  32421. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32422. */
  32423. convertIrradianceToLambertianRadiance(): void;
  32424. /**
  32425. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32426. * required operations at run time.
  32427. *
  32428. * This is simply done by scaling back the SH with Ylm constants parameter.
  32429. * The trigonometric part being applied by the shader at run time.
  32430. */
  32431. preScaleForRendering(): void;
  32432. /**
  32433. * Constructs a spherical harmonics from an array.
  32434. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32435. * @returns the spherical harmonics
  32436. */
  32437. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32438. /**
  32439. * Gets the spherical harmonics from polynomial
  32440. * @param polynomial the spherical polynomial
  32441. * @returns the spherical harmonics
  32442. */
  32443. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32444. }
  32445. /**
  32446. * Class representing spherical polynomial coefficients to the 3rd degree
  32447. */
  32448. export class SphericalPolynomial {
  32449. private _harmonics;
  32450. /**
  32451. * The spherical harmonics used to create the polynomials.
  32452. */
  32453. readonly preScaledHarmonics: SphericalHarmonics;
  32454. /**
  32455. * The x coefficients of the spherical polynomial
  32456. */
  32457. x: Vector3;
  32458. /**
  32459. * The y coefficients of the spherical polynomial
  32460. */
  32461. y: Vector3;
  32462. /**
  32463. * The z coefficients of the spherical polynomial
  32464. */
  32465. z: Vector3;
  32466. /**
  32467. * The xx coefficients of the spherical polynomial
  32468. */
  32469. xx: Vector3;
  32470. /**
  32471. * The yy coefficients of the spherical polynomial
  32472. */
  32473. yy: Vector3;
  32474. /**
  32475. * The zz coefficients of the spherical polynomial
  32476. */
  32477. zz: Vector3;
  32478. /**
  32479. * The xy coefficients of the spherical polynomial
  32480. */
  32481. xy: Vector3;
  32482. /**
  32483. * The yz coefficients of the spherical polynomial
  32484. */
  32485. yz: Vector3;
  32486. /**
  32487. * The zx coefficients of the spherical polynomial
  32488. */
  32489. zx: Vector3;
  32490. /**
  32491. * Adds an ambient color to the spherical polynomial
  32492. * @param color the color to add
  32493. */
  32494. addAmbient(color: Color3): void;
  32495. /**
  32496. * Scales the spherical polynomial by the given amount
  32497. * @param scale the amount to scale
  32498. */
  32499. scaleInPlace(scale: number): void;
  32500. /**
  32501. * Gets the spherical polynomial from harmonics
  32502. * @param harmonics the spherical harmonics
  32503. * @returns the spherical polynomial
  32504. */
  32505. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32506. /**
  32507. * Constructs a spherical polynomial from an array.
  32508. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32509. * @returns the spherical polynomial
  32510. */
  32511. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32512. }
  32513. }
  32514. declare module "babylonjs/Materials/Textures/internalTexture" {
  32515. import { Observable } from "babylonjs/Misc/observable";
  32516. import { Nullable, int } from "babylonjs/types";
  32517. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32518. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32519. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32520. /**
  32521. * Defines the source of the internal texture
  32522. */
  32523. export enum InternalTextureSource {
  32524. /**
  32525. * The source of the texture data is unknown
  32526. */
  32527. Unknown = 0,
  32528. /**
  32529. * Texture data comes from an URL
  32530. */
  32531. Url = 1,
  32532. /**
  32533. * Texture data is only used for temporary storage
  32534. */
  32535. Temp = 2,
  32536. /**
  32537. * Texture data comes from raw data (ArrayBuffer)
  32538. */
  32539. Raw = 3,
  32540. /**
  32541. * Texture content is dynamic (video or dynamic texture)
  32542. */
  32543. Dynamic = 4,
  32544. /**
  32545. * Texture content is generated by rendering to it
  32546. */
  32547. RenderTarget = 5,
  32548. /**
  32549. * Texture content is part of a multi render target process
  32550. */
  32551. MultiRenderTarget = 6,
  32552. /**
  32553. * Texture data comes from a cube data file
  32554. */
  32555. Cube = 7,
  32556. /**
  32557. * Texture data comes from a raw cube data
  32558. */
  32559. CubeRaw = 8,
  32560. /**
  32561. * Texture data come from a prefiltered cube data file
  32562. */
  32563. CubePrefiltered = 9,
  32564. /**
  32565. * Texture content is raw 3D data
  32566. */
  32567. Raw3D = 10,
  32568. /**
  32569. * Texture content is raw 2D array data
  32570. */
  32571. Raw2DArray = 11,
  32572. /**
  32573. * Texture content is a depth texture
  32574. */
  32575. Depth = 12,
  32576. /**
  32577. * Texture data comes from a raw cube data encoded with RGBD
  32578. */
  32579. CubeRawRGBD = 13
  32580. }
  32581. /**
  32582. * Class used to store data associated with WebGL texture data for the engine
  32583. * This class should not be used directly
  32584. */
  32585. export class InternalTexture {
  32586. /** @hidden */
  32587. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32588. /**
  32589. * Defines if the texture is ready
  32590. */
  32591. isReady: boolean;
  32592. /**
  32593. * Defines if the texture is a cube texture
  32594. */
  32595. isCube: boolean;
  32596. /**
  32597. * Defines if the texture contains 3D data
  32598. */
  32599. is3D: boolean;
  32600. /**
  32601. * Defines if the texture contains 2D array data
  32602. */
  32603. is2DArray: boolean;
  32604. /**
  32605. * Defines if the texture contains multiview data
  32606. */
  32607. isMultiview: boolean;
  32608. /**
  32609. * Gets the URL used to load this texture
  32610. */
  32611. url: string;
  32612. /**
  32613. * Gets the sampling mode of the texture
  32614. */
  32615. samplingMode: number;
  32616. /**
  32617. * Gets a boolean indicating if the texture needs mipmaps generation
  32618. */
  32619. generateMipMaps: boolean;
  32620. /**
  32621. * Gets the number of samples used by the texture (WebGL2+ only)
  32622. */
  32623. samples: number;
  32624. /**
  32625. * Gets the type of the texture (int, float...)
  32626. */
  32627. type: number;
  32628. /**
  32629. * Gets the format of the texture (RGB, RGBA...)
  32630. */
  32631. format: number;
  32632. /**
  32633. * Observable called when the texture is loaded
  32634. */
  32635. onLoadedObservable: Observable<InternalTexture>;
  32636. /**
  32637. * Gets the width of the texture
  32638. */
  32639. width: number;
  32640. /**
  32641. * Gets the height of the texture
  32642. */
  32643. height: number;
  32644. /**
  32645. * Gets the depth of the texture
  32646. */
  32647. depth: number;
  32648. /**
  32649. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32650. */
  32651. baseWidth: number;
  32652. /**
  32653. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32654. */
  32655. baseHeight: number;
  32656. /**
  32657. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32658. */
  32659. baseDepth: number;
  32660. /**
  32661. * Gets a boolean indicating if the texture is inverted on Y axis
  32662. */
  32663. invertY: boolean;
  32664. /** @hidden */
  32665. _invertVScale: boolean;
  32666. /** @hidden */
  32667. _associatedChannel: number;
  32668. /** @hidden */
  32669. _source: InternalTextureSource;
  32670. /** @hidden */
  32671. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32672. /** @hidden */
  32673. _bufferView: Nullable<ArrayBufferView>;
  32674. /** @hidden */
  32675. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32676. /** @hidden */
  32677. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32678. /** @hidden */
  32679. _size: number;
  32680. /** @hidden */
  32681. _extension: string;
  32682. /** @hidden */
  32683. _files: Nullable<string[]>;
  32684. /** @hidden */
  32685. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32686. /** @hidden */
  32687. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32688. /** @hidden */
  32689. _framebuffer: Nullable<WebGLFramebuffer>;
  32690. /** @hidden */
  32691. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32692. /** @hidden */
  32693. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32694. /** @hidden */
  32695. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32696. /** @hidden */
  32697. _attachments: Nullable<number[]>;
  32698. /** @hidden */
  32699. _cachedCoordinatesMode: Nullable<number>;
  32700. /** @hidden */
  32701. _cachedWrapU: Nullable<number>;
  32702. /** @hidden */
  32703. _cachedWrapV: Nullable<number>;
  32704. /** @hidden */
  32705. _cachedWrapR: Nullable<number>;
  32706. /** @hidden */
  32707. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32708. /** @hidden */
  32709. _isDisabled: boolean;
  32710. /** @hidden */
  32711. _compression: Nullable<string>;
  32712. /** @hidden */
  32713. _generateStencilBuffer: boolean;
  32714. /** @hidden */
  32715. _generateDepthBuffer: boolean;
  32716. /** @hidden */
  32717. _comparisonFunction: number;
  32718. /** @hidden */
  32719. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32720. /** @hidden */
  32721. _lodGenerationScale: number;
  32722. /** @hidden */
  32723. _lodGenerationOffset: number;
  32724. /** @hidden */
  32725. _colorTextureArray: Nullable<WebGLTexture>;
  32726. /** @hidden */
  32727. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32728. /** @hidden */
  32729. _lodTextureHigh: Nullable<BaseTexture>;
  32730. /** @hidden */
  32731. _lodTextureMid: Nullable<BaseTexture>;
  32732. /** @hidden */
  32733. _lodTextureLow: Nullable<BaseTexture>;
  32734. /** @hidden */
  32735. _isRGBD: boolean;
  32736. /** @hidden */
  32737. _linearSpecularLOD: boolean;
  32738. /** @hidden */
  32739. _irradianceTexture: Nullable<BaseTexture>;
  32740. /** @hidden */
  32741. _webGLTexture: Nullable<WebGLTexture>;
  32742. /** @hidden */
  32743. _references: number;
  32744. private _engine;
  32745. /**
  32746. * Gets the Engine the texture belongs to.
  32747. * @returns The babylon engine
  32748. */
  32749. getEngine(): ThinEngine;
  32750. /**
  32751. * Gets the data source type of the texture
  32752. */
  32753. readonly source: InternalTextureSource;
  32754. /**
  32755. * Creates a new InternalTexture
  32756. * @param engine defines the engine to use
  32757. * @param source defines the type of data that will be used
  32758. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32759. */
  32760. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32761. /**
  32762. * Increments the number of references (ie. the number of Texture that point to it)
  32763. */
  32764. incrementReferences(): void;
  32765. /**
  32766. * Change the size of the texture (not the size of the content)
  32767. * @param width defines the new width
  32768. * @param height defines the new height
  32769. * @param depth defines the new depth (1 by default)
  32770. */
  32771. updateSize(width: int, height: int, depth?: int): void;
  32772. /** @hidden */
  32773. _rebuild(): void;
  32774. /** @hidden */
  32775. _swapAndDie(target: InternalTexture): void;
  32776. /**
  32777. * Dispose the current allocated resources
  32778. */
  32779. dispose(): void;
  32780. }
  32781. }
  32782. declare module "babylonjs/Audio/analyser" {
  32783. import { Scene } from "babylonjs/scene";
  32784. /**
  32785. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32787. */
  32788. export class Analyser {
  32789. /**
  32790. * Gets or sets the smoothing
  32791. * @ignorenaming
  32792. */
  32793. SMOOTHING: number;
  32794. /**
  32795. * Gets or sets the FFT table size
  32796. * @ignorenaming
  32797. */
  32798. FFT_SIZE: number;
  32799. /**
  32800. * Gets or sets the bar graph amplitude
  32801. * @ignorenaming
  32802. */
  32803. BARGRAPHAMPLITUDE: number;
  32804. /**
  32805. * Gets or sets the position of the debug canvas
  32806. * @ignorenaming
  32807. */
  32808. DEBUGCANVASPOS: {
  32809. x: number;
  32810. y: number;
  32811. };
  32812. /**
  32813. * Gets or sets the debug canvas size
  32814. * @ignorenaming
  32815. */
  32816. DEBUGCANVASSIZE: {
  32817. width: number;
  32818. height: number;
  32819. };
  32820. private _byteFreqs;
  32821. private _byteTime;
  32822. private _floatFreqs;
  32823. private _webAudioAnalyser;
  32824. private _debugCanvas;
  32825. private _debugCanvasContext;
  32826. private _scene;
  32827. private _registerFunc;
  32828. private _audioEngine;
  32829. /**
  32830. * Creates a new analyser
  32831. * @param scene defines hosting scene
  32832. */
  32833. constructor(scene: Scene);
  32834. /**
  32835. * Get the number of data values you will have to play with for the visualization
  32836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32837. * @returns a number
  32838. */
  32839. getFrequencyBinCount(): number;
  32840. /**
  32841. * Gets the current frequency data as a byte array
  32842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32843. * @returns a Uint8Array
  32844. */
  32845. getByteFrequencyData(): Uint8Array;
  32846. /**
  32847. * Gets the current waveform as a byte array
  32848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32849. * @returns a Uint8Array
  32850. */
  32851. getByteTimeDomainData(): Uint8Array;
  32852. /**
  32853. * Gets the current frequency data as a float array
  32854. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32855. * @returns a Float32Array
  32856. */
  32857. getFloatFrequencyData(): Float32Array;
  32858. /**
  32859. * Renders the debug canvas
  32860. */
  32861. drawDebugCanvas(): void;
  32862. /**
  32863. * Stops rendering the debug canvas and removes it
  32864. */
  32865. stopDebugCanvas(): void;
  32866. /**
  32867. * Connects two audio nodes
  32868. * @param inputAudioNode defines first node to connect
  32869. * @param outputAudioNode defines second node to connect
  32870. */
  32871. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32872. /**
  32873. * Releases all associated resources
  32874. */
  32875. dispose(): void;
  32876. }
  32877. }
  32878. declare module "babylonjs/Audio/audioEngine" {
  32879. import { IDisposable } from "babylonjs/scene";
  32880. import { Analyser } from "babylonjs/Audio/analyser";
  32881. import { Nullable } from "babylonjs/types";
  32882. import { Observable } from "babylonjs/Misc/observable";
  32883. /**
  32884. * This represents an audio engine and it is responsible
  32885. * to play, synchronize and analyse sounds throughout the application.
  32886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32887. */
  32888. export interface IAudioEngine extends IDisposable {
  32889. /**
  32890. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32891. */
  32892. readonly canUseWebAudio: boolean;
  32893. /**
  32894. * Gets the current AudioContext if available.
  32895. */
  32896. readonly audioContext: Nullable<AudioContext>;
  32897. /**
  32898. * The master gain node defines the global audio volume of your audio engine.
  32899. */
  32900. readonly masterGain: GainNode;
  32901. /**
  32902. * Gets whether or not mp3 are supported by your browser.
  32903. */
  32904. readonly isMP3supported: boolean;
  32905. /**
  32906. * Gets whether or not ogg are supported by your browser.
  32907. */
  32908. readonly isOGGsupported: boolean;
  32909. /**
  32910. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32911. * @ignoreNaming
  32912. */
  32913. WarnedWebAudioUnsupported: boolean;
  32914. /**
  32915. * Defines if the audio engine relies on a custom unlocked button.
  32916. * In this case, the embedded button will not be displayed.
  32917. */
  32918. useCustomUnlockedButton: boolean;
  32919. /**
  32920. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32921. */
  32922. readonly unlocked: boolean;
  32923. /**
  32924. * Event raised when audio has been unlocked on the browser.
  32925. */
  32926. onAudioUnlockedObservable: Observable<AudioEngine>;
  32927. /**
  32928. * Event raised when audio has been locked on the browser.
  32929. */
  32930. onAudioLockedObservable: Observable<AudioEngine>;
  32931. /**
  32932. * Flags the audio engine in Locked state.
  32933. * This happens due to new browser policies preventing audio to autoplay.
  32934. */
  32935. lock(): void;
  32936. /**
  32937. * Unlocks the audio engine once a user action has been done on the dom.
  32938. * This is helpful to resume play once browser policies have been satisfied.
  32939. */
  32940. unlock(): void;
  32941. }
  32942. /**
  32943. * This represents the default audio engine used in babylon.
  32944. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32946. */
  32947. export class AudioEngine implements IAudioEngine {
  32948. private _audioContext;
  32949. private _audioContextInitialized;
  32950. private _muteButton;
  32951. private _hostElement;
  32952. /**
  32953. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32954. */
  32955. canUseWebAudio: boolean;
  32956. /**
  32957. * The master gain node defines the global audio volume of your audio engine.
  32958. */
  32959. masterGain: GainNode;
  32960. /**
  32961. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32962. * @ignoreNaming
  32963. */
  32964. WarnedWebAudioUnsupported: boolean;
  32965. /**
  32966. * Gets whether or not mp3 are supported by your browser.
  32967. */
  32968. isMP3supported: boolean;
  32969. /**
  32970. * Gets whether or not ogg are supported by your browser.
  32971. */
  32972. isOGGsupported: boolean;
  32973. /**
  32974. * Gets whether audio has been unlocked on the device.
  32975. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32976. * a user interaction has happened.
  32977. */
  32978. unlocked: boolean;
  32979. /**
  32980. * Defines if the audio engine relies on a custom unlocked button.
  32981. * In this case, the embedded button will not be displayed.
  32982. */
  32983. useCustomUnlockedButton: boolean;
  32984. /**
  32985. * Event raised when audio has been unlocked on the browser.
  32986. */
  32987. onAudioUnlockedObservable: Observable<AudioEngine>;
  32988. /**
  32989. * Event raised when audio has been locked on the browser.
  32990. */
  32991. onAudioLockedObservable: Observable<AudioEngine>;
  32992. /**
  32993. * Gets the current AudioContext if available.
  32994. */
  32995. readonly audioContext: Nullable<AudioContext>;
  32996. private _connectedAnalyser;
  32997. /**
  32998. * Instantiates a new audio engine.
  32999. *
  33000. * There should be only one per page as some browsers restrict the number
  33001. * of audio contexts you can create.
  33002. * @param hostElement defines the host element where to display the mute icon if necessary
  33003. */
  33004. constructor(hostElement?: Nullable<HTMLElement>);
  33005. /**
  33006. * Flags the audio engine in Locked state.
  33007. * This happens due to new browser policies preventing audio to autoplay.
  33008. */
  33009. lock(): void;
  33010. /**
  33011. * Unlocks the audio engine once a user action has been done on the dom.
  33012. * This is helpful to resume play once browser policies have been satisfied.
  33013. */
  33014. unlock(): void;
  33015. private _resumeAudioContext;
  33016. private _initializeAudioContext;
  33017. private _tryToRun;
  33018. private _triggerRunningState;
  33019. private _triggerSuspendedState;
  33020. private _displayMuteButton;
  33021. private _moveButtonToTopLeft;
  33022. private _onResize;
  33023. private _hideMuteButton;
  33024. /**
  33025. * Destroy and release the resources associated with the audio ccontext.
  33026. */
  33027. dispose(): void;
  33028. /**
  33029. * Gets the global volume sets on the master gain.
  33030. * @returns the global volume if set or -1 otherwise
  33031. */
  33032. getGlobalVolume(): number;
  33033. /**
  33034. * Sets the global volume of your experience (sets on the master gain).
  33035. * @param newVolume Defines the new global volume of the application
  33036. */
  33037. setGlobalVolume(newVolume: number): void;
  33038. /**
  33039. * Connect the audio engine to an audio analyser allowing some amazing
  33040. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33042. * @param analyser The analyser to connect to the engine
  33043. */
  33044. connectToAnalyser(analyser: Analyser): void;
  33045. }
  33046. }
  33047. declare module "babylonjs/Loading/loadingScreen" {
  33048. /**
  33049. * Interface used to present a loading screen while loading a scene
  33050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33051. */
  33052. export interface ILoadingScreen {
  33053. /**
  33054. * Function called to display the loading screen
  33055. */
  33056. displayLoadingUI: () => void;
  33057. /**
  33058. * Function called to hide the loading screen
  33059. */
  33060. hideLoadingUI: () => void;
  33061. /**
  33062. * Gets or sets the color to use for the background
  33063. */
  33064. loadingUIBackgroundColor: string;
  33065. /**
  33066. * Gets or sets the text to display while loading
  33067. */
  33068. loadingUIText: string;
  33069. }
  33070. /**
  33071. * Class used for the default loading screen
  33072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33073. */
  33074. export class DefaultLoadingScreen implements ILoadingScreen {
  33075. private _renderingCanvas;
  33076. private _loadingText;
  33077. private _loadingDivBackgroundColor;
  33078. private _loadingDiv;
  33079. private _loadingTextDiv;
  33080. /** Gets or sets the logo url to use for the default loading screen */
  33081. static DefaultLogoUrl: string;
  33082. /** Gets or sets the spinner url to use for the default loading screen */
  33083. static DefaultSpinnerUrl: string;
  33084. /**
  33085. * Creates a new default loading screen
  33086. * @param _renderingCanvas defines the canvas used to render the scene
  33087. * @param _loadingText defines the default text to display
  33088. * @param _loadingDivBackgroundColor defines the default background color
  33089. */
  33090. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33091. /**
  33092. * Function called to display the loading screen
  33093. */
  33094. displayLoadingUI(): void;
  33095. /**
  33096. * Function called to hide the loading screen
  33097. */
  33098. hideLoadingUI(): void;
  33099. /**
  33100. * Gets or sets the text to display while loading
  33101. */
  33102. loadingUIText: string;
  33103. /**
  33104. * Gets or sets the color to use for the background
  33105. */
  33106. loadingUIBackgroundColor: string;
  33107. private _resizeLoadingUI;
  33108. }
  33109. }
  33110. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33111. /**
  33112. * Interface for any object that can request an animation frame
  33113. */
  33114. export interface ICustomAnimationFrameRequester {
  33115. /**
  33116. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33117. */
  33118. renderFunction?: Function;
  33119. /**
  33120. * Called to request the next frame to render to
  33121. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33122. */
  33123. requestAnimationFrame: Function;
  33124. /**
  33125. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33126. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33127. */
  33128. requestID?: number;
  33129. }
  33130. }
  33131. declare module "babylonjs/Misc/performanceMonitor" {
  33132. /**
  33133. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33134. */
  33135. export class PerformanceMonitor {
  33136. private _enabled;
  33137. private _rollingFrameTime;
  33138. private _lastFrameTimeMs;
  33139. /**
  33140. * constructor
  33141. * @param frameSampleSize The number of samples required to saturate the sliding window
  33142. */
  33143. constructor(frameSampleSize?: number);
  33144. /**
  33145. * Samples current frame
  33146. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33147. */
  33148. sampleFrame(timeMs?: number): void;
  33149. /**
  33150. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33151. */
  33152. readonly averageFrameTime: number;
  33153. /**
  33154. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33155. */
  33156. readonly averageFrameTimeVariance: number;
  33157. /**
  33158. * Returns the frame time of the most recent frame
  33159. */
  33160. readonly instantaneousFrameTime: number;
  33161. /**
  33162. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33163. */
  33164. readonly averageFPS: number;
  33165. /**
  33166. * Returns the average framerate in frames per second using the most recent frame time
  33167. */
  33168. readonly instantaneousFPS: number;
  33169. /**
  33170. * Returns true if enough samples have been taken to completely fill the sliding window
  33171. */
  33172. readonly isSaturated: boolean;
  33173. /**
  33174. * Enables contributions to the sliding window sample set
  33175. */
  33176. enable(): void;
  33177. /**
  33178. * Disables contributions to the sliding window sample set
  33179. * Samples will not be interpolated over the disabled period
  33180. */
  33181. disable(): void;
  33182. /**
  33183. * Returns true if sampling is enabled
  33184. */
  33185. readonly isEnabled: boolean;
  33186. /**
  33187. * Resets performance monitor
  33188. */
  33189. reset(): void;
  33190. }
  33191. /**
  33192. * RollingAverage
  33193. *
  33194. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33195. */
  33196. export class RollingAverage {
  33197. /**
  33198. * Current average
  33199. */
  33200. average: number;
  33201. /**
  33202. * Current variance
  33203. */
  33204. variance: number;
  33205. protected _samples: Array<number>;
  33206. protected _sampleCount: number;
  33207. protected _pos: number;
  33208. protected _m2: number;
  33209. /**
  33210. * constructor
  33211. * @param length The number of samples required to saturate the sliding window
  33212. */
  33213. constructor(length: number);
  33214. /**
  33215. * Adds a sample to the sample set
  33216. * @param v The sample value
  33217. */
  33218. add(v: number): void;
  33219. /**
  33220. * Returns previously added values or null if outside of history or outside the sliding window domain
  33221. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33222. * @return Value previously recorded with add() or null if outside of range
  33223. */
  33224. history(i: number): number;
  33225. /**
  33226. * Returns true if enough samples have been taken to completely fill the sliding window
  33227. * @return true if sample-set saturated
  33228. */
  33229. isSaturated(): boolean;
  33230. /**
  33231. * Resets the rolling average (equivalent to 0 samples taken so far)
  33232. */
  33233. reset(): void;
  33234. /**
  33235. * Wraps a value around the sample range boundaries
  33236. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33237. * @return Wrapped position in sample range
  33238. */
  33239. protected _wrapPosition(i: number): number;
  33240. }
  33241. }
  33242. declare module "babylonjs/Misc/perfCounter" {
  33243. /**
  33244. * This class is used to track a performance counter which is number based.
  33245. * The user has access to many properties which give statistics of different nature.
  33246. *
  33247. * The implementer can track two kinds of Performance Counter: time and count.
  33248. * 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.
  33249. * 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.
  33250. */
  33251. export class PerfCounter {
  33252. /**
  33253. * Gets or sets a global boolean to turn on and off all the counters
  33254. */
  33255. static Enabled: boolean;
  33256. /**
  33257. * Returns the smallest value ever
  33258. */
  33259. readonly min: number;
  33260. /**
  33261. * Returns the biggest value ever
  33262. */
  33263. readonly max: number;
  33264. /**
  33265. * Returns the average value since the performance counter is running
  33266. */
  33267. readonly average: number;
  33268. /**
  33269. * Returns the average value of the last second the counter was monitored
  33270. */
  33271. readonly lastSecAverage: number;
  33272. /**
  33273. * Returns the current value
  33274. */
  33275. readonly current: number;
  33276. /**
  33277. * Gets the accumulated total
  33278. */
  33279. readonly total: number;
  33280. /**
  33281. * Gets the total value count
  33282. */
  33283. readonly count: number;
  33284. /**
  33285. * Creates a new counter
  33286. */
  33287. constructor();
  33288. /**
  33289. * Call this method to start monitoring a new frame.
  33290. * 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.
  33291. */
  33292. fetchNewFrame(): void;
  33293. /**
  33294. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33295. * @param newCount the count value to add to the monitored count
  33296. * @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.
  33297. */
  33298. addCount(newCount: number, fetchResult: boolean): void;
  33299. /**
  33300. * Start monitoring this performance counter
  33301. */
  33302. beginMonitoring(): void;
  33303. /**
  33304. * Compute the time lapsed since the previous beginMonitoring() call.
  33305. * @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
  33306. */
  33307. endMonitoring(newFrame?: boolean): void;
  33308. private _fetchResult;
  33309. private _startMonitoringTime;
  33310. private _min;
  33311. private _max;
  33312. private _average;
  33313. private _current;
  33314. private _totalValueCount;
  33315. private _totalAccumulated;
  33316. private _lastSecAverage;
  33317. private _lastSecAccumulated;
  33318. private _lastSecTime;
  33319. private _lastSecValueCount;
  33320. }
  33321. }
  33322. declare module "babylonjs/Engines/engine" {
  33323. import { Observable } from "babylonjs/Misc/observable";
  33324. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33325. import { Scene } from "babylonjs/scene";
  33326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33327. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33328. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33329. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33330. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33331. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33332. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33333. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33334. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33335. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33336. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33337. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33338. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33339. import { Material } from "babylonjs/Materials/material";
  33340. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33341. /**
  33342. * Defines the interface used by display changed events
  33343. */
  33344. export interface IDisplayChangedEventArgs {
  33345. /** Gets the vrDisplay object (if any) */
  33346. vrDisplay: Nullable<any>;
  33347. /** Gets a boolean indicating if webVR is supported */
  33348. vrSupported: boolean;
  33349. }
  33350. /**
  33351. * Defines the interface used by objects containing a viewport (like a camera)
  33352. */
  33353. interface IViewportOwnerLike {
  33354. /**
  33355. * Gets or sets the viewport
  33356. */
  33357. viewport: IViewportLike;
  33358. }
  33359. /**
  33360. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33361. */
  33362. export class Engine extends ThinEngine {
  33363. /** Defines that alpha blending is disabled */
  33364. static readonly ALPHA_DISABLE: number;
  33365. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33366. static readonly ALPHA_ADD: number;
  33367. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33368. static readonly ALPHA_COMBINE: number;
  33369. /** Defines that alpha blending to DEST - SRC * DEST */
  33370. static readonly ALPHA_SUBTRACT: number;
  33371. /** Defines that alpha blending to SRC * DEST */
  33372. static readonly ALPHA_MULTIPLY: number;
  33373. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33374. static readonly ALPHA_MAXIMIZED: number;
  33375. /** Defines that alpha blending to SRC + DEST */
  33376. static readonly ALPHA_ONEONE: number;
  33377. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33378. static readonly ALPHA_PREMULTIPLIED: number;
  33379. /**
  33380. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33381. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33382. */
  33383. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33384. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33385. static readonly ALPHA_INTERPOLATE: number;
  33386. /**
  33387. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33388. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33389. */
  33390. static readonly ALPHA_SCREENMODE: number;
  33391. /** Defines that the ressource is not delayed*/
  33392. static readonly DELAYLOADSTATE_NONE: number;
  33393. /** Defines that the ressource was successfully delay loaded */
  33394. static readonly DELAYLOADSTATE_LOADED: number;
  33395. /** Defines that the ressource is currently delay loading */
  33396. static readonly DELAYLOADSTATE_LOADING: number;
  33397. /** Defines that the ressource is delayed and has not started loading */
  33398. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33399. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33400. static readonly NEVER: number;
  33401. /** 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 */
  33402. static readonly ALWAYS: number;
  33403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33404. static readonly LESS: number;
  33405. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33406. static readonly EQUAL: number;
  33407. /** 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 */
  33408. static readonly LEQUAL: number;
  33409. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33410. static readonly GREATER: number;
  33411. /** 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 */
  33412. static readonly GEQUAL: number;
  33413. /** 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 */
  33414. static readonly NOTEQUAL: number;
  33415. /** Passed to stencilOperation to specify that stencil value must be kept */
  33416. static readonly KEEP: number;
  33417. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33418. static readonly REPLACE: number;
  33419. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33420. static readonly INCR: number;
  33421. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33422. static readonly DECR: number;
  33423. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33424. static readonly INVERT: number;
  33425. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33426. static readonly INCR_WRAP: number;
  33427. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33428. static readonly DECR_WRAP: number;
  33429. /** Texture is not repeating outside of 0..1 UVs */
  33430. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33431. /** Texture is repeating outside of 0..1 UVs */
  33432. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33433. /** Texture is repeating and mirrored */
  33434. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33435. /** ALPHA */
  33436. static readonly TEXTUREFORMAT_ALPHA: number;
  33437. /** LUMINANCE */
  33438. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33439. /** LUMINANCE_ALPHA */
  33440. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33441. /** RGB */
  33442. static readonly TEXTUREFORMAT_RGB: number;
  33443. /** RGBA */
  33444. static readonly TEXTUREFORMAT_RGBA: number;
  33445. /** RED */
  33446. static readonly TEXTUREFORMAT_RED: number;
  33447. /** RED (2nd reference) */
  33448. static readonly TEXTUREFORMAT_R: number;
  33449. /** RG */
  33450. static readonly TEXTUREFORMAT_RG: number;
  33451. /** RED_INTEGER */
  33452. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33453. /** RED_INTEGER (2nd reference) */
  33454. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33455. /** RG_INTEGER */
  33456. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33457. /** RGB_INTEGER */
  33458. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33459. /** RGBA_INTEGER */
  33460. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33461. /** UNSIGNED_BYTE */
  33462. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33463. /** UNSIGNED_BYTE (2nd reference) */
  33464. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33465. /** FLOAT */
  33466. static readonly TEXTURETYPE_FLOAT: number;
  33467. /** HALF_FLOAT */
  33468. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33469. /** BYTE */
  33470. static readonly TEXTURETYPE_BYTE: number;
  33471. /** SHORT */
  33472. static readonly TEXTURETYPE_SHORT: number;
  33473. /** UNSIGNED_SHORT */
  33474. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33475. /** INT */
  33476. static readonly TEXTURETYPE_INT: number;
  33477. /** UNSIGNED_INT */
  33478. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33479. /** UNSIGNED_SHORT_4_4_4_4 */
  33480. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33481. /** UNSIGNED_SHORT_5_5_5_1 */
  33482. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33483. /** UNSIGNED_SHORT_5_6_5 */
  33484. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33485. /** UNSIGNED_INT_2_10_10_10_REV */
  33486. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33487. /** UNSIGNED_INT_24_8 */
  33488. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33489. /** UNSIGNED_INT_10F_11F_11F_REV */
  33490. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33491. /** UNSIGNED_INT_5_9_9_9_REV */
  33492. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33493. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33494. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33495. /** nearest is mag = nearest and min = nearest and mip = linear */
  33496. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33497. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33498. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33499. /** Trilinear is mag = linear and min = linear and mip = linear */
  33500. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33501. /** nearest is mag = nearest and min = nearest and mip = linear */
  33502. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33503. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33504. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33505. /** Trilinear is mag = linear and min = linear and mip = linear */
  33506. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33507. /** mag = nearest and min = nearest and mip = nearest */
  33508. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33509. /** mag = nearest and min = linear and mip = nearest */
  33510. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33511. /** mag = nearest and min = linear and mip = linear */
  33512. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33513. /** mag = nearest and min = linear and mip = none */
  33514. static readonly TEXTURE_NEAREST_LINEAR: number;
  33515. /** mag = nearest and min = nearest and mip = none */
  33516. static readonly TEXTURE_NEAREST_NEAREST: number;
  33517. /** mag = linear and min = nearest and mip = nearest */
  33518. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33519. /** mag = linear and min = nearest and mip = linear */
  33520. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33521. /** mag = linear and min = linear and mip = none */
  33522. static readonly TEXTURE_LINEAR_LINEAR: number;
  33523. /** mag = linear and min = nearest and mip = none */
  33524. static readonly TEXTURE_LINEAR_NEAREST: number;
  33525. /** Explicit coordinates mode */
  33526. static readonly TEXTURE_EXPLICIT_MODE: number;
  33527. /** Spherical coordinates mode */
  33528. static readonly TEXTURE_SPHERICAL_MODE: number;
  33529. /** Planar coordinates mode */
  33530. static readonly TEXTURE_PLANAR_MODE: number;
  33531. /** Cubic coordinates mode */
  33532. static readonly TEXTURE_CUBIC_MODE: number;
  33533. /** Projection coordinates mode */
  33534. static readonly TEXTURE_PROJECTION_MODE: number;
  33535. /** Skybox coordinates mode */
  33536. static readonly TEXTURE_SKYBOX_MODE: number;
  33537. /** Inverse Cubic coordinates mode */
  33538. static readonly TEXTURE_INVCUBIC_MODE: number;
  33539. /** Equirectangular coordinates mode */
  33540. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33541. /** Equirectangular Fixed coordinates mode */
  33542. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33543. /** Equirectangular Fixed Mirrored coordinates mode */
  33544. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33545. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33546. static readonly SCALEMODE_FLOOR: number;
  33547. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33548. static readonly SCALEMODE_NEAREST: number;
  33549. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33550. static readonly SCALEMODE_CEILING: number;
  33551. /**
  33552. * Returns the current npm package of the sdk
  33553. */
  33554. static readonly NpmPackage: string;
  33555. /**
  33556. * Returns the current version of the framework
  33557. */
  33558. static readonly Version: string;
  33559. /** Gets the list of created engines */
  33560. static readonly Instances: Engine[];
  33561. /**
  33562. * Gets the latest created engine
  33563. */
  33564. static readonly LastCreatedEngine: Nullable<Engine>;
  33565. /**
  33566. * Gets the latest created scene
  33567. */
  33568. static readonly LastCreatedScene: Nullable<Scene>;
  33569. /**
  33570. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33571. * @param flag defines which part of the materials must be marked as dirty
  33572. * @param predicate defines a predicate used to filter which materials should be affected
  33573. */
  33574. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33575. /**
  33576. * Method called to create the default loading screen.
  33577. * This can be overriden in your own app.
  33578. * @param canvas The rendering canvas element
  33579. * @returns The loading screen
  33580. */
  33581. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33582. /**
  33583. * Method called to create the default rescale post process on each engine.
  33584. */
  33585. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33586. /**
  33587. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33588. **/
  33589. enableOfflineSupport: boolean;
  33590. /**
  33591. * 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)
  33592. **/
  33593. disableManifestCheck: boolean;
  33594. /**
  33595. * Gets the list of created scenes
  33596. */
  33597. scenes: Scene[];
  33598. /**
  33599. * Event raised when a new scene is created
  33600. */
  33601. onNewSceneAddedObservable: Observable<Scene>;
  33602. /**
  33603. * Gets the list of created postprocesses
  33604. */
  33605. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33606. /**
  33607. * Gets a boolean indicating if the pointer is currently locked
  33608. */
  33609. isPointerLock: boolean;
  33610. /**
  33611. * Observable event triggered each time the rendering canvas is resized
  33612. */
  33613. onResizeObservable: Observable<Engine>;
  33614. /**
  33615. * Observable event triggered each time the canvas loses focus
  33616. */
  33617. onCanvasBlurObservable: Observable<Engine>;
  33618. /**
  33619. * Observable event triggered each time the canvas gains focus
  33620. */
  33621. onCanvasFocusObservable: Observable<Engine>;
  33622. /**
  33623. * Observable event triggered each time the canvas receives pointerout event
  33624. */
  33625. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33626. /**
  33627. * Observable raised when the engine begins a new frame
  33628. */
  33629. onBeginFrameObservable: Observable<Engine>;
  33630. /**
  33631. * If set, will be used to request the next animation frame for the render loop
  33632. */
  33633. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33634. /**
  33635. * Observable raised when the engine ends the current frame
  33636. */
  33637. onEndFrameObservable: Observable<Engine>;
  33638. /**
  33639. * Observable raised when the engine is about to compile a shader
  33640. */
  33641. onBeforeShaderCompilationObservable: Observable<Engine>;
  33642. /**
  33643. * Observable raised when the engine has jsut compiled a shader
  33644. */
  33645. onAfterShaderCompilationObservable: Observable<Engine>;
  33646. /**
  33647. * Gets the audio engine
  33648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33649. * @ignorenaming
  33650. */
  33651. static audioEngine: IAudioEngine;
  33652. /**
  33653. * Default AudioEngine factory responsible of creating the Audio Engine.
  33654. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33655. */
  33656. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33657. /**
  33658. * Default offline support factory responsible of creating a tool used to store data locally.
  33659. * By default, this will create a Database object if the workload has been embedded.
  33660. */
  33661. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33662. private _loadingScreen;
  33663. private _pointerLockRequested;
  33664. private _dummyFramebuffer;
  33665. private _rescalePostProcess;
  33666. /** @hidden */
  33667. protected _alphaMode: number;
  33668. /** @hidden */
  33669. protected _alphaEquation: number;
  33670. private _deterministicLockstep;
  33671. private _lockstepMaxSteps;
  33672. private _timeStep;
  33673. protected readonly _supportsHardwareTextureRescaling: boolean;
  33674. private _fps;
  33675. private _deltaTime;
  33676. /** @hidden */
  33677. _drawCalls: PerfCounter;
  33678. /**
  33679. * Turn this value on if you want to pause FPS computation when in background
  33680. */
  33681. disablePerformanceMonitorInBackground: boolean;
  33682. private _performanceMonitor;
  33683. /**
  33684. * Gets the performance monitor attached to this engine
  33685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33686. */
  33687. readonly performanceMonitor: PerformanceMonitor;
  33688. private _onFocus;
  33689. private _onBlur;
  33690. private _onCanvasPointerOut;
  33691. private _onCanvasBlur;
  33692. private _onCanvasFocus;
  33693. private _onFullscreenChange;
  33694. private _onPointerLockChange;
  33695. /**
  33696. * Gets the HTML element used to attach event listeners
  33697. * @returns a HTML element
  33698. */
  33699. getInputElement(): Nullable<HTMLElement>;
  33700. /**
  33701. * Creates a new engine
  33702. * @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
  33703. * @param antialias defines enable antialiasing (default: false)
  33704. * @param options defines further options to be sent to the getContext() function
  33705. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33706. */
  33707. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33708. /**
  33709. * Gets current aspect ratio
  33710. * @param viewportOwner defines the camera to use to get the aspect ratio
  33711. * @param useScreen defines if screen size must be used (or the current render target if any)
  33712. * @returns a number defining the aspect ratio
  33713. */
  33714. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33715. /**
  33716. * Gets current screen aspect ratio
  33717. * @returns a number defining the aspect ratio
  33718. */
  33719. getScreenAspectRatio(): number;
  33720. /**
  33721. * Gets the client rect of the HTML canvas attached with the current webGL context
  33722. * @returns a client rectanglee
  33723. */
  33724. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33725. /**
  33726. * Gets the client rect of the HTML element used for events
  33727. * @returns a client rectanglee
  33728. */
  33729. getInputElementClientRect(): Nullable<ClientRect>;
  33730. /**
  33731. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33733. * @returns true if engine is in deterministic lock step mode
  33734. */
  33735. isDeterministicLockStep(): boolean;
  33736. /**
  33737. * Gets the max steps when engine is running in deterministic lock step
  33738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33739. * @returns the max steps
  33740. */
  33741. getLockstepMaxSteps(): number;
  33742. /**
  33743. * Returns the time in ms between steps when using deterministic lock step.
  33744. * @returns time step in (ms)
  33745. */
  33746. getTimeStep(): number;
  33747. /**
  33748. * Force the mipmap generation for the given render target texture
  33749. * @param texture defines the render target texture to use
  33750. */
  33751. generateMipMapsForCubemap(texture: InternalTexture): void;
  33752. /** States */
  33753. /**
  33754. * Set various states to the webGL context
  33755. * @param culling defines backface culling state
  33756. * @param zOffset defines the value to apply to zOffset (0 by default)
  33757. * @param force defines if states must be applied even if cache is up to date
  33758. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33759. */
  33760. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33761. /**
  33762. * Set the z offset to apply to current rendering
  33763. * @param value defines the offset to apply
  33764. */
  33765. setZOffset(value: number): void;
  33766. /**
  33767. * Gets the current value of the zOffset
  33768. * @returns the current zOffset state
  33769. */
  33770. getZOffset(): number;
  33771. /**
  33772. * Enable or disable depth buffering
  33773. * @param enable defines the state to set
  33774. */
  33775. setDepthBuffer(enable: boolean): void;
  33776. /**
  33777. * Gets a boolean indicating if depth writing is enabled
  33778. * @returns the current depth writing state
  33779. */
  33780. getDepthWrite(): boolean;
  33781. /**
  33782. * Enable or disable depth writing
  33783. * @param enable defines the state to set
  33784. */
  33785. setDepthWrite(enable: boolean): void;
  33786. /**
  33787. * Enable or disable color writing
  33788. * @param enable defines the state to set
  33789. */
  33790. setColorWrite(enable: boolean): void;
  33791. /**
  33792. * Gets a boolean indicating if color writing is enabled
  33793. * @returns the current color writing state
  33794. */
  33795. getColorWrite(): boolean;
  33796. /**
  33797. * Sets alpha constants used by some alpha blending modes
  33798. * @param r defines the red component
  33799. * @param g defines the green component
  33800. * @param b defines the blue component
  33801. * @param a defines the alpha component
  33802. */
  33803. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33804. /**
  33805. * Sets the current alpha mode
  33806. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33807. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33808. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33809. */
  33810. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33811. /**
  33812. * Gets the current alpha mode
  33813. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33814. * @returns the current alpha mode
  33815. */
  33816. getAlphaMode(): number;
  33817. /**
  33818. * Sets the current alpha equation
  33819. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33820. */
  33821. setAlphaEquation(equation: number): void;
  33822. /**
  33823. * Gets the current alpha equation.
  33824. * @returns the current alpha equation
  33825. */
  33826. getAlphaEquation(): number;
  33827. /**
  33828. * Gets a boolean indicating if stencil buffer is enabled
  33829. * @returns the current stencil buffer state
  33830. */
  33831. getStencilBuffer(): boolean;
  33832. /**
  33833. * Enable or disable the stencil buffer
  33834. * @param enable defines if the stencil buffer must be enabled or disabled
  33835. */
  33836. setStencilBuffer(enable: boolean): void;
  33837. /**
  33838. * Gets the current stencil mask
  33839. * @returns a number defining the new stencil mask to use
  33840. */
  33841. getStencilMask(): number;
  33842. /**
  33843. * Sets the current stencil mask
  33844. * @param mask defines the new stencil mask to use
  33845. */
  33846. setStencilMask(mask: number): void;
  33847. /**
  33848. * Gets the current stencil function
  33849. * @returns a number defining the stencil function to use
  33850. */
  33851. getStencilFunction(): number;
  33852. /**
  33853. * Gets the current stencil reference value
  33854. * @returns a number defining the stencil reference value to use
  33855. */
  33856. getStencilFunctionReference(): number;
  33857. /**
  33858. * Gets the current stencil mask
  33859. * @returns a number defining the stencil mask to use
  33860. */
  33861. getStencilFunctionMask(): number;
  33862. /**
  33863. * Sets the current stencil function
  33864. * @param stencilFunc defines the new stencil function to use
  33865. */
  33866. setStencilFunction(stencilFunc: number): void;
  33867. /**
  33868. * Sets the current stencil reference
  33869. * @param reference defines the new stencil reference to use
  33870. */
  33871. setStencilFunctionReference(reference: number): void;
  33872. /**
  33873. * Sets the current stencil mask
  33874. * @param mask defines the new stencil mask to use
  33875. */
  33876. setStencilFunctionMask(mask: number): void;
  33877. /**
  33878. * Gets the current stencil operation when stencil fails
  33879. * @returns a number defining stencil operation to use when stencil fails
  33880. */
  33881. getStencilOperationFail(): number;
  33882. /**
  33883. * Gets the current stencil operation when depth fails
  33884. * @returns a number defining stencil operation to use when depth fails
  33885. */
  33886. getStencilOperationDepthFail(): number;
  33887. /**
  33888. * Gets the current stencil operation when stencil passes
  33889. * @returns a number defining stencil operation to use when stencil passes
  33890. */
  33891. getStencilOperationPass(): number;
  33892. /**
  33893. * Sets the stencil operation to use when stencil fails
  33894. * @param operation defines the stencil operation to use when stencil fails
  33895. */
  33896. setStencilOperationFail(operation: number): void;
  33897. /**
  33898. * Sets the stencil operation to use when depth fails
  33899. * @param operation defines the stencil operation to use when depth fails
  33900. */
  33901. setStencilOperationDepthFail(operation: number): void;
  33902. /**
  33903. * Sets the stencil operation to use when stencil passes
  33904. * @param operation defines the stencil operation to use when stencil passes
  33905. */
  33906. setStencilOperationPass(operation: number): void;
  33907. /**
  33908. * Sets a boolean indicating if the dithering state is enabled or disabled
  33909. * @param value defines the dithering state
  33910. */
  33911. setDitheringState(value: boolean): void;
  33912. /**
  33913. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33914. * @param value defines the rasterizer state
  33915. */
  33916. setRasterizerState(value: boolean): void;
  33917. /**
  33918. * Gets the current depth function
  33919. * @returns a number defining the depth function
  33920. */
  33921. getDepthFunction(): Nullable<number>;
  33922. /**
  33923. * Sets the current depth function
  33924. * @param depthFunc defines the function to use
  33925. */
  33926. setDepthFunction(depthFunc: number): void;
  33927. /**
  33928. * Sets the current depth function to GREATER
  33929. */
  33930. setDepthFunctionToGreater(): void;
  33931. /**
  33932. * Sets the current depth function to GEQUAL
  33933. */
  33934. setDepthFunctionToGreaterOrEqual(): void;
  33935. /**
  33936. * Sets the current depth function to LESS
  33937. */
  33938. setDepthFunctionToLess(): void;
  33939. /**
  33940. * Sets the current depth function to LEQUAL
  33941. */
  33942. setDepthFunctionToLessOrEqual(): void;
  33943. private _cachedStencilBuffer;
  33944. private _cachedStencilFunction;
  33945. private _cachedStencilMask;
  33946. private _cachedStencilOperationPass;
  33947. private _cachedStencilOperationFail;
  33948. private _cachedStencilOperationDepthFail;
  33949. private _cachedStencilReference;
  33950. /**
  33951. * Caches the the state of the stencil buffer
  33952. */
  33953. cacheStencilState(): void;
  33954. /**
  33955. * Restores the state of the stencil buffer
  33956. */
  33957. restoreStencilState(): void;
  33958. /**
  33959. * Directly set the WebGL Viewport
  33960. * @param x defines the x coordinate of the viewport (in screen space)
  33961. * @param y defines the y coordinate of the viewport (in screen space)
  33962. * @param width defines the width of the viewport (in screen space)
  33963. * @param height defines the height of the viewport (in screen space)
  33964. * @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
  33965. */
  33966. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33967. /**
  33968. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33969. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33970. * @param y defines the y-coordinate of the corner of the clear rectangle
  33971. * @param width defines the width of the clear rectangle
  33972. * @param height defines the height of the clear rectangle
  33973. * @param clearColor defines the clear color
  33974. */
  33975. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33976. /**
  33977. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33978. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33979. * @param y defines the y-coordinate of the corner of the clear rectangle
  33980. * @param width defines the width of the clear rectangle
  33981. * @param height defines the height of the clear rectangle
  33982. */
  33983. enableScissor(x: number, y: number, width: number, height: number): void;
  33984. /**
  33985. * Disable previously set scissor test rectangle
  33986. */
  33987. disableScissor(): void;
  33988. protected _reportDrawCall(): void;
  33989. /**
  33990. * Initializes a webVR display and starts listening to display change events
  33991. * The onVRDisplayChangedObservable will be notified upon these changes
  33992. * @returns The onVRDisplayChangedObservable
  33993. */
  33994. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33995. /** @hidden */
  33996. _prepareVRComponent(): void;
  33997. /** @hidden */
  33998. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33999. /** @hidden */
  34000. _submitVRFrame(): void;
  34001. /**
  34002. * Call this function to leave webVR mode
  34003. * Will do nothing if webVR is not supported or if there is no webVR device
  34004. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34005. */
  34006. disableVR(): void;
  34007. /**
  34008. * Gets a boolean indicating that the system is in VR mode and is presenting
  34009. * @returns true if VR mode is engaged
  34010. */
  34011. isVRPresenting(): boolean;
  34012. /** @hidden */
  34013. _requestVRFrame(): void;
  34014. /** @hidden */
  34015. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34016. /**
  34017. * Gets the source code of the vertex shader associated with a specific webGL program
  34018. * @param program defines the program to use
  34019. * @returns a string containing the source code of the vertex shader associated with the program
  34020. */
  34021. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34022. /**
  34023. * Gets the source code of the fragment shader associated with a specific webGL program
  34024. * @param program defines the program to use
  34025. * @returns a string containing the source code of the fragment shader associated with the program
  34026. */
  34027. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34028. /**
  34029. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34030. * @param x defines the x coordinate of the rectangle where pixels must be read
  34031. * @param y defines the y coordinate of the rectangle where pixels must be read
  34032. * @param width defines the width of the rectangle where pixels must be read
  34033. * @param height defines the height of the rectangle where pixels must be read
  34034. * @returns a Uint8Array containing RGBA colors
  34035. */
  34036. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34037. /**
  34038. * Sets a depth stencil texture from a render target to the according uniform.
  34039. * @param channel The texture channel
  34040. * @param uniform The uniform to set
  34041. * @param texture The render target texture containing the depth stencil texture to apply
  34042. */
  34043. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34044. /**
  34045. * Sets a texture to the webGL context from a postprocess
  34046. * @param channel defines the channel to use
  34047. * @param postProcess defines the source postprocess
  34048. */
  34049. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34050. /**
  34051. * Binds the output of the passed in post process to the texture channel specified
  34052. * @param channel The channel the texture should be bound to
  34053. * @param postProcess The post process which's output should be bound
  34054. */
  34055. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34056. /** @hidden */
  34057. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34058. protected _rebuildBuffers(): void;
  34059. /** @hidden */
  34060. _renderFrame(): void;
  34061. _renderLoop(): void;
  34062. /** @hidden */
  34063. _renderViews(): boolean;
  34064. /**
  34065. * Toggle full screen mode
  34066. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34067. */
  34068. switchFullscreen(requestPointerLock: boolean): void;
  34069. /**
  34070. * Enters full screen mode
  34071. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34072. */
  34073. enterFullscreen(requestPointerLock: boolean): void;
  34074. /**
  34075. * Exits full screen mode
  34076. */
  34077. exitFullscreen(): void;
  34078. /**
  34079. * Enters Pointerlock mode
  34080. */
  34081. enterPointerlock(): void;
  34082. /**
  34083. * Exits Pointerlock mode
  34084. */
  34085. exitPointerlock(): void;
  34086. /**
  34087. * Begin a new frame
  34088. */
  34089. beginFrame(): void;
  34090. /**
  34091. * Enf the current frame
  34092. */
  34093. endFrame(): void;
  34094. resize(): void;
  34095. /**
  34096. * Set the compressed texture format to use, based on the formats you have, and the formats
  34097. * supported by the hardware / browser.
  34098. *
  34099. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34100. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34101. * to API arguments needed to compressed textures. This puts the burden on the container
  34102. * generator to house the arcane code for determining these for current & future formats.
  34103. *
  34104. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34105. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34106. *
  34107. * Note: The result of this call is not taken into account when a texture is base64.
  34108. *
  34109. * @param formatsAvailable defines the list of those format families you have created
  34110. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34111. *
  34112. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34113. * @returns The extension selected.
  34114. */
  34115. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34116. /**
  34117. * Force a specific size of the canvas
  34118. * @param width defines the new canvas' width
  34119. * @param height defines the new canvas' height
  34120. */
  34121. setSize(width: number, height: number): void;
  34122. /**
  34123. * Updates a dynamic vertex buffer.
  34124. * @param vertexBuffer the vertex buffer to update
  34125. * @param data the data used to update the vertex buffer
  34126. * @param byteOffset the byte offset of the data
  34127. * @param byteLength the byte length of the data
  34128. */
  34129. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34130. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34131. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34132. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34133. _releaseTexture(texture: InternalTexture): void;
  34134. /**
  34135. * @hidden
  34136. * Rescales a texture
  34137. * @param source input texutre
  34138. * @param destination destination texture
  34139. * @param scene scene to use to render the resize
  34140. * @param internalFormat format to use when resizing
  34141. * @param onComplete callback to be called when resize has completed
  34142. */
  34143. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34144. /**
  34145. * Gets the current framerate
  34146. * @returns a number representing the framerate
  34147. */
  34148. getFps(): number;
  34149. /**
  34150. * Gets the time spent between current and previous frame
  34151. * @returns a number representing the delta time in ms
  34152. */
  34153. getDeltaTime(): number;
  34154. private _measureFps;
  34155. /** @hidden */
  34156. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34157. /**
  34158. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34159. * @param renderTarget The render target to set the frame buffer for
  34160. */
  34161. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34162. /**
  34163. * Update a dynamic index buffer
  34164. * @param indexBuffer defines the target index buffer
  34165. * @param indices defines the data to update
  34166. * @param offset defines the offset in the target index buffer where update should start
  34167. */
  34168. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34169. /**
  34170. * Updates the sample count of a render target texture
  34171. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34172. * @param texture defines the texture to update
  34173. * @param samples defines the sample count to set
  34174. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34175. */
  34176. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34177. /**
  34178. * Updates a depth texture Comparison Mode and Function.
  34179. * If the comparison Function is equal to 0, the mode will be set to none.
  34180. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34181. * @param texture The texture to set the comparison function for
  34182. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34183. */
  34184. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34185. /**
  34186. * Creates a webGL buffer to use with instanciation
  34187. * @param capacity defines the size of the buffer
  34188. * @returns the webGL buffer
  34189. */
  34190. createInstancesBuffer(capacity: number): DataBuffer;
  34191. /**
  34192. * Delete a webGL buffer used with instanciation
  34193. * @param buffer defines the webGL buffer to delete
  34194. */
  34195. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34196. /** @hidden */
  34197. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34198. dispose(): void;
  34199. private _disableTouchAction;
  34200. /**
  34201. * Display the loading screen
  34202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34203. */
  34204. displayLoadingUI(): void;
  34205. /**
  34206. * Hide the loading screen
  34207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34208. */
  34209. hideLoadingUI(): void;
  34210. /**
  34211. * Gets the current loading screen object
  34212. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34213. */
  34214. /**
  34215. * Sets the current loading screen object
  34216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34217. */
  34218. loadingScreen: ILoadingScreen;
  34219. /**
  34220. * Sets the current loading screen text
  34221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34222. */
  34223. loadingUIText: string;
  34224. /**
  34225. * Sets the current loading screen background color
  34226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34227. */
  34228. loadingUIBackgroundColor: string;
  34229. /** Pointerlock and fullscreen */
  34230. /**
  34231. * Ask the browser to promote the current element to pointerlock mode
  34232. * @param element defines the DOM element to promote
  34233. */
  34234. static _RequestPointerlock(element: HTMLElement): void;
  34235. /**
  34236. * Asks the browser to exit pointerlock mode
  34237. */
  34238. static _ExitPointerlock(): void;
  34239. /**
  34240. * Ask the browser to promote the current element to fullscreen rendering mode
  34241. * @param element defines the DOM element to promote
  34242. */
  34243. static _RequestFullscreen(element: HTMLElement): void;
  34244. /**
  34245. * Asks the browser to exit fullscreen mode
  34246. */
  34247. static _ExitFullscreen(): void;
  34248. }
  34249. }
  34250. declare module "babylonjs/Engines/engineStore" {
  34251. import { Nullable } from "babylonjs/types";
  34252. import { Engine } from "babylonjs/Engines/engine";
  34253. import { Scene } from "babylonjs/scene";
  34254. /**
  34255. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34256. * during the life time of the application.
  34257. */
  34258. export class EngineStore {
  34259. /** Gets the list of created engines */
  34260. static Instances: import("babylonjs/Engines/engine").Engine[];
  34261. /** @hidden */
  34262. static _LastCreatedScene: Nullable<Scene>;
  34263. /**
  34264. * Gets the latest created engine
  34265. */
  34266. static readonly LastCreatedEngine: Nullable<Engine>;
  34267. /**
  34268. * Gets the latest created scene
  34269. */
  34270. static readonly LastCreatedScene: Nullable<Scene>;
  34271. /**
  34272. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34273. * @ignorenaming
  34274. */
  34275. static UseFallbackTexture: boolean;
  34276. /**
  34277. * Texture content used if a texture cannot loaded
  34278. * @ignorenaming
  34279. */
  34280. static FallbackTexture: string;
  34281. }
  34282. }
  34283. declare module "babylonjs/Misc/promise" {
  34284. /**
  34285. * Helper class that provides a small promise polyfill
  34286. */
  34287. export class PromisePolyfill {
  34288. /**
  34289. * Static function used to check if the polyfill is required
  34290. * If this is the case then the function will inject the polyfill to window.Promise
  34291. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34292. */
  34293. static Apply(force?: boolean): void;
  34294. }
  34295. }
  34296. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34297. /**
  34298. * Interface for screenshot methods with describe argument called `size` as object with options
  34299. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34300. */
  34301. export interface IScreenshotSize {
  34302. /**
  34303. * number in pixels for canvas height
  34304. */
  34305. height?: number;
  34306. /**
  34307. * multiplier allowing render at a higher or lower resolution
  34308. * If value is defined then height and width will be ignored and taken from camera
  34309. */
  34310. precision?: number;
  34311. /**
  34312. * number in pixels for canvas width
  34313. */
  34314. width?: number;
  34315. }
  34316. }
  34317. declare module "babylonjs/Misc/tools" {
  34318. import { Nullable, float } from "babylonjs/types";
  34319. import { DomManagement } from "babylonjs/Misc/domManagement";
  34320. import { WebRequest } from "babylonjs/Misc/webRequest";
  34321. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34322. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34324. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34325. import { Camera } from "babylonjs/Cameras/camera";
  34326. import { Engine } from "babylonjs/Engines/engine";
  34327. interface IColor4Like {
  34328. r: float;
  34329. g: float;
  34330. b: float;
  34331. a: float;
  34332. }
  34333. /**
  34334. * Class containing a set of static utilities functions
  34335. */
  34336. export class Tools {
  34337. /**
  34338. * Gets or sets the base URL to use to load assets
  34339. */
  34340. static BaseUrl: string;
  34341. /**
  34342. * Enable/Disable Custom HTTP Request Headers globally.
  34343. * default = false
  34344. * @see CustomRequestHeaders
  34345. */
  34346. static UseCustomRequestHeaders: boolean;
  34347. /**
  34348. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34349. * i.e. when loading files, where the server/service expects an Authorization header
  34350. */
  34351. static CustomRequestHeaders: {
  34352. [key: string]: string;
  34353. };
  34354. /**
  34355. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34356. */
  34357. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34358. /**
  34359. * Default behaviour for cors in the application.
  34360. * It can be a string if the expected behavior is identical in the entire app.
  34361. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34362. */
  34363. static CorsBehavior: string | ((url: string | string[]) => string);
  34364. /**
  34365. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34366. * @ignorenaming
  34367. */
  34368. static UseFallbackTexture: boolean;
  34369. /**
  34370. * Use this object to register external classes like custom textures or material
  34371. * to allow the laoders to instantiate them
  34372. */
  34373. static RegisteredExternalClasses: {
  34374. [key: string]: Object;
  34375. };
  34376. /**
  34377. * Texture content used if a texture cannot loaded
  34378. * @ignorenaming
  34379. */
  34380. static fallbackTexture: string;
  34381. /**
  34382. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34383. * @param u defines the coordinate on X axis
  34384. * @param v defines the coordinate on Y axis
  34385. * @param width defines the width of the source data
  34386. * @param height defines the height of the source data
  34387. * @param pixels defines the source byte array
  34388. * @param color defines the output color
  34389. */
  34390. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34391. /**
  34392. * Interpolates between a and b via alpha
  34393. * @param a The lower value (returned when alpha = 0)
  34394. * @param b The upper value (returned when alpha = 1)
  34395. * @param alpha The interpolation-factor
  34396. * @return The mixed value
  34397. */
  34398. static Mix(a: number, b: number, alpha: number): number;
  34399. /**
  34400. * Tries to instantiate a new object from a given class name
  34401. * @param className defines the class name to instantiate
  34402. * @returns the new object or null if the system was not able to do the instantiation
  34403. */
  34404. static Instantiate(className: string): any;
  34405. /**
  34406. * Provides a slice function that will work even on IE
  34407. * @param data defines the array to slice
  34408. * @param start defines the start of the data (optional)
  34409. * @param end defines the end of the data (optional)
  34410. * @returns the new sliced array
  34411. */
  34412. static Slice<T>(data: T, start?: number, end?: number): T;
  34413. /**
  34414. * Polyfill for setImmediate
  34415. * @param action defines the action to execute after the current execution block
  34416. */
  34417. static SetImmediate(action: () => void): void;
  34418. /**
  34419. * Function indicating if a number is an exponent of 2
  34420. * @param value defines the value to test
  34421. * @returns true if the value is an exponent of 2
  34422. */
  34423. static IsExponentOfTwo(value: number): boolean;
  34424. private static _tmpFloatArray;
  34425. /**
  34426. * Returns the nearest 32-bit single precision float representation of a Number
  34427. * @param value A Number. If the parameter is of a different type, it will get converted
  34428. * to a number or to NaN if it cannot be converted
  34429. * @returns number
  34430. */
  34431. static FloatRound(value: number): number;
  34432. /**
  34433. * Extracts the filename from a path
  34434. * @param path defines the path to use
  34435. * @returns the filename
  34436. */
  34437. static GetFilename(path: string): string;
  34438. /**
  34439. * Extracts the "folder" part of a path (everything before the filename).
  34440. * @param uri The URI to extract the info from
  34441. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34442. * @returns The "folder" part of the path
  34443. */
  34444. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34445. /**
  34446. * Extracts text content from a DOM element hierarchy
  34447. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34448. */
  34449. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34450. /**
  34451. * Convert an angle in radians to degrees
  34452. * @param angle defines the angle to convert
  34453. * @returns the angle in degrees
  34454. */
  34455. static ToDegrees(angle: number): number;
  34456. /**
  34457. * Convert an angle in degrees to radians
  34458. * @param angle defines the angle to convert
  34459. * @returns the angle in radians
  34460. */
  34461. static ToRadians(angle: number): number;
  34462. /**
  34463. * Returns an array if obj is not an array
  34464. * @param obj defines the object to evaluate as an array
  34465. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34466. * @returns either obj directly if obj is an array or a new array containing obj
  34467. */
  34468. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34469. /**
  34470. * Gets the pointer prefix to use
  34471. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34472. */
  34473. static GetPointerPrefix(): string;
  34474. /**
  34475. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34476. * @param url define the url we are trying
  34477. * @param element define the dom element where to configure the cors policy
  34478. */
  34479. static SetCorsBehavior(url: string | string[], element: {
  34480. crossOrigin: string | null;
  34481. }): void;
  34482. /**
  34483. * Removes unwanted characters from an url
  34484. * @param url defines the url to clean
  34485. * @returns the cleaned url
  34486. */
  34487. static CleanUrl(url: string): string;
  34488. /**
  34489. * Gets or sets a function used to pre-process url before using them to load assets
  34490. */
  34491. static PreprocessUrl: (url: string) => string;
  34492. /**
  34493. * Loads an image as an HTMLImageElement.
  34494. * @param input url string, ArrayBuffer, or Blob to load
  34495. * @param onLoad callback called when the image successfully loads
  34496. * @param onError callback called when the image fails to load
  34497. * @param offlineProvider offline provider for caching
  34498. * @param mimeType optional mime type
  34499. * @returns the HTMLImageElement of the loaded image
  34500. */
  34501. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34502. /**
  34503. * Loads a file from a url
  34504. * @param url url string, ArrayBuffer, or Blob to load
  34505. * @param onSuccess callback called when the file successfully loads
  34506. * @param onProgress callback called while file is loading (if the server supports this mode)
  34507. * @param offlineProvider defines the offline provider for caching
  34508. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34509. * @param onError callback called when the file fails to load
  34510. * @returns a file request object
  34511. */
  34512. 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;
  34513. /**
  34514. * Loads a file from a url
  34515. * @param url the file url to load
  34516. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34517. */
  34518. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34519. /**
  34520. * Load a script (identified by an url). When the url returns, the
  34521. * content of this file is added into a new script element, attached to the DOM (body element)
  34522. * @param scriptUrl defines the url of the script to laod
  34523. * @param onSuccess defines the callback called when the script is loaded
  34524. * @param onError defines the callback to call if an error occurs
  34525. * @param scriptId defines the id of the script element
  34526. */
  34527. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34528. /**
  34529. * Load an asynchronous script (identified by an url). When the url returns, the
  34530. * content of this file is added into a new script element, attached to the DOM (body element)
  34531. * @param scriptUrl defines the url of the script to laod
  34532. * @param scriptId defines the id of the script element
  34533. * @returns a promise request object
  34534. */
  34535. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34536. /**
  34537. * Loads a file from a blob
  34538. * @param fileToLoad defines the blob to use
  34539. * @param callback defines the callback to call when data is loaded
  34540. * @param progressCallback defines the callback to call during loading process
  34541. * @returns a file request object
  34542. */
  34543. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34544. /**
  34545. * Reads a file from a File object
  34546. * @param file defines the file to load
  34547. * @param onSuccess defines the callback to call when data is loaded
  34548. * @param onProgress defines the callback to call during loading process
  34549. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34550. * @param onError defines the callback to call when an error occurs
  34551. * @returns a file request object
  34552. */
  34553. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34554. /**
  34555. * Creates a data url from a given string content
  34556. * @param content defines the content to convert
  34557. * @returns the new data url link
  34558. */
  34559. static FileAsURL(content: string): string;
  34560. /**
  34561. * Format the given number to a specific decimal format
  34562. * @param value defines the number to format
  34563. * @param decimals defines the number of decimals to use
  34564. * @returns the formatted string
  34565. */
  34566. static Format(value: number, decimals?: number): string;
  34567. /**
  34568. * Tries to copy an object by duplicating every property
  34569. * @param source defines the source object
  34570. * @param destination defines the target object
  34571. * @param doNotCopyList defines a list of properties to avoid
  34572. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34573. */
  34574. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34575. /**
  34576. * Gets a boolean indicating if the given object has no own property
  34577. * @param obj defines the object to test
  34578. * @returns true if object has no own property
  34579. */
  34580. static IsEmpty(obj: any): boolean;
  34581. /**
  34582. * Function used to register events at window level
  34583. * @param windowElement defines the Window object to use
  34584. * @param events defines the events to register
  34585. */
  34586. static RegisterTopRootEvents(windowElement: Window, events: {
  34587. name: string;
  34588. handler: Nullable<(e: FocusEvent) => any>;
  34589. }[]): void;
  34590. /**
  34591. * Function used to unregister events from window level
  34592. * @param windowElement defines the Window object to use
  34593. * @param events defines the events to unregister
  34594. */
  34595. static UnregisterTopRootEvents(windowElement: Window, events: {
  34596. name: string;
  34597. handler: Nullable<(e: FocusEvent) => any>;
  34598. }[]): void;
  34599. /**
  34600. * @ignore
  34601. */
  34602. static _ScreenshotCanvas: HTMLCanvasElement;
  34603. /**
  34604. * Dumps the current bound framebuffer
  34605. * @param width defines the rendering width
  34606. * @param height defines the rendering height
  34607. * @param engine defines the hosting engine
  34608. * @param successCallback defines the callback triggered once the data are available
  34609. * @param mimeType defines the mime type of the result
  34610. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34611. */
  34612. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34613. /**
  34614. * Converts the canvas data to blob.
  34615. * This acts as a polyfill for browsers not supporting the to blob function.
  34616. * @param canvas Defines the canvas to extract the data from
  34617. * @param successCallback Defines the callback triggered once the data are available
  34618. * @param mimeType Defines the mime type of the result
  34619. */
  34620. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34621. /**
  34622. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34623. * @param successCallback defines the callback triggered once the data are available
  34624. * @param mimeType defines the mime type of the result
  34625. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34626. */
  34627. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34628. /**
  34629. * Downloads a blob in the browser
  34630. * @param blob defines the blob to download
  34631. * @param fileName defines the name of the downloaded file
  34632. */
  34633. static Download(blob: Blob, fileName: string): void;
  34634. /**
  34635. * Captures a screenshot of the current rendering
  34636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34637. * @param engine defines the rendering engine
  34638. * @param camera defines the source camera
  34639. * @param size This parameter can be set to a single number or to an object with the
  34640. * following (optional) properties: precision, width, height. If a single number is passed,
  34641. * it will be used for both width and height. If an object is passed, the screenshot size
  34642. * will be derived from the parameters. The precision property is a multiplier allowing
  34643. * rendering at a higher or lower resolution
  34644. * @param successCallback defines the callback receives a single parameter which contains the
  34645. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34646. * src parameter of an <img> to display it
  34647. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34648. * Check your browser for supported MIME types
  34649. */
  34650. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34651. /**
  34652. * Captures a screenshot of the current rendering
  34653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34654. * @param engine defines the rendering engine
  34655. * @param camera defines the source camera
  34656. * @param size This parameter can be set to a single number or to an object with the
  34657. * following (optional) properties: precision, width, height. If a single number is passed,
  34658. * it will be used for both width and height. If an object is passed, the screenshot size
  34659. * will be derived from the parameters. The precision property is a multiplier allowing
  34660. * rendering at a higher or lower resolution
  34661. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34662. * Check your browser for supported MIME types
  34663. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34664. * to the src parameter of an <img> to display it
  34665. */
  34666. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34667. /**
  34668. * Generates an image screenshot from the specified camera.
  34669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34670. * @param engine The engine to use for rendering
  34671. * @param camera The camera to use for rendering
  34672. * @param size This parameter can be set to a single number or to an object with the
  34673. * following (optional) properties: precision, width, height. If a single number is passed,
  34674. * it will be used for both width and height. If an object is passed, the screenshot size
  34675. * will be derived from the parameters. The precision property is a multiplier allowing
  34676. * rendering at a higher or lower resolution
  34677. * @param successCallback The callback receives a single parameter which contains the
  34678. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34679. * src parameter of an <img> to display it
  34680. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34681. * Check your browser for supported MIME types
  34682. * @param samples Texture samples (default: 1)
  34683. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34684. * @param fileName A name for for the downloaded file.
  34685. */
  34686. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34687. /**
  34688. * Generates an image screenshot from the specified camera.
  34689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34690. * @param engine The engine to use for rendering
  34691. * @param camera The camera to use for rendering
  34692. * @param size This parameter can be set to a single number or to an object with the
  34693. * following (optional) properties: precision, width, height. If a single number is passed,
  34694. * it will be used for both width and height. If an object is passed, the screenshot size
  34695. * will be derived from the parameters. The precision property is a multiplier allowing
  34696. * rendering at a higher or lower resolution
  34697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34698. * Check your browser for supported MIME types
  34699. * @param samples Texture samples (default: 1)
  34700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34701. * @param fileName A name for for the downloaded file.
  34702. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34703. * to the src parameter of an <img> to display it
  34704. */
  34705. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34706. /**
  34707. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34708. * Be aware Math.random() could cause collisions, but:
  34709. * "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"
  34710. * @returns a pseudo random id
  34711. */
  34712. static RandomId(): string;
  34713. /**
  34714. * Test if the given uri is a base64 string
  34715. * @param uri The uri to test
  34716. * @return True if the uri is a base64 string or false otherwise
  34717. */
  34718. static IsBase64(uri: string): boolean;
  34719. /**
  34720. * Decode the given base64 uri.
  34721. * @param uri The uri to decode
  34722. * @return The decoded base64 data.
  34723. */
  34724. static DecodeBase64(uri: string): ArrayBuffer;
  34725. /**
  34726. * Gets the absolute url.
  34727. * @param url the input url
  34728. * @return the absolute url
  34729. */
  34730. static GetAbsoluteUrl(url: string): string;
  34731. /**
  34732. * No log
  34733. */
  34734. static readonly NoneLogLevel: number;
  34735. /**
  34736. * Only message logs
  34737. */
  34738. static readonly MessageLogLevel: number;
  34739. /**
  34740. * Only warning logs
  34741. */
  34742. static readonly WarningLogLevel: number;
  34743. /**
  34744. * Only error logs
  34745. */
  34746. static readonly ErrorLogLevel: number;
  34747. /**
  34748. * All logs
  34749. */
  34750. static readonly AllLogLevel: number;
  34751. /**
  34752. * Gets a value indicating the number of loading errors
  34753. * @ignorenaming
  34754. */
  34755. static readonly errorsCount: number;
  34756. /**
  34757. * Callback called when a new log is added
  34758. */
  34759. static OnNewCacheEntry: (entry: string) => void;
  34760. /**
  34761. * Log a message to the console
  34762. * @param message defines the message to log
  34763. */
  34764. static Log(message: string): void;
  34765. /**
  34766. * Write a warning message to the console
  34767. * @param message defines the message to log
  34768. */
  34769. static Warn(message: string): void;
  34770. /**
  34771. * Write an error message to the console
  34772. * @param message defines the message to log
  34773. */
  34774. static Error(message: string): void;
  34775. /**
  34776. * Gets current log cache (list of logs)
  34777. */
  34778. static readonly LogCache: string;
  34779. /**
  34780. * Clears the log cache
  34781. */
  34782. static ClearLogCache(): void;
  34783. /**
  34784. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34785. */
  34786. static LogLevels: number;
  34787. /**
  34788. * Checks if the window object exists
  34789. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34790. */
  34791. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34792. /**
  34793. * No performance log
  34794. */
  34795. static readonly PerformanceNoneLogLevel: number;
  34796. /**
  34797. * Use user marks to log performance
  34798. */
  34799. static readonly PerformanceUserMarkLogLevel: number;
  34800. /**
  34801. * Log performance to the console
  34802. */
  34803. static readonly PerformanceConsoleLogLevel: number;
  34804. private static _performance;
  34805. /**
  34806. * Sets the current performance log level
  34807. */
  34808. static PerformanceLogLevel: number;
  34809. private static _StartPerformanceCounterDisabled;
  34810. private static _EndPerformanceCounterDisabled;
  34811. private static _StartUserMark;
  34812. private static _EndUserMark;
  34813. private static _StartPerformanceConsole;
  34814. private static _EndPerformanceConsole;
  34815. /**
  34816. * Starts a performance counter
  34817. */
  34818. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34819. /**
  34820. * Ends a specific performance coutner
  34821. */
  34822. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34823. /**
  34824. * Gets either window.performance.now() if supported or Date.now() else
  34825. */
  34826. static readonly Now: number;
  34827. /**
  34828. * This method will return the name of the class used to create the instance of the given object.
  34829. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34830. * @param object the object to get the class name from
  34831. * @param isType defines if the object is actually a type
  34832. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34833. */
  34834. static GetClassName(object: any, isType?: boolean): string;
  34835. /**
  34836. * Gets the first element of an array satisfying a given predicate
  34837. * @param array defines the array to browse
  34838. * @param predicate defines the predicate to use
  34839. * @returns null if not found or the element
  34840. */
  34841. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34842. /**
  34843. * This method will return the name of the full name of the class, including its owning module (if any).
  34844. * 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).
  34845. * @param object the object to get the class name from
  34846. * @param isType defines if the object is actually a type
  34847. * @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.
  34848. * @ignorenaming
  34849. */
  34850. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34851. /**
  34852. * Returns a promise that resolves after the given amount of time.
  34853. * @param delay Number of milliseconds to delay
  34854. * @returns Promise that resolves after the given amount of time
  34855. */
  34856. static DelayAsync(delay: number): Promise<void>;
  34857. }
  34858. /**
  34859. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34860. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34861. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34862. * @param name The name of the class, case should be preserved
  34863. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34864. */
  34865. export function className(name: string, module?: string): (target: Object) => void;
  34866. /**
  34867. * An implementation of a loop for asynchronous functions.
  34868. */
  34869. export class AsyncLoop {
  34870. /**
  34871. * Defines the number of iterations for the loop
  34872. */
  34873. iterations: number;
  34874. /**
  34875. * Defines the current index of the loop.
  34876. */
  34877. index: number;
  34878. private _done;
  34879. private _fn;
  34880. private _successCallback;
  34881. /**
  34882. * Constructor.
  34883. * @param iterations the number of iterations.
  34884. * @param func the function to run each iteration
  34885. * @param successCallback the callback that will be called upon succesful execution
  34886. * @param offset starting offset.
  34887. */
  34888. constructor(
  34889. /**
  34890. * Defines the number of iterations for the loop
  34891. */
  34892. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34893. /**
  34894. * Execute the next iteration. Must be called after the last iteration was finished.
  34895. */
  34896. executeNext(): void;
  34897. /**
  34898. * Break the loop and run the success callback.
  34899. */
  34900. breakLoop(): void;
  34901. /**
  34902. * Create and run an async loop.
  34903. * @param iterations the number of iterations.
  34904. * @param fn the function to run each iteration
  34905. * @param successCallback the callback that will be called upon succesful execution
  34906. * @param offset starting offset.
  34907. * @returns the created async loop object
  34908. */
  34909. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34910. /**
  34911. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34912. * @param iterations total number of iterations
  34913. * @param syncedIterations number of synchronous iterations in each async iteration.
  34914. * @param fn the function to call each iteration.
  34915. * @param callback a success call back that will be called when iterating stops.
  34916. * @param breakFunction a break condition (optional)
  34917. * @param timeout timeout settings for the setTimeout function. default - 0.
  34918. * @returns the created async loop object
  34919. */
  34920. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34921. }
  34922. }
  34923. declare module "babylonjs/Misc/stringDictionary" {
  34924. import { Nullable } from "babylonjs/types";
  34925. /**
  34926. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34927. * The underlying implementation relies on an associative array to ensure the best performances.
  34928. * The value can be anything including 'null' but except 'undefined'
  34929. */
  34930. export class StringDictionary<T> {
  34931. /**
  34932. * This will clear this dictionary and copy the content from the 'source' one.
  34933. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34934. * @param source the dictionary to take the content from and copy to this dictionary
  34935. */
  34936. copyFrom(source: StringDictionary<T>): void;
  34937. /**
  34938. * Get a value based from its key
  34939. * @param key the given key to get the matching value from
  34940. * @return the value if found, otherwise undefined is returned
  34941. */
  34942. get(key: string): T | undefined;
  34943. /**
  34944. * Get a value from its key or add it if it doesn't exist.
  34945. * This method will ensure you that a given key/data will be present in the dictionary.
  34946. * @param key the given key to get the matching value from
  34947. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34948. * The factory will only be invoked if there's no data for the given key.
  34949. * @return the value corresponding to the key.
  34950. */
  34951. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34952. /**
  34953. * Get a value from its key if present in the dictionary otherwise add it
  34954. * @param key the key to get the value from
  34955. * @param val if there's no such key/value pair in the dictionary add it with this value
  34956. * @return the value corresponding to the key
  34957. */
  34958. getOrAdd(key: string, val: T): T;
  34959. /**
  34960. * Check if there's a given key in the dictionary
  34961. * @param key the key to check for
  34962. * @return true if the key is present, false otherwise
  34963. */
  34964. contains(key: string): boolean;
  34965. /**
  34966. * Add a new key and its corresponding value
  34967. * @param key the key to add
  34968. * @param value the value corresponding to the key
  34969. * @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
  34970. */
  34971. add(key: string, value: T): boolean;
  34972. /**
  34973. * Update a specific value associated to a key
  34974. * @param key defines the key to use
  34975. * @param value defines the value to store
  34976. * @returns true if the value was updated (or false if the key was not found)
  34977. */
  34978. set(key: string, value: T): boolean;
  34979. /**
  34980. * Get the element of the given key and remove it from the dictionary
  34981. * @param key defines the key to search
  34982. * @returns the value associated with the key or null if not found
  34983. */
  34984. getAndRemove(key: string): Nullable<T>;
  34985. /**
  34986. * Remove a key/value from the dictionary.
  34987. * @param key the key to remove
  34988. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34989. */
  34990. remove(key: string): boolean;
  34991. /**
  34992. * Clear the whole content of the dictionary
  34993. */
  34994. clear(): void;
  34995. /**
  34996. * Gets the current count
  34997. */
  34998. readonly count: number;
  34999. /**
  35000. * Execute a callback on each key/val of the dictionary.
  35001. * Note that you can remove any element in this dictionary in the callback implementation
  35002. * @param callback the callback to execute on a given key/value pair
  35003. */
  35004. forEach(callback: (key: string, val: T) => void): void;
  35005. /**
  35006. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35007. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35008. * Note that you can remove any element in this dictionary in the callback implementation
  35009. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35010. * @returns the first item
  35011. */
  35012. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35013. private _count;
  35014. private _data;
  35015. }
  35016. }
  35017. declare module "babylonjs/Collisions/collisionCoordinator" {
  35018. import { Nullable } from "babylonjs/types";
  35019. import { Scene } from "babylonjs/scene";
  35020. import { Vector3 } from "babylonjs/Maths/math.vector";
  35021. import { Collider } from "babylonjs/Collisions/collider";
  35022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35023. /** @hidden */
  35024. export interface ICollisionCoordinator {
  35025. createCollider(): Collider;
  35026. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35027. init(scene: Scene): void;
  35028. }
  35029. /** @hidden */
  35030. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35031. private _scene;
  35032. private _scaledPosition;
  35033. private _scaledVelocity;
  35034. private _finalPosition;
  35035. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35036. createCollider(): Collider;
  35037. init(scene: Scene): void;
  35038. private _collideWithWorld;
  35039. }
  35040. }
  35041. declare module "babylonjs/Inputs/scene.inputManager" {
  35042. import { Nullable } from "babylonjs/types";
  35043. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35044. import { Vector2 } from "babylonjs/Maths/math.vector";
  35045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35046. import { Scene } from "babylonjs/scene";
  35047. /**
  35048. * Class used to manage all inputs for the scene.
  35049. */
  35050. export class InputManager {
  35051. /** The distance in pixel that you have to move to prevent some events */
  35052. static DragMovementThreshold: number;
  35053. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35054. static LongPressDelay: number;
  35055. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35056. static DoubleClickDelay: number;
  35057. /** If you need to check double click without raising a single click at first click, enable this flag */
  35058. static ExclusiveDoubleClickMode: boolean;
  35059. private _wheelEventName;
  35060. private _onPointerMove;
  35061. private _onPointerDown;
  35062. private _onPointerUp;
  35063. private _initClickEvent;
  35064. private _initActionManager;
  35065. private _delayedSimpleClick;
  35066. private _delayedSimpleClickTimeout;
  35067. private _previousDelayedSimpleClickTimeout;
  35068. private _meshPickProceed;
  35069. private _previousButtonPressed;
  35070. private _currentPickResult;
  35071. private _previousPickResult;
  35072. private _totalPointersPressed;
  35073. private _doubleClickOccured;
  35074. private _pointerOverMesh;
  35075. private _pickedDownMesh;
  35076. private _pickedUpMesh;
  35077. private _pointerX;
  35078. private _pointerY;
  35079. private _unTranslatedPointerX;
  35080. private _unTranslatedPointerY;
  35081. private _startingPointerPosition;
  35082. private _previousStartingPointerPosition;
  35083. private _startingPointerTime;
  35084. private _previousStartingPointerTime;
  35085. private _pointerCaptures;
  35086. private _onKeyDown;
  35087. private _onKeyUp;
  35088. private _onCanvasFocusObserver;
  35089. private _onCanvasBlurObserver;
  35090. private _scene;
  35091. /**
  35092. * Creates a new InputManager
  35093. * @param scene defines the hosting scene
  35094. */
  35095. constructor(scene: Scene);
  35096. /**
  35097. * Gets the mesh that is currently under the pointer
  35098. */
  35099. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35100. /**
  35101. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35102. */
  35103. readonly unTranslatedPointer: Vector2;
  35104. /**
  35105. * Gets or sets the current on-screen X position of the pointer
  35106. */
  35107. pointerX: number;
  35108. /**
  35109. * Gets or sets the current on-screen Y position of the pointer
  35110. */
  35111. pointerY: number;
  35112. private _updatePointerPosition;
  35113. private _processPointerMove;
  35114. private _setRayOnPointerInfo;
  35115. private _checkPrePointerObservable;
  35116. /**
  35117. * Use this method to simulate a pointer move on a mesh
  35118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35121. */
  35122. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35123. /**
  35124. * Use this method to simulate a pointer down on a mesh
  35125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35128. */
  35129. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35130. private _processPointerDown;
  35131. /** @hidden */
  35132. _isPointerSwiping(): boolean;
  35133. /**
  35134. * Use this method to simulate a pointer up on a mesh
  35135. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35136. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35137. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35138. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35139. */
  35140. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35141. private _processPointerUp;
  35142. /**
  35143. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35144. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35145. * @returns true if the pointer was captured
  35146. */
  35147. isPointerCaptured(pointerId?: number): boolean;
  35148. /**
  35149. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35150. * @param attachUp defines if you want to attach events to pointerup
  35151. * @param attachDown defines if you want to attach events to pointerdown
  35152. * @param attachMove defines if you want to attach events to pointermove
  35153. */
  35154. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35155. /**
  35156. * Detaches all event handlers
  35157. */
  35158. detachControl(): void;
  35159. /**
  35160. * Force the value of meshUnderPointer
  35161. * @param mesh defines the mesh to use
  35162. */
  35163. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35164. /**
  35165. * Gets the mesh under the pointer
  35166. * @returns a Mesh or null if no mesh is under the pointer
  35167. */
  35168. getPointerOverMesh(): Nullable<AbstractMesh>;
  35169. }
  35170. }
  35171. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35172. /**
  35173. * Helper class used to generate session unique ID
  35174. */
  35175. export class UniqueIdGenerator {
  35176. private static _UniqueIdCounter;
  35177. /**
  35178. * Gets an unique (relatively to the current scene) Id
  35179. */
  35180. static readonly UniqueId: number;
  35181. }
  35182. }
  35183. declare module "babylonjs/Animations/animationGroup" {
  35184. import { Animatable } from "babylonjs/Animations/animatable";
  35185. import { Animation } from "babylonjs/Animations/animation";
  35186. import { Scene, IDisposable } from "babylonjs/scene";
  35187. import { Observable } from "babylonjs/Misc/observable";
  35188. import { Nullable } from "babylonjs/types";
  35189. import "babylonjs/Animations/animatable";
  35190. /**
  35191. * This class defines the direct association between an animation and a target
  35192. */
  35193. export class TargetedAnimation {
  35194. /**
  35195. * Animation to perform
  35196. */
  35197. animation: Animation;
  35198. /**
  35199. * Target to animate
  35200. */
  35201. target: any;
  35202. /**
  35203. * Serialize the object
  35204. * @returns the JSON object representing the current entity
  35205. */
  35206. serialize(): any;
  35207. }
  35208. /**
  35209. * Use this class to create coordinated animations on multiple targets
  35210. */
  35211. export class AnimationGroup implements IDisposable {
  35212. /** The name of the animation group */
  35213. name: string;
  35214. private _scene;
  35215. private _targetedAnimations;
  35216. private _animatables;
  35217. private _from;
  35218. private _to;
  35219. private _isStarted;
  35220. private _isPaused;
  35221. private _speedRatio;
  35222. private _loopAnimation;
  35223. /**
  35224. * Gets or sets the unique id of the node
  35225. */
  35226. uniqueId: number;
  35227. /**
  35228. * This observable will notify when one animation have ended
  35229. */
  35230. onAnimationEndObservable: Observable<TargetedAnimation>;
  35231. /**
  35232. * Observer raised when one animation loops
  35233. */
  35234. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35235. /**
  35236. * Observer raised when all animations have looped
  35237. */
  35238. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35239. /**
  35240. * This observable will notify when all animations have ended.
  35241. */
  35242. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35243. /**
  35244. * This observable will notify when all animations have paused.
  35245. */
  35246. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35247. /**
  35248. * This observable will notify when all animations are playing.
  35249. */
  35250. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35251. /**
  35252. * Gets the first frame
  35253. */
  35254. readonly from: number;
  35255. /**
  35256. * Gets the last frame
  35257. */
  35258. readonly to: number;
  35259. /**
  35260. * Define if the animations are started
  35261. */
  35262. readonly isStarted: boolean;
  35263. /**
  35264. * Gets a value indicating that the current group is playing
  35265. */
  35266. readonly isPlaying: boolean;
  35267. /**
  35268. * Gets or sets the speed ratio to use for all animations
  35269. */
  35270. /**
  35271. * Gets or sets the speed ratio to use for all animations
  35272. */
  35273. speedRatio: number;
  35274. /**
  35275. * Gets or sets if all animations should loop or not
  35276. */
  35277. loopAnimation: boolean;
  35278. /**
  35279. * Gets the targeted animations for this animation group
  35280. */
  35281. readonly targetedAnimations: Array<TargetedAnimation>;
  35282. /**
  35283. * returning the list of animatables controlled by this animation group.
  35284. */
  35285. readonly animatables: Array<Animatable>;
  35286. /**
  35287. * Instantiates a new Animation Group.
  35288. * This helps managing several animations at once.
  35289. * @see http://doc.babylonjs.com/how_to/group
  35290. * @param name Defines the name of the group
  35291. * @param scene Defines the scene the group belongs to
  35292. */
  35293. constructor(
  35294. /** The name of the animation group */
  35295. name: string, scene?: Nullable<Scene>);
  35296. /**
  35297. * Add an animation (with its target) in the group
  35298. * @param animation defines the animation we want to add
  35299. * @param target defines the target of the animation
  35300. * @returns the TargetedAnimation object
  35301. */
  35302. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35303. /**
  35304. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35305. * It can add constant keys at begin or end
  35306. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35307. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35308. * @returns the animation group
  35309. */
  35310. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35311. private _animationLoopCount;
  35312. private _animationLoopFlags;
  35313. private _processLoop;
  35314. /**
  35315. * Start all animations on given targets
  35316. * @param loop defines if animations must loop
  35317. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35318. * @param from defines the from key (optional)
  35319. * @param to defines the to key (optional)
  35320. * @returns the current animation group
  35321. */
  35322. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35323. /**
  35324. * Pause all animations
  35325. * @returns the animation group
  35326. */
  35327. pause(): AnimationGroup;
  35328. /**
  35329. * Play all animations to initial state
  35330. * This function will start() the animations if they were not started or will restart() them if they were paused
  35331. * @param loop defines if animations must loop
  35332. * @returns the animation group
  35333. */
  35334. play(loop?: boolean): AnimationGroup;
  35335. /**
  35336. * Reset all animations to initial state
  35337. * @returns the animation group
  35338. */
  35339. reset(): AnimationGroup;
  35340. /**
  35341. * Restart animations from key 0
  35342. * @returns the animation group
  35343. */
  35344. restart(): AnimationGroup;
  35345. /**
  35346. * Stop all animations
  35347. * @returns the animation group
  35348. */
  35349. stop(): AnimationGroup;
  35350. /**
  35351. * Set animation weight for all animatables
  35352. * @param weight defines the weight to use
  35353. * @return the animationGroup
  35354. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35355. */
  35356. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35357. /**
  35358. * Synchronize and normalize all animatables with a source animatable
  35359. * @param root defines the root animatable to synchronize with
  35360. * @return the animationGroup
  35361. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35362. */
  35363. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35364. /**
  35365. * Goes to a specific frame in this animation group
  35366. * @param frame the frame number to go to
  35367. * @return the animationGroup
  35368. */
  35369. goToFrame(frame: number): AnimationGroup;
  35370. /**
  35371. * Dispose all associated resources
  35372. */
  35373. dispose(): void;
  35374. private _checkAnimationGroupEnded;
  35375. /**
  35376. * Clone the current animation group and returns a copy
  35377. * @param newName defines the name of the new group
  35378. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35379. * @returns the new aniamtion group
  35380. */
  35381. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35382. /**
  35383. * Serializes the animationGroup to an object
  35384. * @returns Serialized object
  35385. */
  35386. serialize(): any;
  35387. /**
  35388. * Returns a new AnimationGroup object parsed from the source provided.
  35389. * @param parsedAnimationGroup defines the source
  35390. * @param scene defines the scene that will receive the animationGroup
  35391. * @returns a new AnimationGroup
  35392. */
  35393. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35394. /**
  35395. * Returns the string "AnimationGroup"
  35396. * @returns "AnimationGroup"
  35397. */
  35398. getClassName(): string;
  35399. /**
  35400. * Creates a detailled string about the object
  35401. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35402. * @returns a string representing the object
  35403. */
  35404. toString(fullDetails?: boolean): string;
  35405. }
  35406. }
  35407. declare module "babylonjs/scene" {
  35408. import { Nullable } from "babylonjs/types";
  35409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35410. import { Observable } from "babylonjs/Misc/observable";
  35411. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35412. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35413. import { Geometry } from "babylonjs/Meshes/geometry";
  35414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35417. import { Mesh } from "babylonjs/Meshes/mesh";
  35418. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35419. import { Bone } from "babylonjs/Bones/bone";
  35420. import { Skeleton } from "babylonjs/Bones/skeleton";
  35421. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35422. import { Camera } from "babylonjs/Cameras/camera";
  35423. import { AbstractScene } from "babylonjs/abstractScene";
  35424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35425. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35426. import { Material } from "babylonjs/Materials/material";
  35427. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35428. import { Effect } from "babylonjs/Materials/effect";
  35429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35430. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35431. import { Light } from "babylonjs/Lights/light";
  35432. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35433. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35434. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35435. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35437. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35438. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35439. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35440. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35441. import { Engine } from "babylonjs/Engines/engine";
  35442. import { Node } from "babylonjs/node";
  35443. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35444. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35445. import { WebRequest } from "babylonjs/Misc/webRequest";
  35446. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35447. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35449. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35450. import { Plane } from "babylonjs/Maths/math.plane";
  35451. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35452. import { Ray } from "babylonjs/Culling/ray";
  35453. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35454. import { Animation } from "babylonjs/Animations/animation";
  35455. import { Animatable } from "babylonjs/Animations/animatable";
  35456. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35457. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35458. import { Collider } from "babylonjs/Collisions/collider";
  35459. /**
  35460. * Define an interface for all classes that will hold resources
  35461. */
  35462. export interface IDisposable {
  35463. /**
  35464. * Releases all held resources
  35465. */
  35466. dispose(): void;
  35467. }
  35468. /** Interface defining initialization parameters for Scene class */
  35469. export interface SceneOptions {
  35470. /**
  35471. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35472. * It will improve performance when the number of geometries becomes important.
  35473. */
  35474. useGeometryUniqueIdsMap?: boolean;
  35475. /**
  35476. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35477. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35478. */
  35479. useMaterialMeshMap?: boolean;
  35480. /**
  35481. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35482. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35483. */
  35484. useClonedMeshhMap?: boolean;
  35485. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35486. virtual?: boolean;
  35487. }
  35488. /**
  35489. * Represents a scene to be rendered by the engine.
  35490. * @see http://doc.babylonjs.com/features/scene
  35491. */
  35492. export class Scene extends AbstractScene implements IAnimatable {
  35493. /** The fog is deactivated */
  35494. static readonly FOGMODE_NONE: number;
  35495. /** The fog density is following an exponential function */
  35496. static readonly FOGMODE_EXP: number;
  35497. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35498. static readonly FOGMODE_EXP2: number;
  35499. /** The fog density is following a linear function. */
  35500. static readonly FOGMODE_LINEAR: number;
  35501. /**
  35502. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35503. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35504. */
  35505. static MinDeltaTime: number;
  35506. /**
  35507. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35508. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35509. */
  35510. static MaxDeltaTime: number;
  35511. /**
  35512. * Factory used to create the default material.
  35513. * @param name The name of the material to create
  35514. * @param scene The scene to create the material for
  35515. * @returns The default material
  35516. */
  35517. static DefaultMaterialFactory(scene: Scene): Material;
  35518. /**
  35519. * Factory used to create the a collision coordinator.
  35520. * @returns The collision coordinator
  35521. */
  35522. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35523. /** @hidden */
  35524. _inputManager: InputManager;
  35525. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35526. cameraToUseForPointers: Nullable<Camera>;
  35527. /** @hidden */
  35528. readonly _isScene: boolean;
  35529. /**
  35530. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35531. */
  35532. autoClear: boolean;
  35533. /**
  35534. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35535. */
  35536. autoClearDepthAndStencil: boolean;
  35537. /**
  35538. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35539. */
  35540. clearColor: Color4;
  35541. /**
  35542. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35543. */
  35544. ambientColor: Color3;
  35545. /**
  35546. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35547. * It should only be one of the following (if not the default embedded one):
  35548. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35549. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35550. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35551. * The material properties need to be setup according to the type of texture in use.
  35552. */
  35553. environmentBRDFTexture: BaseTexture;
  35554. /** @hidden */
  35555. protected _environmentTexture: Nullable<BaseTexture>;
  35556. /**
  35557. * Texture used in all pbr material as the reflection texture.
  35558. * As in the majority of the scene they are the same (exception for multi room and so on),
  35559. * this is easier to reference from here than from all the materials.
  35560. */
  35561. /**
  35562. * Texture used in all pbr material as the reflection texture.
  35563. * As in the majority of the scene they are the same (exception for multi room and so on),
  35564. * this is easier to set here than in all the materials.
  35565. */
  35566. environmentTexture: Nullable<BaseTexture>;
  35567. /** @hidden */
  35568. protected _environmentIntensity: number;
  35569. /**
  35570. * Intensity of the environment in all pbr material.
  35571. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35572. * As in the majority of the scene they are the same (exception for multi room and so on),
  35573. * this is easier to reference from here than from all the materials.
  35574. */
  35575. /**
  35576. * Intensity of the environment in all pbr material.
  35577. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35578. * As in the majority of the scene they are the same (exception for multi room and so on),
  35579. * this is easier to set here than in all the materials.
  35580. */
  35581. environmentIntensity: number;
  35582. /** @hidden */
  35583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35584. /**
  35585. * Default image processing configuration used either in the rendering
  35586. * Forward main pass or through the imageProcessingPostProcess if present.
  35587. * As in the majority of the scene they are the same (exception for multi camera),
  35588. * this is easier to reference from here than from all the materials and post process.
  35589. *
  35590. * No setter as we it is a shared configuration, you can set the values instead.
  35591. */
  35592. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35593. private _forceWireframe;
  35594. /**
  35595. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35596. */
  35597. forceWireframe: boolean;
  35598. private _forcePointsCloud;
  35599. /**
  35600. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35601. */
  35602. forcePointsCloud: boolean;
  35603. /**
  35604. * Gets or sets the active clipplane 1
  35605. */
  35606. clipPlane: Nullable<Plane>;
  35607. /**
  35608. * Gets or sets the active clipplane 2
  35609. */
  35610. clipPlane2: Nullable<Plane>;
  35611. /**
  35612. * Gets or sets the active clipplane 3
  35613. */
  35614. clipPlane3: Nullable<Plane>;
  35615. /**
  35616. * Gets or sets the active clipplane 4
  35617. */
  35618. clipPlane4: Nullable<Plane>;
  35619. /**
  35620. * Gets or sets a boolean indicating if animations are enabled
  35621. */
  35622. animationsEnabled: boolean;
  35623. private _animationPropertiesOverride;
  35624. /**
  35625. * Gets or sets the animation properties override
  35626. */
  35627. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35628. /**
  35629. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35630. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35631. */
  35632. useConstantAnimationDeltaTime: boolean;
  35633. /**
  35634. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35635. * Please note that it requires to run a ray cast through the scene on every frame
  35636. */
  35637. constantlyUpdateMeshUnderPointer: boolean;
  35638. /**
  35639. * Defines the HTML cursor to use when hovering over interactive elements
  35640. */
  35641. hoverCursor: string;
  35642. /**
  35643. * Defines the HTML default cursor to use (empty by default)
  35644. */
  35645. defaultCursor: string;
  35646. /**
  35647. * Defines wether cursors are handled by the scene.
  35648. */
  35649. doNotHandleCursors: boolean;
  35650. /**
  35651. * This is used to call preventDefault() on pointer down
  35652. * in order to block unwanted artifacts like system double clicks
  35653. */
  35654. preventDefaultOnPointerDown: boolean;
  35655. /**
  35656. * This is used to call preventDefault() on pointer up
  35657. * in order to block unwanted artifacts like system double clicks
  35658. */
  35659. preventDefaultOnPointerUp: boolean;
  35660. /**
  35661. * Gets or sets user defined metadata
  35662. */
  35663. metadata: any;
  35664. /**
  35665. * For internal use only. Please do not use.
  35666. */
  35667. reservedDataStore: any;
  35668. /**
  35669. * Gets the name of the plugin used to load this scene (null by default)
  35670. */
  35671. loadingPluginName: string;
  35672. /**
  35673. * Use this array to add regular expressions used to disable offline support for specific urls
  35674. */
  35675. disableOfflineSupportExceptionRules: RegExp[];
  35676. /**
  35677. * An event triggered when the scene is disposed.
  35678. */
  35679. onDisposeObservable: Observable<Scene>;
  35680. private _onDisposeObserver;
  35681. /** Sets a function to be executed when this scene is disposed. */
  35682. onDispose: () => void;
  35683. /**
  35684. * An event triggered before rendering the scene (right after animations and physics)
  35685. */
  35686. onBeforeRenderObservable: Observable<Scene>;
  35687. private _onBeforeRenderObserver;
  35688. /** Sets a function to be executed before rendering this scene */
  35689. beforeRender: Nullable<() => void>;
  35690. /**
  35691. * An event triggered after rendering the scene
  35692. */
  35693. onAfterRenderObservable: Observable<Scene>;
  35694. /**
  35695. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35696. */
  35697. onAfterRenderCameraObservable: Observable<Camera>;
  35698. private _onAfterRenderObserver;
  35699. /** Sets a function to be executed after rendering this scene */
  35700. afterRender: Nullable<() => void>;
  35701. /**
  35702. * An event triggered before animating the scene
  35703. */
  35704. onBeforeAnimationsObservable: Observable<Scene>;
  35705. /**
  35706. * An event triggered after animations processing
  35707. */
  35708. onAfterAnimationsObservable: Observable<Scene>;
  35709. /**
  35710. * An event triggered before draw calls are ready to be sent
  35711. */
  35712. onBeforeDrawPhaseObservable: Observable<Scene>;
  35713. /**
  35714. * An event triggered after draw calls have been sent
  35715. */
  35716. onAfterDrawPhaseObservable: Observable<Scene>;
  35717. /**
  35718. * An event triggered when the scene is ready
  35719. */
  35720. onReadyObservable: Observable<Scene>;
  35721. /**
  35722. * An event triggered before rendering a camera
  35723. */
  35724. onBeforeCameraRenderObservable: Observable<Camera>;
  35725. private _onBeforeCameraRenderObserver;
  35726. /** Sets a function to be executed before rendering a camera*/
  35727. beforeCameraRender: () => void;
  35728. /**
  35729. * An event triggered after rendering a camera
  35730. */
  35731. onAfterCameraRenderObservable: Observable<Camera>;
  35732. private _onAfterCameraRenderObserver;
  35733. /** Sets a function to be executed after rendering a camera*/
  35734. afterCameraRender: () => void;
  35735. /**
  35736. * An event triggered when active meshes evaluation is about to start
  35737. */
  35738. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35739. /**
  35740. * An event triggered when active meshes evaluation is done
  35741. */
  35742. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35743. /**
  35744. * An event triggered when particles rendering is about to start
  35745. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35746. */
  35747. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35748. /**
  35749. * An event triggered when particles rendering is done
  35750. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35751. */
  35752. onAfterParticlesRenderingObservable: Observable<Scene>;
  35753. /**
  35754. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35755. */
  35756. onDataLoadedObservable: Observable<Scene>;
  35757. /**
  35758. * An event triggered when a camera is created
  35759. */
  35760. onNewCameraAddedObservable: Observable<Camera>;
  35761. /**
  35762. * An event triggered when a camera is removed
  35763. */
  35764. onCameraRemovedObservable: Observable<Camera>;
  35765. /**
  35766. * An event triggered when a light is created
  35767. */
  35768. onNewLightAddedObservable: Observable<Light>;
  35769. /**
  35770. * An event triggered when a light is removed
  35771. */
  35772. onLightRemovedObservable: Observable<Light>;
  35773. /**
  35774. * An event triggered when a geometry is created
  35775. */
  35776. onNewGeometryAddedObservable: Observable<Geometry>;
  35777. /**
  35778. * An event triggered when a geometry is removed
  35779. */
  35780. onGeometryRemovedObservable: Observable<Geometry>;
  35781. /**
  35782. * An event triggered when a transform node is created
  35783. */
  35784. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35785. /**
  35786. * An event triggered when a transform node is removed
  35787. */
  35788. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35789. /**
  35790. * An event triggered when a mesh is created
  35791. */
  35792. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35793. /**
  35794. * An event triggered when a mesh is removed
  35795. */
  35796. onMeshRemovedObservable: Observable<AbstractMesh>;
  35797. /**
  35798. * An event triggered when a skeleton is created
  35799. */
  35800. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35801. /**
  35802. * An event triggered when a skeleton is removed
  35803. */
  35804. onSkeletonRemovedObservable: Observable<Skeleton>;
  35805. /**
  35806. * An event triggered when a material is created
  35807. */
  35808. onNewMaterialAddedObservable: Observable<Material>;
  35809. /**
  35810. * An event triggered when a material is removed
  35811. */
  35812. onMaterialRemovedObservable: Observable<Material>;
  35813. /**
  35814. * An event triggered when a texture is created
  35815. */
  35816. onNewTextureAddedObservable: Observable<BaseTexture>;
  35817. /**
  35818. * An event triggered when a texture is removed
  35819. */
  35820. onTextureRemovedObservable: Observable<BaseTexture>;
  35821. /**
  35822. * An event triggered when render targets are about to be rendered
  35823. * Can happen multiple times per frame.
  35824. */
  35825. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35826. /**
  35827. * An event triggered when render targets were rendered.
  35828. * Can happen multiple times per frame.
  35829. */
  35830. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35831. /**
  35832. * An event triggered before calculating deterministic simulation step
  35833. */
  35834. onBeforeStepObservable: Observable<Scene>;
  35835. /**
  35836. * An event triggered after calculating deterministic simulation step
  35837. */
  35838. onAfterStepObservable: Observable<Scene>;
  35839. /**
  35840. * An event triggered when the activeCamera property is updated
  35841. */
  35842. onActiveCameraChanged: Observable<Scene>;
  35843. /**
  35844. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35845. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35846. * 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)
  35847. */
  35848. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35849. /**
  35850. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35851. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35852. * 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)
  35853. */
  35854. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35855. /**
  35856. * This Observable will when a mesh has been imported into the scene.
  35857. */
  35858. onMeshImportedObservable: Observable<AbstractMesh>;
  35859. /**
  35860. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35861. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35862. */
  35863. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35864. /** @hidden */
  35865. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35866. /**
  35867. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35868. */
  35869. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35870. /**
  35871. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35872. */
  35873. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35874. /**
  35875. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35876. */
  35877. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35878. /** Callback called when a pointer move is detected */
  35879. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35880. /** Callback called when a pointer down is detected */
  35881. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35882. /** Callback called when a pointer up is detected */
  35883. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35884. /** Callback called when a pointer pick is detected */
  35885. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35886. /**
  35887. * 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).
  35888. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35889. */
  35890. onPrePointerObservable: Observable<PointerInfoPre>;
  35891. /**
  35892. * Observable event triggered each time an input event is received from the rendering canvas
  35893. */
  35894. onPointerObservable: Observable<PointerInfo>;
  35895. /**
  35896. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35897. */
  35898. readonly unTranslatedPointer: Vector2;
  35899. /**
  35900. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35901. */
  35902. static DragMovementThreshold: number;
  35903. /**
  35904. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35905. */
  35906. static LongPressDelay: number;
  35907. /**
  35908. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35909. */
  35910. static DoubleClickDelay: number;
  35911. /** If you need to check double click without raising a single click at first click, enable this flag */
  35912. static ExclusiveDoubleClickMode: boolean;
  35913. /** @hidden */
  35914. _mirroredCameraPosition: Nullable<Vector3>;
  35915. /**
  35916. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35917. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35918. */
  35919. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35920. /**
  35921. * Observable event triggered each time an keyboard event is received from the hosting window
  35922. */
  35923. onKeyboardObservable: Observable<KeyboardInfo>;
  35924. private _useRightHandedSystem;
  35925. /**
  35926. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35927. */
  35928. useRightHandedSystem: boolean;
  35929. private _timeAccumulator;
  35930. private _currentStepId;
  35931. private _currentInternalStep;
  35932. /**
  35933. * Sets the step Id used by deterministic lock step
  35934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35935. * @param newStepId defines the step Id
  35936. */
  35937. setStepId(newStepId: number): void;
  35938. /**
  35939. * Gets the step Id used by deterministic lock step
  35940. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35941. * @returns the step Id
  35942. */
  35943. getStepId(): number;
  35944. /**
  35945. * Gets the internal step used by deterministic lock step
  35946. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35947. * @returns the internal step
  35948. */
  35949. getInternalStep(): number;
  35950. private _fogEnabled;
  35951. /**
  35952. * Gets or sets a boolean indicating if fog is enabled on this scene
  35953. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35954. * (Default is true)
  35955. */
  35956. fogEnabled: boolean;
  35957. private _fogMode;
  35958. /**
  35959. * Gets or sets the fog mode to use
  35960. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35961. * | mode | value |
  35962. * | --- | --- |
  35963. * | FOGMODE_NONE | 0 |
  35964. * | FOGMODE_EXP | 1 |
  35965. * | FOGMODE_EXP2 | 2 |
  35966. * | FOGMODE_LINEAR | 3 |
  35967. */
  35968. fogMode: number;
  35969. /**
  35970. * Gets or sets the fog color to use
  35971. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35972. * (Default is Color3(0.2, 0.2, 0.3))
  35973. */
  35974. fogColor: Color3;
  35975. /**
  35976. * Gets or sets the fog density to use
  35977. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35978. * (Default is 0.1)
  35979. */
  35980. fogDensity: number;
  35981. /**
  35982. * Gets or sets the fog start distance to use
  35983. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35984. * (Default is 0)
  35985. */
  35986. fogStart: number;
  35987. /**
  35988. * Gets or sets the fog end distance to use
  35989. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35990. * (Default is 1000)
  35991. */
  35992. fogEnd: number;
  35993. private _shadowsEnabled;
  35994. /**
  35995. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35996. */
  35997. shadowsEnabled: boolean;
  35998. private _lightsEnabled;
  35999. /**
  36000. * Gets or sets a boolean indicating if lights are enabled on this scene
  36001. */
  36002. lightsEnabled: boolean;
  36003. /** All of the active cameras added to this scene. */
  36004. activeCameras: Camera[];
  36005. /** @hidden */
  36006. _activeCamera: Nullable<Camera>;
  36007. /** Gets or sets the current active camera */
  36008. activeCamera: Nullable<Camera>;
  36009. private _defaultMaterial;
  36010. /** The default material used on meshes when no material is affected */
  36011. /** The default material used on meshes when no material is affected */
  36012. defaultMaterial: Material;
  36013. private _texturesEnabled;
  36014. /**
  36015. * Gets or sets a boolean indicating if textures are enabled on this scene
  36016. */
  36017. texturesEnabled: boolean;
  36018. /**
  36019. * Gets or sets a boolean indicating if particles are enabled on this scene
  36020. */
  36021. particlesEnabled: boolean;
  36022. /**
  36023. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36024. */
  36025. spritesEnabled: boolean;
  36026. private _skeletonsEnabled;
  36027. /**
  36028. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36029. */
  36030. skeletonsEnabled: boolean;
  36031. /**
  36032. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36033. */
  36034. lensFlaresEnabled: boolean;
  36035. /**
  36036. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36038. */
  36039. collisionsEnabled: boolean;
  36040. private _collisionCoordinator;
  36041. /** @hidden */
  36042. readonly collisionCoordinator: ICollisionCoordinator;
  36043. /**
  36044. * Defines the gravity applied to this scene (used only for collisions)
  36045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36046. */
  36047. gravity: Vector3;
  36048. /**
  36049. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36050. */
  36051. postProcessesEnabled: boolean;
  36052. /**
  36053. * The list of postprocesses added to the scene
  36054. */
  36055. postProcesses: PostProcess[];
  36056. /**
  36057. * Gets the current postprocess manager
  36058. */
  36059. postProcessManager: PostProcessManager;
  36060. /**
  36061. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36062. */
  36063. renderTargetsEnabled: boolean;
  36064. /**
  36065. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36066. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36067. */
  36068. dumpNextRenderTargets: boolean;
  36069. /**
  36070. * The list of user defined render targets added to the scene
  36071. */
  36072. customRenderTargets: RenderTargetTexture[];
  36073. /**
  36074. * Defines if texture loading must be delayed
  36075. * If true, textures will only be loaded when they need to be rendered
  36076. */
  36077. useDelayedTextureLoading: boolean;
  36078. /**
  36079. * Gets the list of meshes imported to the scene through SceneLoader
  36080. */
  36081. importedMeshesFiles: String[];
  36082. /**
  36083. * Gets or sets a boolean indicating if probes are enabled on this scene
  36084. */
  36085. probesEnabled: boolean;
  36086. /**
  36087. * Gets or sets the current offline provider to use to store scene data
  36088. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36089. */
  36090. offlineProvider: IOfflineProvider;
  36091. /**
  36092. * Gets or sets the action manager associated with the scene
  36093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36094. */
  36095. actionManager: AbstractActionManager;
  36096. private _meshesForIntersections;
  36097. /**
  36098. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36099. */
  36100. proceduralTexturesEnabled: boolean;
  36101. private _engine;
  36102. private _totalVertices;
  36103. /** @hidden */
  36104. _activeIndices: PerfCounter;
  36105. /** @hidden */
  36106. _activeParticles: PerfCounter;
  36107. /** @hidden */
  36108. _activeBones: PerfCounter;
  36109. private _animationRatio;
  36110. /** @hidden */
  36111. _animationTimeLast: number;
  36112. /** @hidden */
  36113. _animationTime: number;
  36114. /**
  36115. * Gets or sets a general scale for animation speed
  36116. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36117. */
  36118. animationTimeScale: number;
  36119. /** @hidden */
  36120. _cachedMaterial: Nullable<Material>;
  36121. /** @hidden */
  36122. _cachedEffect: Nullable<Effect>;
  36123. /** @hidden */
  36124. _cachedVisibility: Nullable<number>;
  36125. private _renderId;
  36126. private _frameId;
  36127. private _executeWhenReadyTimeoutId;
  36128. private _intermediateRendering;
  36129. private _viewUpdateFlag;
  36130. private _projectionUpdateFlag;
  36131. /** @hidden */
  36132. _toBeDisposed: Nullable<IDisposable>[];
  36133. private _activeRequests;
  36134. /** @hidden */
  36135. _pendingData: any[];
  36136. private _isDisposed;
  36137. /**
  36138. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36139. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36140. */
  36141. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36142. private _activeMeshes;
  36143. private _processedMaterials;
  36144. private _renderTargets;
  36145. /** @hidden */
  36146. _activeParticleSystems: SmartArray<IParticleSystem>;
  36147. private _activeSkeletons;
  36148. private _softwareSkinnedMeshes;
  36149. private _renderingManager;
  36150. /** @hidden */
  36151. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36152. private _transformMatrix;
  36153. private _sceneUbo;
  36154. /** @hidden */
  36155. _viewMatrix: Matrix;
  36156. private _projectionMatrix;
  36157. /** @hidden */
  36158. _forcedViewPosition: Nullable<Vector3>;
  36159. /** @hidden */
  36160. _frustumPlanes: Plane[];
  36161. /**
  36162. * Gets the list of frustum planes (built from the active camera)
  36163. */
  36164. readonly frustumPlanes: Plane[];
  36165. /**
  36166. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36167. * This is useful if there are more lights that the maximum simulteanous authorized
  36168. */
  36169. requireLightSorting: boolean;
  36170. /** @hidden */
  36171. readonly useMaterialMeshMap: boolean;
  36172. /** @hidden */
  36173. readonly useClonedMeshhMap: boolean;
  36174. private _externalData;
  36175. private _uid;
  36176. /**
  36177. * @hidden
  36178. * Backing store of defined scene components.
  36179. */
  36180. _components: ISceneComponent[];
  36181. /**
  36182. * @hidden
  36183. * Backing store of defined scene components.
  36184. */
  36185. _serializableComponents: ISceneSerializableComponent[];
  36186. /**
  36187. * List of components to register on the next registration step.
  36188. */
  36189. private _transientComponents;
  36190. /**
  36191. * Registers the transient components if needed.
  36192. */
  36193. private _registerTransientComponents;
  36194. /**
  36195. * @hidden
  36196. * Add a component to the scene.
  36197. * Note that the ccomponent could be registered on th next frame if this is called after
  36198. * the register component stage.
  36199. * @param component Defines the component to add to the scene
  36200. */
  36201. _addComponent(component: ISceneComponent): void;
  36202. /**
  36203. * @hidden
  36204. * Gets a component from the scene.
  36205. * @param name defines the name of the component to retrieve
  36206. * @returns the component or null if not present
  36207. */
  36208. _getComponent(name: string): Nullable<ISceneComponent>;
  36209. /**
  36210. * @hidden
  36211. * Defines the actions happening before camera updates.
  36212. */
  36213. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36214. /**
  36215. * @hidden
  36216. * Defines the actions happening before clear the canvas.
  36217. */
  36218. _beforeClearStage: Stage<SimpleStageAction>;
  36219. /**
  36220. * @hidden
  36221. * Defines the actions when collecting render targets for the frame.
  36222. */
  36223. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36224. /**
  36225. * @hidden
  36226. * Defines the actions happening for one camera in the frame.
  36227. */
  36228. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36229. /**
  36230. * @hidden
  36231. * Defines the actions happening during the per mesh ready checks.
  36232. */
  36233. _isReadyForMeshStage: Stage<MeshStageAction>;
  36234. /**
  36235. * @hidden
  36236. * Defines the actions happening before evaluate active mesh checks.
  36237. */
  36238. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36239. /**
  36240. * @hidden
  36241. * Defines the actions happening during the evaluate sub mesh checks.
  36242. */
  36243. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36244. /**
  36245. * @hidden
  36246. * Defines the actions happening during the active mesh stage.
  36247. */
  36248. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36249. /**
  36250. * @hidden
  36251. * Defines the actions happening during the per camera render target step.
  36252. */
  36253. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36254. /**
  36255. * @hidden
  36256. * Defines the actions happening just before the active camera is drawing.
  36257. */
  36258. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36259. /**
  36260. * @hidden
  36261. * Defines the actions happening just before a render target is drawing.
  36262. */
  36263. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36264. /**
  36265. * @hidden
  36266. * Defines the actions happening just before a rendering group is drawing.
  36267. */
  36268. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36269. /**
  36270. * @hidden
  36271. * Defines the actions happening just before a mesh is drawing.
  36272. */
  36273. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36274. /**
  36275. * @hidden
  36276. * Defines the actions happening just after a mesh has been drawn.
  36277. */
  36278. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36279. /**
  36280. * @hidden
  36281. * Defines the actions happening just after a rendering group has been drawn.
  36282. */
  36283. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36284. /**
  36285. * @hidden
  36286. * Defines the actions happening just after the active camera has been drawn.
  36287. */
  36288. _afterCameraDrawStage: Stage<CameraStageAction>;
  36289. /**
  36290. * @hidden
  36291. * Defines the actions happening just after a render target has been drawn.
  36292. */
  36293. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36294. /**
  36295. * @hidden
  36296. * Defines the actions happening just after rendering all cameras and computing intersections.
  36297. */
  36298. _afterRenderStage: Stage<SimpleStageAction>;
  36299. /**
  36300. * @hidden
  36301. * Defines the actions happening when a pointer move event happens.
  36302. */
  36303. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36304. /**
  36305. * @hidden
  36306. * Defines the actions happening when a pointer down event happens.
  36307. */
  36308. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36309. /**
  36310. * @hidden
  36311. * Defines the actions happening when a pointer up event happens.
  36312. */
  36313. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36314. /**
  36315. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36316. */
  36317. private geometriesByUniqueId;
  36318. /**
  36319. * Creates a new Scene
  36320. * @param engine defines the engine to use to render this scene
  36321. * @param options defines the scene options
  36322. */
  36323. constructor(engine: Engine, options?: SceneOptions);
  36324. /**
  36325. * Gets a string idenfifying the name of the class
  36326. * @returns "Scene" string
  36327. */
  36328. getClassName(): string;
  36329. private _defaultMeshCandidates;
  36330. /**
  36331. * @hidden
  36332. */
  36333. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36334. private _defaultSubMeshCandidates;
  36335. /**
  36336. * @hidden
  36337. */
  36338. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36339. /**
  36340. * Sets the default candidate providers for the scene.
  36341. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36342. * and getCollidingSubMeshCandidates to their default function
  36343. */
  36344. setDefaultCandidateProviders(): void;
  36345. /**
  36346. * Gets the mesh that is currently under the pointer
  36347. */
  36348. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36349. /**
  36350. * Gets or sets the current on-screen X position of the pointer
  36351. */
  36352. pointerX: number;
  36353. /**
  36354. * Gets or sets the current on-screen Y position of the pointer
  36355. */
  36356. pointerY: number;
  36357. /**
  36358. * Gets the cached material (ie. the latest rendered one)
  36359. * @returns the cached material
  36360. */
  36361. getCachedMaterial(): Nullable<Material>;
  36362. /**
  36363. * Gets the cached effect (ie. the latest rendered one)
  36364. * @returns the cached effect
  36365. */
  36366. getCachedEffect(): Nullable<Effect>;
  36367. /**
  36368. * Gets the cached visibility state (ie. the latest rendered one)
  36369. * @returns the cached visibility state
  36370. */
  36371. getCachedVisibility(): Nullable<number>;
  36372. /**
  36373. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36374. * @param material defines the current material
  36375. * @param effect defines the current effect
  36376. * @param visibility defines the current visibility state
  36377. * @returns true if one parameter is not cached
  36378. */
  36379. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36380. /**
  36381. * Gets the engine associated with the scene
  36382. * @returns an Engine
  36383. */
  36384. getEngine(): Engine;
  36385. /**
  36386. * Gets the total number of vertices rendered per frame
  36387. * @returns the total number of vertices rendered per frame
  36388. */
  36389. getTotalVertices(): number;
  36390. /**
  36391. * Gets the performance counter for total vertices
  36392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36393. */
  36394. readonly totalVerticesPerfCounter: PerfCounter;
  36395. /**
  36396. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36397. * @returns the total number of active indices rendered per frame
  36398. */
  36399. getActiveIndices(): number;
  36400. /**
  36401. * Gets the performance counter for active indices
  36402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36403. */
  36404. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36405. /**
  36406. * Gets the total number of active particles rendered per frame
  36407. * @returns the total number of active particles rendered per frame
  36408. */
  36409. getActiveParticles(): number;
  36410. /**
  36411. * Gets the performance counter for active particles
  36412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36413. */
  36414. readonly activeParticlesPerfCounter: PerfCounter;
  36415. /**
  36416. * Gets the total number of active bones rendered per frame
  36417. * @returns the total number of active bones rendered per frame
  36418. */
  36419. getActiveBones(): number;
  36420. /**
  36421. * Gets the performance counter for active bones
  36422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36423. */
  36424. readonly activeBonesPerfCounter: PerfCounter;
  36425. /**
  36426. * Gets the array of active meshes
  36427. * @returns an array of AbstractMesh
  36428. */
  36429. getActiveMeshes(): SmartArray<AbstractMesh>;
  36430. /**
  36431. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36432. * @returns a number
  36433. */
  36434. getAnimationRatio(): number;
  36435. /**
  36436. * Gets an unique Id for the current render phase
  36437. * @returns a number
  36438. */
  36439. getRenderId(): number;
  36440. /**
  36441. * Gets an unique Id for the current frame
  36442. * @returns a number
  36443. */
  36444. getFrameId(): number;
  36445. /** Call this function if you want to manually increment the render Id*/
  36446. incrementRenderId(): void;
  36447. private _createUbo;
  36448. /**
  36449. * Use this method to simulate a pointer move on a mesh
  36450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36453. * @returns the current scene
  36454. */
  36455. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36456. /**
  36457. * Use this method to simulate a pointer down on a mesh
  36458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36461. * @returns the current scene
  36462. */
  36463. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36464. /**
  36465. * Use this method to simulate a pointer up on a mesh
  36466. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36467. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36468. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36469. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36470. * @returns the current scene
  36471. */
  36472. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36473. /**
  36474. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36475. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36476. * @returns true if the pointer was captured
  36477. */
  36478. isPointerCaptured(pointerId?: number): boolean;
  36479. /**
  36480. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36481. * @param attachUp defines if you want to attach events to pointerup
  36482. * @param attachDown defines if you want to attach events to pointerdown
  36483. * @param attachMove defines if you want to attach events to pointermove
  36484. */
  36485. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36486. /** Detaches all event handlers*/
  36487. detachControl(): void;
  36488. /**
  36489. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36490. * Delay loaded resources are not taking in account
  36491. * @return true if all required resources are ready
  36492. */
  36493. isReady(): boolean;
  36494. /** Resets all cached information relative to material (including effect and visibility) */
  36495. resetCachedMaterial(): void;
  36496. /**
  36497. * Registers a function to be called before every frame render
  36498. * @param func defines the function to register
  36499. */
  36500. registerBeforeRender(func: () => void): void;
  36501. /**
  36502. * Unregisters a function called before every frame render
  36503. * @param func defines the function to unregister
  36504. */
  36505. unregisterBeforeRender(func: () => void): void;
  36506. /**
  36507. * Registers a function to be called after every frame render
  36508. * @param func defines the function to register
  36509. */
  36510. registerAfterRender(func: () => void): void;
  36511. /**
  36512. * Unregisters a function called after every frame render
  36513. * @param func defines the function to unregister
  36514. */
  36515. unregisterAfterRender(func: () => void): void;
  36516. private _executeOnceBeforeRender;
  36517. /**
  36518. * The provided function will run before render once and will be disposed afterwards.
  36519. * A timeout delay can be provided so that the function will be executed in N ms.
  36520. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36521. * @param func The function to be executed.
  36522. * @param timeout optional delay in ms
  36523. */
  36524. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36525. /** @hidden */
  36526. _addPendingData(data: any): void;
  36527. /** @hidden */
  36528. _removePendingData(data: any): void;
  36529. /**
  36530. * Returns the number of items waiting to be loaded
  36531. * @returns the number of items waiting to be loaded
  36532. */
  36533. getWaitingItemsCount(): number;
  36534. /**
  36535. * Returns a boolean indicating if the scene is still loading data
  36536. */
  36537. readonly isLoading: boolean;
  36538. /**
  36539. * Registers a function to be executed when the scene is ready
  36540. * @param {Function} func - the function to be executed
  36541. */
  36542. executeWhenReady(func: () => void): void;
  36543. /**
  36544. * Returns a promise that resolves when the scene is ready
  36545. * @returns A promise that resolves when the scene is ready
  36546. */
  36547. whenReadyAsync(): Promise<void>;
  36548. /** @hidden */
  36549. _checkIsReady(): void;
  36550. /**
  36551. * Gets all animatable attached to the scene
  36552. */
  36553. readonly animatables: Animatable[];
  36554. /**
  36555. * Resets the last animation time frame.
  36556. * Useful to override when animations start running when loading a scene for the first time.
  36557. */
  36558. resetLastAnimationTimeFrame(): void;
  36559. /**
  36560. * Gets the current view matrix
  36561. * @returns a Matrix
  36562. */
  36563. getViewMatrix(): Matrix;
  36564. /**
  36565. * Gets the current projection matrix
  36566. * @returns a Matrix
  36567. */
  36568. getProjectionMatrix(): Matrix;
  36569. /**
  36570. * Gets the current transform matrix
  36571. * @returns a Matrix made of View * Projection
  36572. */
  36573. getTransformMatrix(): Matrix;
  36574. /**
  36575. * Sets the current transform matrix
  36576. * @param viewL defines the View matrix to use
  36577. * @param projectionL defines the Projection matrix to use
  36578. * @param viewR defines the right View matrix to use (if provided)
  36579. * @param projectionR defines the right Projection matrix to use (if provided)
  36580. */
  36581. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36582. /**
  36583. * Gets the uniform buffer used to store scene data
  36584. * @returns a UniformBuffer
  36585. */
  36586. getSceneUniformBuffer(): UniformBuffer;
  36587. /**
  36588. * Gets an unique (relatively to the current scene) Id
  36589. * @returns an unique number for the scene
  36590. */
  36591. getUniqueId(): number;
  36592. /**
  36593. * Add a mesh to the list of scene's meshes
  36594. * @param newMesh defines the mesh to add
  36595. * @param recursive if all child meshes should also be added to the scene
  36596. */
  36597. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36598. /**
  36599. * Remove a mesh for the list of scene's meshes
  36600. * @param toRemove defines the mesh to remove
  36601. * @param recursive if all child meshes should also be removed from the scene
  36602. * @returns the index where the mesh was in the mesh list
  36603. */
  36604. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36605. /**
  36606. * Add a transform node to the list of scene's transform nodes
  36607. * @param newTransformNode defines the transform node to add
  36608. */
  36609. addTransformNode(newTransformNode: TransformNode): void;
  36610. /**
  36611. * Remove a transform node for the list of scene's transform nodes
  36612. * @param toRemove defines the transform node to remove
  36613. * @returns the index where the transform node was in the transform node list
  36614. */
  36615. removeTransformNode(toRemove: TransformNode): number;
  36616. /**
  36617. * Remove a skeleton for the list of scene's skeletons
  36618. * @param toRemove defines the skeleton to remove
  36619. * @returns the index where the skeleton was in the skeleton list
  36620. */
  36621. removeSkeleton(toRemove: Skeleton): number;
  36622. /**
  36623. * Remove a morph target for the list of scene's morph targets
  36624. * @param toRemove defines the morph target to remove
  36625. * @returns the index where the morph target was in the morph target list
  36626. */
  36627. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36628. /**
  36629. * Remove a light for the list of scene's lights
  36630. * @param toRemove defines the light to remove
  36631. * @returns the index where the light was in the light list
  36632. */
  36633. removeLight(toRemove: Light): number;
  36634. /**
  36635. * Remove a camera for the list of scene's cameras
  36636. * @param toRemove defines the camera to remove
  36637. * @returns the index where the camera was in the camera list
  36638. */
  36639. removeCamera(toRemove: Camera): number;
  36640. /**
  36641. * Remove a particle system for the list of scene's particle systems
  36642. * @param toRemove defines the particle system to remove
  36643. * @returns the index where the particle system was in the particle system list
  36644. */
  36645. removeParticleSystem(toRemove: IParticleSystem): number;
  36646. /**
  36647. * Remove a animation for the list of scene's animations
  36648. * @param toRemove defines the animation to remove
  36649. * @returns the index where the animation was in the animation list
  36650. */
  36651. removeAnimation(toRemove: Animation): number;
  36652. /**
  36653. * Will stop the animation of the given target
  36654. * @param target - the target
  36655. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36656. * @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)
  36657. */
  36658. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36659. /**
  36660. * Removes the given animation group from this scene.
  36661. * @param toRemove The animation group to remove
  36662. * @returns The index of the removed animation group
  36663. */
  36664. removeAnimationGroup(toRemove: AnimationGroup): number;
  36665. /**
  36666. * Removes the given multi-material from this scene.
  36667. * @param toRemove The multi-material to remove
  36668. * @returns The index of the removed multi-material
  36669. */
  36670. removeMultiMaterial(toRemove: MultiMaterial): number;
  36671. /**
  36672. * Removes the given material from this scene.
  36673. * @param toRemove The material to remove
  36674. * @returns The index of the removed material
  36675. */
  36676. removeMaterial(toRemove: Material): number;
  36677. /**
  36678. * Removes the given action manager from this scene.
  36679. * @param toRemove The action manager to remove
  36680. * @returns The index of the removed action manager
  36681. */
  36682. removeActionManager(toRemove: AbstractActionManager): number;
  36683. /**
  36684. * Removes the given texture from this scene.
  36685. * @param toRemove The texture to remove
  36686. * @returns The index of the removed texture
  36687. */
  36688. removeTexture(toRemove: BaseTexture): number;
  36689. /**
  36690. * Adds the given light to this scene
  36691. * @param newLight The light to add
  36692. */
  36693. addLight(newLight: Light): void;
  36694. /**
  36695. * Sorts the list list based on light priorities
  36696. */
  36697. sortLightsByPriority(): void;
  36698. /**
  36699. * Adds the given camera to this scene
  36700. * @param newCamera The camera to add
  36701. */
  36702. addCamera(newCamera: Camera): void;
  36703. /**
  36704. * Adds the given skeleton to this scene
  36705. * @param newSkeleton The skeleton to add
  36706. */
  36707. addSkeleton(newSkeleton: Skeleton): void;
  36708. /**
  36709. * Adds the given particle system to this scene
  36710. * @param newParticleSystem The particle system to add
  36711. */
  36712. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36713. /**
  36714. * Adds the given animation to this scene
  36715. * @param newAnimation The animation to add
  36716. */
  36717. addAnimation(newAnimation: Animation): void;
  36718. /**
  36719. * Adds the given animation group to this scene.
  36720. * @param newAnimationGroup The animation group to add
  36721. */
  36722. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36723. /**
  36724. * Adds the given multi-material to this scene
  36725. * @param newMultiMaterial The multi-material to add
  36726. */
  36727. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36728. /**
  36729. * Adds the given material to this scene
  36730. * @param newMaterial The material to add
  36731. */
  36732. addMaterial(newMaterial: Material): void;
  36733. /**
  36734. * Adds the given morph target to this scene
  36735. * @param newMorphTargetManager The morph target to add
  36736. */
  36737. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36738. /**
  36739. * Adds the given geometry to this scene
  36740. * @param newGeometry The geometry to add
  36741. */
  36742. addGeometry(newGeometry: Geometry): void;
  36743. /**
  36744. * Adds the given action manager to this scene
  36745. * @param newActionManager The action manager to add
  36746. */
  36747. addActionManager(newActionManager: AbstractActionManager): void;
  36748. /**
  36749. * Adds the given texture to this scene.
  36750. * @param newTexture The texture to add
  36751. */
  36752. addTexture(newTexture: BaseTexture): void;
  36753. /**
  36754. * Switch active camera
  36755. * @param newCamera defines the new active camera
  36756. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36757. */
  36758. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36759. /**
  36760. * sets the active camera of the scene using its ID
  36761. * @param id defines the camera's ID
  36762. * @return the new active camera or null if none found.
  36763. */
  36764. setActiveCameraByID(id: string): Nullable<Camera>;
  36765. /**
  36766. * sets the active camera of the scene using its name
  36767. * @param name defines the camera's name
  36768. * @returns the new active camera or null if none found.
  36769. */
  36770. setActiveCameraByName(name: string): Nullable<Camera>;
  36771. /**
  36772. * get an animation group using its name
  36773. * @param name defines the material's name
  36774. * @return the animation group or null if none found.
  36775. */
  36776. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36777. /**
  36778. * Get a material using its unique id
  36779. * @param uniqueId defines the material's unique id
  36780. * @return the material or null if none found.
  36781. */
  36782. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36783. /**
  36784. * get a material using its id
  36785. * @param id defines the material's ID
  36786. * @return the material or null if none found.
  36787. */
  36788. getMaterialByID(id: string): Nullable<Material>;
  36789. /**
  36790. * Gets a the last added material using a given id
  36791. * @param id defines the material's ID
  36792. * @return the last material with the given id or null if none found.
  36793. */
  36794. getLastMaterialByID(id: string): Nullable<Material>;
  36795. /**
  36796. * Gets a material using its name
  36797. * @param name defines the material's name
  36798. * @return the material or null if none found.
  36799. */
  36800. getMaterialByName(name: string): Nullable<Material>;
  36801. /**
  36802. * Get a texture using its unique id
  36803. * @param uniqueId defines the texture's unique id
  36804. * @return the texture or null if none found.
  36805. */
  36806. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36807. /**
  36808. * Gets a camera using its id
  36809. * @param id defines the id to look for
  36810. * @returns the camera or null if not found
  36811. */
  36812. getCameraByID(id: string): Nullable<Camera>;
  36813. /**
  36814. * Gets a camera using its unique id
  36815. * @param uniqueId defines the unique id to look for
  36816. * @returns the camera or null if not found
  36817. */
  36818. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36819. /**
  36820. * Gets a camera using its name
  36821. * @param name defines the camera's name
  36822. * @return the camera or null if none found.
  36823. */
  36824. getCameraByName(name: string): Nullable<Camera>;
  36825. /**
  36826. * Gets a bone using its id
  36827. * @param id defines the bone's id
  36828. * @return the bone or null if not found
  36829. */
  36830. getBoneByID(id: string): Nullable<Bone>;
  36831. /**
  36832. * Gets a bone using its id
  36833. * @param name defines the bone's name
  36834. * @return the bone or null if not found
  36835. */
  36836. getBoneByName(name: string): Nullable<Bone>;
  36837. /**
  36838. * Gets a light node using its name
  36839. * @param name defines the the light's name
  36840. * @return the light or null if none found.
  36841. */
  36842. getLightByName(name: string): Nullable<Light>;
  36843. /**
  36844. * Gets a light node using its id
  36845. * @param id defines the light's id
  36846. * @return the light or null if none found.
  36847. */
  36848. getLightByID(id: string): Nullable<Light>;
  36849. /**
  36850. * Gets a light node using its scene-generated unique ID
  36851. * @param uniqueId defines the light's unique id
  36852. * @return the light or null if none found.
  36853. */
  36854. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36855. /**
  36856. * Gets a particle system by id
  36857. * @param id defines the particle system id
  36858. * @return the corresponding system or null if none found
  36859. */
  36860. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36861. /**
  36862. * Gets a geometry using its ID
  36863. * @param id defines the geometry's id
  36864. * @return the geometry or null if none found.
  36865. */
  36866. getGeometryByID(id: string): Nullable<Geometry>;
  36867. private _getGeometryByUniqueID;
  36868. /**
  36869. * Add a new geometry to this scene
  36870. * @param geometry defines the geometry to be added to the scene.
  36871. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36872. * @return a boolean defining if the geometry was added or not
  36873. */
  36874. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36875. /**
  36876. * Removes an existing geometry
  36877. * @param geometry defines the geometry to be removed from the scene
  36878. * @return a boolean defining if the geometry was removed or not
  36879. */
  36880. removeGeometry(geometry: Geometry): boolean;
  36881. /**
  36882. * Gets the list of geometries attached to the scene
  36883. * @returns an array of Geometry
  36884. */
  36885. getGeometries(): Geometry[];
  36886. /**
  36887. * Gets the first added mesh found of a given ID
  36888. * @param id defines the id to search for
  36889. * @return the mesh found or null if not found at all
  36890. */
  36891. getMeshByID(id: string): Nullable<AbstractMesh>;
  36892. /**
  36893. * Gets a list of meshes using their id
  36894. * @param id defines the id to search for
  36895. * @returns a list of meshes
  36896. */
  36897. getMeshesByID(id: string): Array<AbstractMesh>;
  36898. /**
  36899. * Gets the first added transform node found of a given ID
  36900. * @param id defines the id to search for
  36901. * @return the found transform node or null if not found at all.
  36902. */
  36903. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36904. /**
  36905. * Gets a transform node with its auto-generated unique id
  36906. * @param uniqueId efines the unique id to search for
  36907. * @return the found transform node or null if not found at all.
  36908. */
  36909. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36910. /**
  36911. * Gets a list of transform nodes using their id
  36912. * @param id defines the id to search for
  36913. * @returns a list of transform nodes
  36914. */
  36915. getTransformNodesByID(id: string): Array<TransformNode>;
  36916. /**
  36917. * Gets a mesh with its auto-generated unique id
  36918. * @param uniqueId defines the unique id to search for
  36919. * @return the found mesh or null if not found at all.
  36920. */
  36921. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36922. /**
  36923. * Gets a the last added mesh using a given id
  36924. * @param id defines the id to search for
  36925. * @return the found mesh or null if not found at all.
  36926. */
  36927. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36928. /**
  36929. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36930. * @param id defines the id to search for
  36931. * @return the found node or null if not found at all
  36932. */
  36933. getLastEntryByID(id: string): Nullable<Node>;
  36934. /**
  36935. * Gets a node (Mesh, Camera, Light) using a given id
  36936. * @param id defines the id to search for
  36937. * @return the found node or null if not found at all
  36938. */
  36939. getNodeByID(id: string): Nullable<Node>;
  36940. /**
  36941. * Gets a node (Mesh, Camera, Light) using a given name
  36942. * @param name defines the name to search for
  36943. * @return the found node or null if not found at all.
  36944. */
  36945. getNodeByName(name: string): Nullable<Node>;
  36946. /**
  36947. * Gets a mesh using a given name
  36948. * @param name defines the name to search for
  36949. * @return the found mesh or null if not found at all.
  36950. */
  36951. getMeshByName(name: string): Nullable<AbstractMesh>;
  36952. /**
  36953. * Gets a transform node using a given name
  36954. * @param name defines the name to search for
  36955. * @return the found transform node or null if not found at all.
  36956. */
  36957. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36958. /**
  36959. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36960. * @param id defines the id to search for
  36961. * @return the found skeleton or null if not found at all.
  36962. */
  36963. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36964. /**
  36965. * Gets a skeleton using a given auto generated unique id
  36966. * @param uniqueId defines the unique id to search for
  36967. * @return the found skeleton or null if not found at all.
  36968. */
  36969. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36970. /**
  36971. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36972. * @param id defines the id to search for
  36973. * @return the found skeleton or null if not found at all.
  36974. */
  36975. getSkeletonById(id: string): Nullable<Skeleton>;
  36976. /**
  36977. * Gets a skeleton using a given name
  36978. * @param name defines the name to search for
  36979. * @return the found skeleton or null if not found at all.
  36980. */
  36981. getSkeletonByName(name: string): Nullable<Skeleton>;
  36982. /**
  36983. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36984. * @param id defines the id to search for
  36985. * @return the found morph target manager or null if not found at all.
  36986. */
  36987. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36988. /**
  36989. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36990. * @param id defines the id to search for
  36991. * @return the found morph target or null if not found at all.
  36992. */
  36993. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36994. /**
  36995. * Gets a boolean indicating if the given mesh is active
  36996. * @param mesh defines the mesh to look for
  36997. * @returns true if the mesh is in the active list
  36998. */
  36999. isActiveMesh(mesh: AbstractMesh): boolean;
  37000. /**
  37001. * Return a unique id as a string which can serve as an identifier for the scene
  37002. */
  37003. readonly uid: string;
  37004. /**
  37005. * Add an externaly attached data from its key.
  37006. * This method call will fail and return false, if such key already exists.
  37007. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37008. * @param key the unique key that identifies the data
  37009. * @param data the data object to associate to the key for this Engine instance
  37010. * @return true if no such key were already present and the data was added successfully, false otherwise
  37011. */
  37012. addExternalData<T>(key: string, data: T): boolean;
  37013. /**
  37014. * Get an externaly attached data from its key
  37015. * @param key the unique key that identifies the data
  37016. * @return the associated data, if present (can be null), or undefined if not present
  37017. */
  37018. getExternalData<T>(key: string): Nullable<T>;
  37019. /**
  37020. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37021. * @param key the unique key that identifies the data
  37022. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37023. * @return the associated data, can be null if the factory returned null.
  37024. */
  37025. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37026. /**
  37027. * Remove an externaly attached data from the Engine instance
  37028. * @param key the unique key that identifies the data
  37029. * @return true if the data was successfully removed, false if it doesn't exist
  37030. */
  37031. removeExternalData(key: string): boolean;
  37032. private _evaluateSubMesh;
  37033. /**
  37034. * Clear the processed materials smart array preventing retention point in material dispose.
  37035. */
  37036. freeProcessedMaterials(): void;
  37037. private _preventFreeActiveMeshesAndRenderingGroups;
  37038. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37039. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37040. * when disposing several meshes in a row or a hierarchy of meshes.
  37041. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37042. */
  37043. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37044. /**
  37045. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37046. */
  37047. freeActiveMeshes(): void;
  37048. /**
  37049. * Clear the info related to rendering groups preventing retention points during dispose.
  37050. */
  37051. freeRenderingGroups(): void;
  37052. /** @hidden */
  37053. _isInIntermediateRendering(): boolean;
  37054. /**
  37055. * Lambda returning the list of potentially active meshes.
  37056. */
  37057. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37058. /**
  37059. * Lambda returning the list of potentially active sub meshes.
  37060. */
  37061. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37062. /**
  37063. * Lambda returning the list of potentially intersecting sub meshes.
  37064. */
  37065. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37066. /**
  37067. * Lambda returning the list of potentially colliding sub meshes.
  37068. */
  37069. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37070. private _activeMeshesFrozen;
  37071. private _skipEvaluateActiveMeshesCompletely;
  37072. /**
  37073. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37074. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37075. * @returns the current scene
  37076. */
  37077. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37078. /**
  37079. * Use this function to restart evaluating active meshes on every frame
  37080. * @returns the current scene
  37081. */
  37082. unfreezeActiveMeshes(): Scene;
  37083. private _evaluateActiveMeshes;
  37084. private _activeMesh;
  37085. /**
  37086. * Update the transform matrix to update from the current active camera
  37087. * @param force defines a boolean used to force the update even if cache is up to date
  37088. */
  37089. updateTransformMatrix(force?: boolean): void;
  37090. private _bindFrameBuffer;
  37091. /** @hidden */
  37092. _allowPostProcessClearColor: boolean;
  37093. /** @hidden */
  37094. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37095. private _processSubCameras;
  37096. private _checkIntersections;
  37097. /** @hidden */
  37098. _advancePhysicsEngineStep(step: number): void;
  37099. /**
  37100. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37101. */
  37102. getDeterministicFrameTime: () => number;
  37103. /** @hidden */
  37104. _animate(): void;
  37105. /** Execute all animations (for a frame) */
  37106. animate(): void;
  37107. /**
  37108. * Render the scene
  37109. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37110. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37111. */
  37112. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37113. /**
  37114. * Freeze all materials
  37115. * A frozen material will not be updatable but should be faster to render
  37116. */
  37117. freezeMaterials(): void;
  37118. /**
  37119. * Unfreeze all materials
  37120. * A frozen material will not be updatable but should be faster to render
  37121. */
  37122. unfreezeMaterials(): void;
  37123. /**
  37124. * Releases all held ressources
  37125. */
  37126. dispose(): void;
  37127. /**
  37128. * Gets if the scene is already disposed
  37129. */
  37130. readonly isDisposed: boolean;
  37131. /**
  37132. * Call this function to reduce memory footprint of the scene.
  37133. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37134. */
  37135. clearCachedVertexData(): void;
  37136. /**
  37137. * This function will remove the local cached buffer data from texture.
  37138. * It will save memory but will prevent the texture from being rebuilt
  37139. */
  37140. cleanCachedTextureBuffer(): void;
  37141. /**
  37142. * Get the world extend vectors with an optional filter
  37143. *
  37144. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37145. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37146. */
  37147. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37148. min: Vector3;
  37149. max: Vector3;
  37150. };
  37151. /**
  37152. * Creates a ray that can be used to pick in the scene
  37153. * @param x defines the x coordinate of the origin (on-screen)
  37154. * @param y defines the y coordinate of the origin (on-screen)
  37155. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37156. * @param camera defines the camera to use for the picking
  37157. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37158. * @returns a Ray
  37159. */
  37160. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37161. /**
  37162. * Creates a ray that can be used to pick in the scene
  37163. * @param x defines the x coordinate of the origin (on-screen)
  37164. * @param y defines the y coordinate of the origin (on-screen)
  37165. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37166. * @param result defines the ray where to store the picking ray
  37167. * @param camera defines the camera to use for the picking
  37168. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37169. * @returns the current scene
  37170. */
  37171. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  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 camera defines the camera to use for the picking
  37177. * @returns a Ray
  37178. */
  37179. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37180. /**
  37181. * Creates a ray that can be used to pick in the scene
  37182. * @param x defines the x coordinate of the origin (on-screen)
  37183. * @param y defines the y coordinate of the origin (on-screen)
  37184. * @param result defines the ray where to store the picking ray
  37185. * @param camera defines the camera to use for the picking
  37186. * @returns the current scene
  37187. */
  37188. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37189. /** Launch a ray to try to pick a mesh in the scene
  37190. * @param x position on screen
  37191. * @param y position on screen
  37192. * @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
  37193. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37194. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37195. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37196. * @returns a PickingInfo
  37197. */
  37198. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37199. /** Use the given ray to pick a mesh in the scene
  37200. * @param ray The ray to use to pick meshes
  37201. * @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
  37202. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37204. * @returns a PickingInfo
  37205. */
  37206. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37207. /**
  37208. * Launch a ray to try to pick a mesh in the scene
  37209. * @param x X position on screen
  37210. * @param y Y position on screen
  37211. * @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
  37212. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37214. * @returns an array of PickingInfo
  37215. */
  37216. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37217. /**
  37218. * Launch a ray to try to pick a mesh in the scene
  37219. * @param ray Ray to use
  37220. * @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
  37221. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37222. * @returns an array of PickingInfo
  37223. */
  37224. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37225. /**
  37226. * Force the value of meshUnderPointer
  37227. * @param mesh defines the mesh to use
  37228. */
  37229. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37230. /**
  37231. * Gets the mesh under the pointer
  37232. * @returns a Mesh or null if no mesh is under the pointer
  37233. */
  37234. getPointerOverMesh(): Nullable<AbstractMesh>;
  37235. /** @hidden */
  37236. _rebuildGeometries(): void;
  37237. /** @hidden */
  37238. _rebuildTextures(): void;
  37239. private _getByTags;
  37240. /**
  37241. * Get a list of meshes by tags
  37242. * @param tagsQuery defines the tags query to use
  37243. * @param forEach defines a predicate used to filter results
  37244. * @returns an array of Mesh
  37245. */
  37246. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37247. /**
  37248. * Get a list of cameras by tags
  37249. * @param tagsQuery defines the tags query to use
  37250. * @param forEach defines a predicate used to filter results
  37251. * @returns an array of Camera
  37252. */
  37253. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37254. /**
  37255. * Get a list of lights by tags
  37256. * @param tagsQuery defines the tags query to use
  37257. * @param forEach defines a predicate used to filter results
  37258. * @returns an array of Light
  37259. */
  37260. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37261. /**
  37262. * Get a list of materials 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 Material
  37266. */
  37267. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37268. /**
  37269. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37270. * This allowed control for front to back rendering or reversly depending of the special needs.
  37271. *
  37272. * @param renderingGroupId The rendering group id corresponding to its index
  37273. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37274. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37275. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37276. */
  37277. 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;
  37278. /**
  37279. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37280. *
  37281. * @param renderingGroupId The rendering group id corresponding to its index
  37282. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37283. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37284. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37285. */
  37286. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37287. /**
  37288. * Gets the current auto clear configuration for one rendering group of the rendering
  37289. * manager.
  37290. * @param index the rendering group index to get the information for
  37291. * @returns The auto clear setup for the requested rendering group
  37292. */
  37293. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37294. private _blockMaterialDirtyMechanism;
  37295. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37296. blockMaterialDirtyMechanism: boolean;
  37297. /**
  37298. * Will flag all materials as dirty to trigger new shader compilation
  37299. * @param flag defines the flag used to specify which material part must be marked as dirty
  37300. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37301. */
  37302. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37303. /** @hidden */
  37304. _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;
  37305. /** @hidden */
  37306. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37307. /** @hidden */
  37308. _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;
  37309. /** @hidden */
  37310. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37311. /** @hidden */
  37312. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37313. /** @hidden */
  37314. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37315. }
  37316. }
  37317. declare module "babylonjs/assetContainer" {
  37318. import { AbstractScene } from "babylonjs/abstractScene";
  37319. import { Scene } from "babylonjs/scene";
  37320. import { Mesh } from "babylonjs/Meshes/mesh";
  37321. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37322. import { Skeleton } from "babylonjs/Bones/skeleton";
  37323. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37324. /**
  37325. * Set of assets to keep when moving a scene into an asset container.
  37326. */
  37327. export class KeepAssets extends AbstractScene {
  37328. }
  37329. /**
  37330. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37331. */
  37332. export class InstantiatedEntries {
  37333. /**
  37334. * List of new root nodes (eg. nodes with no parent)
  37335. */
  37336. rootNodes: TransformNode[];
  37337. /**
  37338. * List of new skeletons
  37339. */
  37340. skeletons: Skeleton[];
  37341. /**
  37342. * List of new animation groups
  37343. */
  37344. animationGroups: AnimationGroup[];
  37345. }
  37346. /**
  37347. * Container with a set of assets that can be added or removed from a scene.
  37348. */
  37349. export class AssetContainer extends AbstractScene {
  37350. /**
  37351. * The scene the AssetContainer belongs to.
  37352. */
  37353. scene: Scene;
  37354. /**
  37355. * Instantiates an AssetContainer.
  37356. * @param scene The scene the AssetContainer belongs to.
  37357. */
  37358. constructor(scene: Scene);
  37359. /**
  37360. * Instantiate or clone all meshes and add the new ones to the scene.
  37361. * Skeletons and animation groups will all be cloned
  37362. * @param nameFunction defines an optional function used to get new names for clones
  37363. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37364. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37365. */
  37366. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37367. /**
  37368. * Adds all the assets from the container to the scene.
  37369. */
  37370. addAllToScene(): void;
  37371. /**
  37372. * Removes all the assets in the container from the scene
  37373. */
  37374. removeAllFromScene(): void;
  37375. /**
  37376. * Disposes all the assets in the container
  37377. */
  37378. dispose(): void;
  37379. private _moveAssets;
  37380. /**
  37381. * Removes all the assets contained in the scene and adds them to the container.
  37382. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37383. */
  37384. moveAllFromScene(keepAssets?: KeepAssets): void;
  37385. /**
  37386. * 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.
  37387. * @returns the root mesh
  37388. */
  37389. createRootMesh(): Mesh;
  37390. }
  37391. }
  37392. declare module "babylonjs/abstractScene" {
  37393. import { Scene } from "babylonjs/scene";
  37394. import { Nullable } from "babylonjs/types";
  37395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37396. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37397. import { Geometry } from "babylonjs/Meshes/geometry";
  37398. import { Skeleton } from "babylonjs/Bones/skeleton";
  37399. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37400. import { AssetContainer } from "babylonjs/assetContainer";
  37401. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37402. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37404. import { Material } from "babylonjs/Materials/material";
  37405. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37406. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37407. import { Camera } from "babylonjs/Cameras/camera";
  37408. import { Light } from "babylonjs/Lights/light";
  37409. import { Node } from "babylonjs/node";
  37410. import { Animation } from "babylonjs/Animations/animation";
  37411. /**
  37412. * Defines how the parser contract is defined.
  37413. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37414. */
  37415. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37416. /**
  37417. * Defines how the individual parser contract is defined.
  37418. * These parser can parse an individual asset
  37419. */
  37420. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37421. /**
  37422. * Base class of the scene acting as a container for the different elements composing a scene.
  37423. * This class is dynamically extended by the different components of the scene increasing
  37424. * flexibility and reducing coupling
  37425. */
  37426. export abstract class AbstractScene {
  37427. /**
  37428. * Stores the list of available parsers in the application.
  37429. */
  37430. private static _BabylonFileParsers;
  37431. /**
  37432. * Stores the list of available individual parsers in the application.
  37433. */
  37434. private static _IndividualBabylonFileParsers;
  37435. /**
  37436. * Adds a parser in the list of available ones
  37437. * @param name Defines the name of the parser
  37438. * @param parser Defines the parser to add
  37439. */
  37440. static AddParser(name: string, parser: BabylonFileParser): void;
  37441. /**
  37442. * Gets a general parser from the list of avaialble ones
  37443. * @param name Defines the name of the parser
  37444. * @returns the requested parser or null
  37445. */
  37446. static GetParser(name: string): Nullable<BabylonFileParser>;
  37447. /**
  37448. * Adds n individual parser in the list of available ones
  37449. * @param name Defines the name of the parser
  37450. * @param parser Defines the parser to add
  37451. */
  37452. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37453. /**
  37454. * Gets an individual parser from the list of avaialble ones
  37455. * @param name Defines the name of the parser
  37456. * @returns the requested parser or null
  37457. */
  37458. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37459. /**
  37460. * Parser json data and populate both a scene and its associated container object
  37461. * @param jsonData Defines the data to parse
  37462. * @param scene Defines the scene to parse the data for
  37463. * @param container Defines the container attached to the parsing sequence
  37464. * @param rootUrl Defines the root url of the data
  37465. */
  37466. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37467. /**
  37468. * Gets the list of root nodes (ie. nodes with no parent)
  37469. */
  37470. rootNodes: Node[];
  37471. /** All of the cameras added to this scene
  37472. * @see http://doc.babylonjs.com/babylon101/cameras
  37473. */
  37474. cameras: Camera[];
  37475. /**
  37476. * All of the lights added to this scene
  37477. * @see http://doc.babylonjs.com/babylon101/lights
  37478. */
  37479. lights: Light[];
  37480. /**
  37481. * All of the (abstract) meshes added to this scene
  37482. */
  37483. meshes: AbstractMesh[];
  37484. /**
  37485. * The list of skeletons added to the scene
  37486. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37487. */
  37488. skeletons: Skeleton[];
  37489. /**
  37490. * All of the particle systems added to this scene
  37491. * @see http://doc.babylonjs.com/babylon101/particles
  37492. */
  37493. particleSystems: IParticleSystem[];
  37494. /**
  37495. * Gets a list of Animations associated with the scene
  37496. */
  37497. animations: Animation[];
  37498. /**
  37499. * All of the animation groups added to this scene
  37500. * @see http://doc.babylonjs.com/how_to/group
  37501. */
  37502. animationGroups: AnimationGroup[];
  37503. /**
  37504. * All of the multi-materials added to this scene
  37505. * @see http://doc.babylonjs.com/how_to/multi_materials
  37506. */
  37507. multiMaterials: MultiMaterial[];
  37508. /**
  37509. * All of the materials added to this scene
  37510. * In the context of a Scene, it is not supposed to be modified manually.
  37511. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37512. * Note also that the order of the Material within the array is not significant and might change.
  37513. * @see http://doc.babylonjs.com/babylon101/materials
  37514. */
  37515. materials: Material[];
  37516. /**
  37517. * The list of morph target managers added to the scene
  37518. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37519. */
  37520. morphTargetManagers: MorphTargetManager[];
  37521. /**
  37522. * The list of geometries used in the scene.
  37523. */
  37524. geometries: Geometry[];
  37525. /**
  37526. * All of the tranform nodes added to this scene
  37527. * In the context of a Scene, it is not supposed to be modified manually.
  37528. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37529. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37530. * @see http://doc.babylonjs.com/how_to/transformnode
  37531. */
  37532. transformNodes: TransformNode[];
  37533. /**
  37534. * ActionManagers available on the scene.
  37535. */
  37536. actionManagers: AbstractActionManager[];
  37537. /**
  37538. * Textures to keep.
  37539. */
  37540. textures: BaseTexture[];
  37541. /**
  37542. * Environment texture for the scene
  37543. */
  37544. environmentTexture: Nullable<BaseTexture>;
  37545. }
  37546. }
  37547. declare module "babylonjs/Audio/sound" {
  37548. import { Observable } from "babylonjs/Misc/observable";
  37549. import { Vector3 } from "babylonjs/Maths/math.vector";
  37550. import { Nullable } from "babylonjs/types";
  37551. import { Scene } from "babylonjs/scene";
  37552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37553. /**
  37554. * Interface used to define options for Sound class
  37555. */
  37556. export interface ISoundOptions {
  37557. /**
  37558. * Does the sound autoplay once loaded.
  37559. */
  37560. autoplay?: boolean;
  37561. /**
  37562. * Does the sound loop after it finishes playing once.
  37563. */
  37564. loop?: boolean;
  37565. /**
  37566. * Sound's volume
  37567. */
  37568. volume?: number;
  37569. /**
  37570. * Is it a spatial sound?
  37571. */
  37572. spatialSound?: boolean;
  37573. /**
  37574. * Maximum distance to hear that sound
  37575. */
  37576. maxDistance?: number;
  37577. /**
  37578. * Uses user defined attenuation function
  37579. */
  37580. useCustomAttenuation?: boolean;
  37581. /**
  37582. * Define the roll off factor of spatial sounds.
  37583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37584. */
  37585. rolloffFactor?: number;
  37586. /**
  37587. * Define the reference distance the sound should be heard perfectly.
  37588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37589. */
  37590. refDistance?: number;
  37591. /**
  37592. * Define the distance attenuation model the sound will follow.
  37593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37594. */
  37595. distanceModel?: string;
  37596. /**
  37597. * Defines the playback speed (1 by default)
  37598. */
  37599. playbackRate?: number;
  37600. /**
  37601. * Defines if the sound is from a streaming source
  37602. */
  37603. streaming?: boolean;
  37604. /**
  37605. * Defines an optional length (in seconds) inside the sound file
  37606. */
  37607. length?: number;
  37608. /**
  37609. * Defines an optional offset (in seconds) inside the sound file
  37610. */
  37611. offset?: number;
  37612. /**
  37613. * If true, URLs will not be required to state the audio file codec to use.
  37614. */
  37615. skipCodecCheck?: boolean;
  37616. }
  37617. /**
  37618. * Defines a sound that can be played in the application.
  37619. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37620. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37621. */
  37622. export class Sound {
  37623. /**
  37624. * The name of the sound in the scene.
  37625. */
  37626. name: string;
  37627. /**
  37628. * Does the sound autoplay once loaded.
  37629. */
  37630. autoplay: boolean;
  37631. /**
  37632. * Does the sound loop after it finishes playing once.
  37633. */
  37634. loop: boolean;
  37635. /**
  37636. * Does the sound use a custom attenuation curve to simulate the falloff
  37637. * happening when the source gets further away from the camera.
  37638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37639. */
  37640. useCustomAttenuation: boolean;
  37641. /**
  37642. * The sound track id this sound belongs to.
  37643. */
  37644. soundTrackId: number;
  37645. /**
  37646. * Is this sound currently played.
  37647. */
  37648. isPlaying: boolean;
  37649. /**
  37650. * Is this sound currently paused.
  37651. */
  37652. isPaused: boolean;
  37653. /**
  37654. * Does this sound enables spatial sound.
  37655. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37656. */
  37657. spatialSound: boolean;
  37658. /**
  37659. * Define the reference distance the sound should be heard perfectly.
  37660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37661. */
  37662. refDistance: number;
  37663. /**
  37664. * Define the roll off factor of spatial sounds.
  37665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37666. */
  37667. rolloffFactor: number;
  37668. /**
  37669. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37671. */
  37672. maxDistance: number;
  37673. /**
  37674. * Define the distance attenuation model the sound will follow.
  37675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37676. */
  37677. distanceModel: string;
  37678. /**
  37679. * @hidden
  37680. * Back Compat
  37681. **/
  37682. onended: () => any;
  37683. /**
  37684. * Observable event when the current playing sound finishes.
  37685. */
  37686. onEndedObservable: Observable<Sound>;
  37687. private _panningModel;
  37688. private _playbackRate;
  37689. private _streaming;
  37690. private _startTime;
  37691. private _startOffset;
  37692. private _position;
  37693. /** @hidden */
  37694. _positionInEmitterSpace: boolean;
  37695. private _localDirection;
  37696. private _volume;
  37697. private _isReadyToPlay;
  37698. private _isDirectional;
  37699. private _readyToPlayCallback;
  37700. private _audioBuffer;
  37701. private _soundSource;
  37702. private _streamingSource;
  37703. private _soundPanner;
  37704. private _soundGain;
  37705. private _inputAudioNode;
  37706. private _outputAudioNode;
  37707. private _coneInnerAngle;
  37708. private _coneOuterAngle;
  37709. private _coneOuterGain;
  37710. private _scene;
  37711. private _connectedTransformNode;
  37712. private _customAttenuationFunction;
  37713. private _registerFunc;
  37714. private _isOutputConnected;
  37715. private _htmlAudioElement;
  37716. private _urlType;
  37717. private _length?;
  37718. private _offset?;
  37719. /** @hidden */
  37720. static _SceneComponentInitialization: (scene: Scene) => void;
  37721. /**
  37722. * Create a sound and attach it to a scene
  37723. * @param name Name of your sound
  37724. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37725. * @param scene defines the scene the sound belongs to
  37726. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37727. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37728. */
  37729. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37730. /**
  37731. * Release the sound and its associated resources
  37732. */
  37733. dispose(): void;
  37734. /**
  37735. * Gets if the sounds is ready to be played or not.
  37736. * @returns true if ready, otherwise false
  37737. */
  37738. isReady(): boolean;
  37739. private _soundLoaded;
  37740. /**
  37741. * Sets the data of the sound from an audiobuffer
  37742. * @param audioBuffer The audioBuffer containing the data
  37743. */
  37744. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37745. /**
  37746. * Updates the current sounds options such as maxdistance, loop...
  37747. * @param options A JSON object containing values named as the object properties
  37748. */
  37749. updateOptions(options: ISoundOptions): void;
  37750. private _createSpatialParameters;
  37751. private _updateSpatialParameters;
  37752. /**
  37753. * Switch the panning model to HRTF:
  37754. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37756. */
  37757. switchPanningModelToHRTF(): void;
  37758. /**
  37759. * Switch the panning model to Equal Power:
  37760. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37762. */
  37763. switchPanningModelToEqualPower(): void;
  37764. private _switchPanningModel;
  37765. /**
  37766. * Connect this sound to a sound track audio node like gain...
  37767. * @param soundTrackAudioNode the sound track audio node to connect to
  37768. */
  37769. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37770. /**
  37771. * Transform this sound into a directional source
  37772. * @param coneInnerAngle Size of the inner cone in degree
  37773. * @param coneOuterAngle Size of the outer cone in degree
  37774. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37775. */
  37776. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37777. /**
  37778. * Gets or sets the inner angle for the directional cone.
  37779. */
  37780. /**
  37781. * Gets or sets the inner angle for the directional cone.
  37782. */
  37783. directionalConeInnerAngle: number;
  37784. /**
  37785. * Gets or sets the outer angle for the directional cone.
  37786. */
  37787. /**
  37788. * Gets or sets the outer angle for the directional cone.
  37789. */
  37790. directionalConeOuterAngle: number;
  37791. /**
  37792. * Sets the position of the emitter if spatial sound is enabled
  37793. * @param newPosition Defines the new posisiton
  37794. */
  37795. setPosition(newPosition: Vector3): void;
  37796. /**
  37797. * Sets the local direction of the emitter if spatial sound is enabled
  37798. * @param newLocalDirection Defines the new local direction
  37799. */
  37800. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37801. private _updateDirection;
  37802. /** @hidden */
  37803. updateDistanceFromListener(): void;
  37804. /**
  37805. * Sets a new custom attenuation function for the sound.
  37806. * @param callback Defines the function used for the attenuation
  37807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37808. */
  37809. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37810. /**
  37811. * Play the sound
  37812. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37813. * @param offset (optional) Start the sound at a specific time in seconds
  37814. * @param length (optional) Sound duration (in seconds)
  37815. */
  37816. play(time?: number, offset?: number, length?: number): void;
  37817. private _onended;
  37818. /**
  37819. * Stop the sound
  37820. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37821. */
  37822. stop(time?: number): void;
  37823. /**
  37824. * Put the sound in pause
  37825. */
  37826. pause(): void;
  37827. /**
  37828. * Sets a dedicated volume for this sounds
  37829. * @param newVolume Define the new volume of the sound
  37830. * @param time Define time for gradual change to new volume
  37831. */
  37832. setVolume(newVolume: number, time?: number): void;
  37833. /**
  37834. * Set the sound play back rate
  37835. * @param newPlaybackRate Define the playback rate the sound should be played at
  37836. */
  37837. setPlaybackRate(newPlaybackRate: number): void;
  37838. /**
  37839. * Gets the volume of the sound.
  37840. * @returns the volume of the sound
  37841. */
  37842. getVolume(): number;
  37843. /**
  37844. * Attach the sound to a dedicated mesh
  37845. * @param transformNode The transform node to connect the sound with
  37846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37847. */
  37848. attachToMesh(transformNode: TransformNode): void;
  37849. /**
  37850. * Detach the sound from the previously attached mesh
  37851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37852. */
  37853. detachFromMesh(): void;
  37854. private _onRegisterAfterWorldMatrixUpdate;
  37855. /**
  37856. * Clone the current sound in the scene.
  37857. * @returns the new sound clone
  37858. */
  37859. clone(): Nullable<Sound>;
  37860. /**
  37861. * Gets the current underlying audio buffer containing the data
  37862. * @returns the audio buffer
  37863. */
  37864. getAudioBuffer(): Nullable<AudioBuffer>;
  37865. /**
  37866. * Serializes the Sound in a JSON representation
  37867. * @returns the JSON representation of the sound
  37868. */
  37869. serialize(): any;
  37870. /**
  37871. * Parse a JSON representation of a sound to innstantiate in a given scene
  37872. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37873. * @param scene Define the scene the new parsed sound should be created in
  37874. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37875. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37876. * @returns the newly parsed sound
  37877. */
  37878. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37879. }
  37880. }
  37881. declare module "babylonjs/Actions/directAudioActions" {
  37882. import { Action } from "babylonjs/Actions/action";
  37883. import { Condition } from "babylonjs/Actions/condition";
  37884. import { Sound } from "babylonjs/Audio/sound";
  37885. /**
  37886. * This defines an action helpful to play a defined sound on a triggered action.
  37887. */
  37888. export class PlaySoundAction extends Action {
  37889. private _sound;
  37890. /**
  37891. * Instantiate the action
  37892. * @param triggerOptions defines the trigger options
  37893. * @param sound defines the sound to play
  37894. * @param condition defines the trigger related conditions
  37895. */
  37896. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37897. /** @hidden */
  37898. _prepare(): void;
  37899. /**
  37900. * Execute the action and play the sound.
  37901. */
  37902. execute(): void;
  37903. /**
  37904. * Serializes the actions and its related information.
  37905. * @param parent defines the object to serialize in
  37906. * @returns the serialized object
  37907. */
  37908. serialize(parent: any): any;
  37909. }
  37910. /**
  37911. * This defines an action helpful to stop a defined sound on a triggered action.
  37912. */
  37913. export class StopSoundAction extends Action {
  37914. private _sound;
  37915. /**
  37916. * Instantiate the action
  37917. * @param triggerOptions defines the trigger options
  37918. * @param sound defines the sound to stop
  37919. * @param condition defines the trigger related conditions
  37920. */
  37921. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37922. /** @hidden */
  37923. _prepare(): void;
  37924. /**
  37925. * Execute the action and stop the sound.
  37926. */
  37927. execute(): void;
  37928. /**
  37929. * Serializes the actions and its related information.
  37930. * @param parent defines the object to serialize in
  37931. * @returns the serialized object
  37932. */
  37933. serialize(parent: any): any;
  37934. }
  37935. }
  37936. declare module "babylonjs/Actions/interpolateValueAction" {
  37937. import { Action } from "babylonjs/Actions/action";
  37938. import { Condition } from "babylonjs/Actions/condition";
  37939. import { Observable } from "babylonjs/Misc/observable";
  37940. /**
  37941. * This defines an action responsible to change the value of a property
  37942. * by interpolating between its current value and the newly set one once triggered.
  37943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37944. */
  37945. export class InterpolateValueAction extends Action {
  37946. /**
  37947. * Defines the path of the property where the value should be interpolated
  37948. */
  37949. propertyPath: string;
  37950. /**
  37951. * Defines the target value at the end of the interpolation.
  37952. */
  37953. value: any;
  37954. /**
  37955. * Defines the time it will take for the property to interpolate to the value.
  37956. */
  37957. duration: number;
  37958. /**
  37959. * Defines if the other scene animations should be stopped when the action has been triggered
  37960. */
  37961. stopOtherAnimations?: boolean;
  37962. /**
  37963. * Defines a callback raised once the interpolation animation has been done.
  37964. */
  37965. onInterpolationDone?: () => void;
  37966. /**
  37967. * Observable triggered once the interpolation animation has been done.
  37968. */
  37969. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37970. private _target;
  37971. private _effectiveTarget;
  37972. private _property;
  37973. /**
  37974. * Instantiate the action
  37975. * @param triggerOptions defines the trigger options
  37976. * @param target defines the object containing the value to interpolate
  37977. * @param propertyPath defines the path to the property in the target object
  37978. * @param value defines the target value at the end of the interpolation
  37979. * @param duration deines the time it will take for the property to interpolate to the value.
  37980. * @param condition defines the trigger related conditions
  37981. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37982. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37983. */
  37984. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37985. /** @hidden */
  37986. _prepare(): void;
  37987. /**
  37988. * Execute the action starts the value interpolation.
  37989. */
  37990. execute(): void;
  37991. /**
  37992. * Serializes the actions and its related information.
  37993. * @param parent defines the object to serialize in
  37994. * @returns the serialized object
  37995. */
  37996. serialize(parent: any): any;
  37997. }
  37998. }
  37999. declare module "babylonjs/Actions/index" {
  38000. export * from "babylonjs/Actions/abstractActionManager";
  38001. export * from "babylonjs/Actions/action";
  38002. export * from "babylonjs/Actions/actionEvent";
  38003. export * from "babylonjs/Actions/actionManager";
  38004. export * from "babylonjs/Actions/condition";
  38005. export * from "babylonjs/Actions/directActions";
  38006. export * from "babylonjs/Actions/directAudioActions";
  38007. export * from "babylonjs/Actions/interpolateValueAction";
  38008. }
  38009. declare module "babylonjs/Animations/index" {
  38010. export * from "babylonjs/Animations/animatable";
  38011. export * from "babylonjs/Animations/animation";
  38012. export * from "babylonjs/Animations/animationGroup";
  38013. export * from "babylonjs/Animations/animationPropertiesOverride";
  38014. export * from "babylonjs/Animations/easing";
  38015. export * from "babylonjs/Animations/runtimeAnimation";
  38016. export * from "babylonjs/Animations/animationEvent";
  38017. export * from "babylonjs/Animations/animationGroup";
  38018. export * from "babylonjs/Animations/animationKey";
  38019. export * from "babylonjs/Animations/animationRange";
  38020. export * from "babylonjs/Animations/animatable.interface";
  38021. }
  38022. declare module "babylonjs/Audio/soundTrack" {
  38023. import { Sound } from "babylonjs/Audio/sound";
  38024. import { Analyser } from "babylonjs/Audio/analyser";
  38025. import { Scene } from "babylonjs/scene";
  38026. /**
  38027. * Options allowed during the creation of a sound track.
  38028. */
  38029. export interface ISoundTrackOptions {
  38030. /**
  38031. * The volume the sound track should take during creation
  38032. */
  38033. volume?: number;
  38034. /**
  38035. * Define if the sound track is the main sound track of the scene
  38036. */
  38037. mainTrack?: boolean;
  38038. }
  38039. /**
  38040. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38041. * It will be also used in a future release to apply effects on a specific track.
  38042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38043. */
  38044. export class SoundTrack {
  38045. /**
  38046. * The unique identifier of the sound track in the scene.
  38047. */
  38048. id: number;
  38049. /**
  38050. * The list of sounds included in the sound track.
  38051. */
  38052. soundCollection: Array<Sound>;
  38053. private _outputAudioNode;
  38054. private _scene;
  38055. private _connectedAnalyser;
  38056. private _options;
  38057. private _isInitialized;
  38058. /**
  38059. * Creates a new sound track.
  38060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38061. * @param scene Define the scene the sound track belongs to
  38062. * @param options
  38063. */
  38064. constructor(scene: Scene, options?: ISoundTrackOptions);
  38065. private _initializeSoundTrackAudioGraph;
  38066. /**
  38067. * Release the sound track and its associated resources
  38068. */
  38069. dispose(): void;
  38070. /**
  38071. * Adds a sound to this sound track
  38072. * @param sound define the cound to add
  38073. * @ignoreNaming
  38074. */
  38075. AddSound(sound: Sound): void;
  38076. /**
  38077. * Removes a sound to this sound track
  38078. * @param sound define the cound to remove
  38079. * @ignoreNaming
  38080. */
  38081. RemoveSound(sound: Sound): void;
  38082. /**
  38083. * Set a global volume for the full sound track.
  38084. * @param newVolume Define the new volume of the sound track
  38085. */
  38086. setVolume(newVolume: number): void;
  38087. /**
  38088. * Switch the panning model to HRTF:
  38089. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38091. */
  38092. switchPanningModelToHRTF(): void;
  38093. /**
  38094. * Switch the panning model to Equal Power:
  38095. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38097. */
  38098. switchPanningModelToEqualPower(): void;
  38099. /**
  38100. * Connect the sound track to an audio analyser allowing some amazing
  38101. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38103. * @param analyser The analyser to connect to the engine
  38104. */
  38105. connectToAnalyser(analyser: Analyser): void;
  38106. }
  38107. }
  38108. declare module "babylonjs/Audio/audioSceneComponent" {
  38109. import { Sound } from "babylonjs/Audio/sound";
  38110. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38111. import { Nullable } from "babylonjs/types";
  38112. import { Vector3 } from "babylonjs/Maths/math.vector";
  38113. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38114. import { Scene } from "babylonjs/scene";
  38115. import { AbstractScene } from "babylonjs/abstractScene";
  38116. import "babylonjs/Audio/audioEngine";
  38117. module "babylonjs/abstractScene" {
  38118. interface AbstractScene {
  38119. /**
  38120. * The list of sounds used in the scene.
  38121. */
  38122. sounds: Nullable<Array<Sound>>;
  38123. }
  38124. }
  38125. module "babylonjs/scene" {
  38126. interface Scene {
  38127. /**
  38128. * @hidden
  38129. * Backing field
  38130. */
  38131. _mainSoundTrack: SoundTrack;
  38132. /**
  38133. * The main sound track played by the scene.
  38134. * It cotains your primary collection of sounds.
  38135. */
  38136. mainSoundTrack: SoundTrack;
  38137. /**
  38138. * The list of sound tracks added to the scene
  38139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38140. */
  38141. soundTracks: Nullable<Array<SoundTrack>>;
  38142. /**
  38143. * Gets a sound using a given name
  38144. * @param name defines the name to search for
  38145. * @return the found sound or null if not found at all.
  38146. */
  38147. getSoundByName(name: string): Nullable<Sound>;
  38148. /**
  38149. * Gets or sets if audio support is enabled
  38150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38151. */
  38152. audioEnabled: boolean;
  38153. /**
  38154. * Gets or sets if audio will be output to headphones
  38155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38156. */
  38157. headphone: boolean;
  38158. /**
  38159. * Gets or sets custom audio listener position provider
  38160. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38161. */
  38162. audioListenerPositionProvider: Nullable<() => Vector3>;
  38163. /**
  38164. * Gets or sets a refresh rate when using 3D audio positioning
  38165. */
  38166. audioPositioningRefreshRate: number;
  38167. }
  38168. }
  38169. /**
  38170. * Defines the sound scene component responsible to manage any sounds
  38171. * in a given scene.
  38172. */
  38173. export class AudioSceneComponent implements ISceneSerializableComponent {
  38174. /**
  38175. * The component name helpfull to identify the component in the list of scene components.
  38176. */
  38177. readonly name: string;
  38178. /**
  38179. * The scene the component belongs to.
  38180. */
  38181. scene: Scene;
  38182. private _audioEnabled;
  38183. /**
  38184. * Gets whether audio is enabled or not.
  38185. * Please use related enable/disable method to switch state.
  38186. */
  38187. readonly audioEnabled: boolean;
  38188. private _headphone;
  38189. /**
  38190. * Gets whether audio is outputing to headphone or not.
  38191. * Please use the according Switch methods to change output.
  38192. */
  38193. readonly headphone: boolean;
  38194. /**
  38195. * Gets or sets a refresh rate when using 3D audio positioning
  38196. */
  38197. audioPositioningRefreshRate: number;
  38198. private _audioListenerPositionProvider;
  38199. /**
  38200. * Gets the current audio listener position provider
  38201. */
  38202. /**
  38203. * Sets a custom listener position for all sounds in the scene
  38204. * By default, this is the position of the first active camera
  38205. */
  38206. audioListenerPositionProvider: Nullable<() => Vector3>;
  38207. /**
  38208. * Creates a new instance of the component for the given scene
  38209. * @param scene Defines the scene to register the component in
  38210. */
  38211. constructor(scene: Scene);
  38212. /**
  38213. * Registers the component in a given scene
  38214. */
  38215. register(): void;
  38216. /**
  38217. * Rebuilds the elements related to this component in case of
  38218. * context lost for instance.
  38219. */
  38220. rebuild(): void;
  38221. /**
  38222. * Serializes the component data to the specified json object
  38223. * @param serializationObject The object to serialize to
  38224. */
  38225. serialize(serializationObject: any): void;
  38226. /**
  38227. * Adds all the elements from the container to the scene
  38228. * @param container the container holding the elements
  38229. */
  38230. addFromContainer(container: AbstractScene): void;
  38231. /**
  38232. * Removes all the elements in the container from the scene
  38233. * @param container contains the elements to remove
  38234. * @param dispose if the removed element should be disposed (default: false)
  38235. */
  38236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38237. /**
  38238. * Disposes the component and the associated ressources.
  38239. */
  38240. dispose(): void;
  38241. /**
  38242. * Disables audio in the associated scene.
  38243. */
  38244. disableAudio(): void;
  38245. /**
  38246. * Enables audio in the associated scene.
  38247. */
  38248. enableAudio(): void;
  38249. /**
  38250. * Switch audio to headphone output.
  38251. */
  38252. switchAudioModeForHeadphones(): void;
  38253. /**
  38254. * Switch audio to normal speakers.
  38255. */
  38256. switchAudioModeForNormalSpeakers(): void;
  38257. private _cachedCameraDirection;
  38258. private _cachedCameraPosition;
  38259. private _lastCheck;
  38260. private _afterRender;
  38261. }
  38262. }
  38263. declare module "babylonjs/Audio/weightedsound" {
  38264. import { Sound } from "babylonjs/Audio/sound";
  38265. /**
  38266. * Wraps one or more Sound objects and selects one with random weight for playback.
  38267. */
  38268. export class WeightedSound {
  38269. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38270. loop: boolean;
  38271. private _coneInnerAngle;
  38272. private _coneOuterAngle;
  38273. private _volume;
  38274. /** A Sound is currently playing. */
  38275. isPlaying: boolean;
  38276. /** A Sound is currently paused. */
  38277. isPaused: boolean;
  38278. private _sounds;
  38279. private _weights;
  38280. private _currentIndex?;
  38281. /**
  38282. * Creates a new WeightedSound from the list of sounds given.
  38283. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38284. * @param sounds Array of Sounds that will be selected from.
  38285. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38286. */
  38287. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38288. /**
  38289. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38290. */
  38291. /**
  38292. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38293. */
  38294. directionalConeInnerAngle: number;
  38295. /**
  38296. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38297. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38298. */
  38299. /**
  38300. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38301. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38302. */
  38303. directionalConeOuterAngle: number;
  38304. /**
  38305. * Playback volume.
  38306. */
  38307. /**
  38308. * Playback volume.
  38309. */
  38310. volume: number;
  38311. private _onended;
  38312. /**
  38313. * Suspend playback
  38314. */
  38315. pause(): void;
  38316. /**
  38317. * Stop playback
  38318. */
  38319. stop(): void;
  38320. /**
  38321. * Start playback.
  38322. * @param startOffset Position the clip head at a specific time in seconds.
  38323. */
  38324. play(startOffset?: number): void;
  38325. }
  38326. }
  38327. declare module "babylonjs/Audio/index" {
  38328. export * from "babylonjs/Audio/analyser";
  38329. export * from "babylonjs/Audio/audioEngine";
  38330. export * from "babylonjs/Audio/audioSceneComponent";
  38331. export * from "babylonjs/Audio/sound";
  38332. export * from "babylonjs/Audio/soundTrack";
  38333. export * from "babylonjs/Audio/weightedsound";
  38334. }
  38335. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38336. import { Behavior } from "babylonjs/Behaviors/behavior";
  38337. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38338. import { BackEase } from "babylonjs/Animations/easing";
  38339. /**
  38340. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38341. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38342. */
  38343. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38344. /**
  38345. * Gets the name of the behavior.
  38346. */
  38347. readonly name: string;
  38348. /**
  38349. * The easing function used by animations
  38350. */
  38351. static EasingFunction: BackEase;
  38352. /**
  38353. * The easing mode used by animations
  38354. */
  38355. static EasingMode: number;
  38356. /**
  38357. * The duration of the animation, in milliseconds
  38358. */
  38359. transitionDuration: number;
  38360. /**
  38361. * Length of the distance animated by the transition when lower radius is reached
  38362. */
  38363. lowerRadiusTransitionRange: number;
  38364. /**
  38365. * Length of the distance animated by the transition when upper radius is reached
  38366. */
  38367. upperRadiusTransitionRange: number;
  38368. private _autoTransitionRange;
  38369. /**
  38370. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38371. */
  38372. /**
  38373. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38374. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38375. */
  38376. autoTransitionRange: boolean;
  38377. private _attachedCamera;
  38378. private _onAfterCheckInputsObserver;
  38379. private _onMeshTargetChangedObserver;
  38380. /**
  38381. * Initializes the behavior.
  38382. */
  38383. init(): void;
  38384. /**
  38385. * Attaches the behavior to its arc rotate camera.
  38386. * @param camera Defines the camera to attach the behavior to
  38387. */
  38388. attach(camera: ArcRotateCamera): void;
  38389. /**
  38390. * Detaches the behavior from its current arc rotate camera.
  38391. */
  38392. detach(): void;
  38393. private _radiusIsAnimating;
  38394. private _radiusBounceTransition;
  38395. private _animatables;
  38396. private _cachedWheelPrecision;
  38397. /**
  38398. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38399. * @param radiusLimit The limit to check against.
  38400. * @return Bool to indicate if at limit.
  38401. */
  38402. private _isRadiusAtLimit;
  38403. /**
  38404. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38405. * @param radiusDelta The delta by which to animate to. Can be negative.
  38406. */
  38407. private _applyBoundRadiusAnimation;
  38408. /**
  38409. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38410. */
  38411. protected _clearAnimationLocks(): void;
  38412. /**
  38413. * Stops and removes all animations that have been applied to the camera
  38414. */
  38415. stopAllAnimations(): void;
  38416. }
  38417. }
  38418. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38419. import { Behavior } from "babylonjs/Behaviors/behavior";
  38420. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38421. import { ExponentialEase } from "babylonjs/Animations/easing";
  38422. import { Nullable } from "babylonjs/types";
  38423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38424. import { Vector3 } from "babylonjs/Maths/math.vector";
  38425. /**
  38426. * 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.
  38427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38428. */
  38429. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38430. /**
  38431. * Gets the name of the behavior.
  38432. */
  38433. readonly name: string;
  38434. private _mode;
  38435. private _radiusScale;
  38436. private _positionScale;
  38437. private _defaultElevation;
  38438. private _elevationReturnTime;
  38439. private _elevationReturnWaitTime;
  38440. private _zoomStopsAnimation;
  38441. private _framingTime;
  38442. /**
  38443. * The easing function used by animations
  38444. */
  38445. static EasingFunction: ExponentialEase;
  38446. /**
  38447. * The easing mode used by animations
  38448. */
  38449. static EasingMode: number;
  38450. /**
  38451. * Sets the current mode used by the behavior
  38452. */
  38453. /**
  38454. * Gets current mode used by the behavior.
  38455. */
  38456. mode: number;
  38457. /**
  38458. * Sets the scale applied to the radius (1 by default)
  38459. */
  38460. /**
  38461. * Gets the scale applied to the radius
  38462. */
  38463. radiusScale: number;
  38464. /**
  38465. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38466. */
  38467. /**
  38468. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38469. */
  38470. positionScale: number;
  38471. /**
  38472. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38473. * behaviour is triggered, in radians.
  38474. */
  38475. /**
  38476. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38477. * behaviour is triggered, in radians.
  38478. */
  38479. defaultElevation: number;
  38480. /**
  38481. * Sets the time (in milliseconds) taken to return to the default beta position.
  38482. * Negative value indicates camera should not return to default.
  38483. */
  38484. /**
  38485. * Gets the time (in milliseconds) taken to return to the default beta position.
  38486. * Negative value indicates camera should not return to default.
  38487. */
  38488. elevationReturnTime: number;
  38489. /**
  38490. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38491. */
  38492. /**
  38493. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38494. */
  38495. elevationReturnWaitTime: number;
  38496. /**
  38497. * Sets the flag that indicates if user zooming should stop animation.
  38498. */
  38499. /**
  38500. * Gets the flag that indicates if user zooming should stop animation.
  38501. */
  38502. zoomStopsAnimation: boolean;
  38503. /**
  38504. * Sets the transition time when framing the mesh, in milliseconds
  38505. */
  38506. /**
  38507. * Gets the transition time when framing the mesh, in milliseconds
  38508. */
  38509. framingTime: number;
  38510. /**
  38511. * Define if the behavior should automatically change the configured
  38512. * camera limits and sensibilities.
  38513. */
  38514. autoCorrectCameraLimitsAndSensibility: boolean;
  38515. private _onPrePointerObservableObserver;
  38516. private _onAfterCheckInputsObserver;
  38517. private _onMeshTargetChangedObserver;
  38518. private _attachedCamera;
  38519. private _isPointerDown;
  38520. private _lastInteractionTime;
  38521. /**
  38522. * Initializes the behavior.
  38523. */
  38524. init(): void;
  38525. /**
  38526. * Attaches the behavior to its arc rotate camera.
  38527. * @param camera Defines the camera to attach the behavior to
  38528. */
  38529. attach(camera: ArcRotateCamera): void;
  38530. /**
  38531. * Detaches the behavior from its current arc rotate camera.
  38532. */
  38533. detach(): void;
  38534. private _animatables;
  38535. private _betaIsAnimating;
  38536. private _betaTransition;
  38537. private _radiusTransition;
  38538. private _vectorTransition;
  38539. /**
  38540. * Targets the given mesh and updates zoom level accordingly.
  38541. * @param mesh The mesh to target.
  38542. * @param radius Optional. If a cached radius position already exists, overrides default.
  38543. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38546. */
  38547. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38548. /**
  38549. * Targets the given mesh with its children and updates zoom level accordingly.
  38550. * @param mesh The mesh to target.
  38551. * @param radius Optional. If a cached radius position already exists, overrides default.
  38552. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38555. */
  38556. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38557. /**
  38558. * Targets the given meshes with their children and updates zoom level accordingly.
  38559. * @param meshes The mesh to target.
  38560. * @param radius Optional. If a cached radius position already exists, overrides default.
  38561. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38562. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38563. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38564. */
  38565. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38566. /**
  38567. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38568. * @param minimumWorld Determines the smaller position of the bounding box extend
  38569. * @param maximumWorld Determines the bigger position of the bounding box extend
  38570. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38571. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38572. */
  38573. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38574. /**
  38575. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38576. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38577. * frustum width.
  38578. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38579. * to fully enclose the mesh in the viewing frustum.
  38580. */
  38581. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38582. /**
  38583. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38584. * is automatically returned to its default position (expected to be above ground plane).
  38585. */
  38586. private _maintainCameraAboveGround;
  38587. /**
  38588. * Returns the frustum slope based on the canvas ratio and camera FOV
  38589. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38590. */
  38591. private _getFrustumSlope;
  38592. /**
  38593. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38594. */
  38595. private _clearAnimationLocks;
  38596. /**
  38597. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38598. */
  38599. private _applyUserInteraction;
  38600. /**
  38601. * Stops and removes all animations that have been applied to the camera
  38602. */
  38603. stopAllAnimations(): void;
  38604. /**
  38605. * Gets a value indicating if the user is moving the camera
  38606. */
  38607. readonly isUserIsMoving: boolean;
  38608. /**
  38609. * The camera can move all the way towards the mesh.
  38610. */
  38611. static IgnoreBoundsSizeMode: number;
  38612. /**
  38613. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38614. */
  38615. static FitFrustumSidesMode: number;
  38616. }
  38617. }
  38618. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38619. import { Nullable } from "babylonjs/types";
  38620. import { Camera } from "babylonjs/Cameras/camera";
  38621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38622. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38623. /**
  38624. * Base class for Camera Pointer Inputs.
  38625. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38626. * for example usage.
  38627. */
  38628. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38629. /**
  38630. * Defines the camera the input is attached to.
  38631. */
  38632. abstract camera: Camera;
  38633. /**
  38634. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38635. */
  38636. protected _altKey: boolean;
  38637. protected _ctrlKey: boolean;
  38638. protected _metaKey: boolean;
  38639. protected _shiftKey: boolean;
  38640. /**
  38641. * Which mouse buttons were pressed at time of last mouse event.
  38642. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38643. */
  38644. protected _buttonsPressed: number;
  38645. /**
  38646. * Defines the buttons associated with the input to handle camera move.
  38647. */
  38648. buttons: number[];
  38649. /**
  38650. * Attach the input controls to a specific dom element to get the input from.
  38651. * @param element Defines the element the controls should be listened from
  38652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38653. */
  38654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38655. /**
  38656. * Detach the current controls from the specified dom element.
  38657. * @param element Defines the element to stop listening the inputs from
  38658. */
  38659. detachControl(element: Nullable<HTMLElement>): void;
  38660. /**
  38661. * Gets the class name of the current input.
  38662. * @returns the class name
  38663. */
  38664. getClassName(): string;
  38665. /**
  38666. * Get the friendly name associated with the input class.
  38667. * @returns the input friendly name
  38668. */
  38669. getSimpleName(): string;
  38670. /**
  38671. * Called on pointer POINTERDOUBLETAP event.
  38672. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38673. */
  38674. protected onDoubleTap(type: string): void;
  38675. /**
  38676. * Called on pointer POINTERMOVE event if only a single touch is active.
  38677. * Override this method to provide functionality.
  38678. */
  38679. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38680. /**
  38681. * Called on pointer POINTERMOVE event if multiple touches are active.
  38682. * Override this method to provide functionality.
  38683. */
  38684. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38685. /**
  38686. * Called on JS contextmenu event.
  38687. * Override this method to provide functionality.
  38688. */
  38689. protected onContextMenu(evt: PointerEvent): void;
  38690. /**
  38691. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38692. * press.
  38693. * Override this method to provide functionality.
  38694. */
  38695. protected onButtonDown(evt: PointerEvent): void;
  38696. /**
  38697. * Called each time a new POINTERUP event occurs. Ie, for each button
  38698. * release.
  38699. * Override this method to provide functionality.
  38700. */
  38701. protected onButtonUp(evt: PointerEvent): void;
  38702. /**
  38703. * Called when window becomes inactive.
  38704. * Override this method to provide functionality.
  38705. */
  38706. protected onLostFocus(): void;
  38707. private _pointerInput;
  38708. private _observer;
  38709. private _onLostFocus;
  38710. private pointA;
  38711. private pointB;
  38712. }
  38713. }
  38714. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38715. import { Nullable } from "babylonjs/types";
  38716. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38717. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38718. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38719. /**
  38720. * Manage the pointers inputs to control an arc rotate camera.
  38721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38722. */
  38723. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38724. /**
  38725. * Defines the camera the input is attached to.
  38726. */
  38727. camera: ArcRotateCamera;
  38728. /**
  38729. * Gets the class name of the current input.
  38730. * @returns the class name
  38731. */
  38732. getClassName(): string;
  38733. /**
  38734. * Defines the buttons associated with the input to handle camera move.
  38735. */
  38736. buttons: number[];
  38737. /**
  38738. * Defines the pointer angular sensibility along the X axis or how fast is
  38739. * the camera rotating.
  38740. */
  38741. angularSensibilityX: number;
  38742. /**
  38743. * Defines the pointer angular sensibility along the Y axis or how fast is
  38744. * the camera rotating.
  38745. */
  38746. angularSensibilityY: number;
  38747. /**
  38748. * Defines the pointer pinch precision or how fast is the camera zooming.
  38749. */
  38750. pinchPrecision: number;
  38751. /**
  38752. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38753. * from 0.
  38754. * It defines the percentage of current camera.radius to use as delta when
  38755. * pinch zoom is used.
  38756. */
  38757. pinchDeltaPercentage: number;
  38758. /**
  38759. * Defines the pointer panning sensibility or how fast is the camera moving.
  38760. */
  38761. panningSensibility: number;
  38762. /**
  38763. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38764. */
  38765. multiTouchPanning: boolean;
  38766. /**
  38767. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38768. * zoom (pinch) through multitouch.
  38769. */
  38770. multiTouchPanAndZoom: boolean;
  38771. /**
  38772. * Revers pinch action direction.
  38773. */
  38774. pinchInwards: boolean;
  38775. private _isPanClick;
  38776. private _twoFingerActivityCount;
  38777. private _isPinching;
  38778. /**
  38779. * Called on pointer POINTERMOVE event if only a single touch is active.
  38780. */
  38781. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38782. /**
  38783. * Called on pointer POINTERDOUBLETAP event.
  38784. */
  38785. protected onDoubleTap(type: string): void;
  38786. /**
  38787. * Called on pointer POINTERMOVE event if multiple touches are active.
  38788. */
  38789. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38790. /**
  38791. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38792. * press.
  38793. */
  38794. protected onButtonDown(evt: PointerEvent): void;
  38795. /**
  38796. * Called each time a new POINTERUP event occurs. Ie, for each button
  38797. * release.
  38798. */
  38799. protected onButtonUp(evt: PointerEvent): void;
  38800. /**
  38801. * Called when window becomes inactive.
  38802. */
  38803. protected onLostFocus(): void;
  38804. }
  38805. }
  38806. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38807. import { Nullable } from "babylonjs/types";
  38808. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38809. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38810. /**
  38811. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38812. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38813. */
  38814. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38815. /**
  38816. * Defines the camera the input is attached to.
  38817. */
  38818. camera: ArcRotateCamera;
  38819. /**
  38820. * Defines the list of key codes associated with the up action (increase alpha)
  38821. */
  38822. keysUp: number[];
  38823. /**
  38824. * Defines the list of key codes associated with the down action (decrease alpha)
  38825. */
  38826. keysDown: number[];
  38827. /**
  38828. * Defines the list of key codes associated with the left action (increase beta)
  38829. */
  38830. keysLeft: number[];
  38831. /**
  38832. * Defines the list of key codes associated with the right action (decrease beta)
  38833. */
  38834. keysRight: number[];
  38835. /**
  38836. * Defines the list of key codes associated with the reset action.
  38837. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38838. */
  38839. keysReset: number[];
  38840. /**
  38841. * Defines the panning sensibility of the inputs.
  38842. * (How fast is the camera paning)
  38843. */
  38844. panningSensibility: number;
  38845. /**
  38846. * Defines the zooming sensibility of the inputs.
  38847. * (How fast is the camera zooming)
  38848. */
  38849. zoomingSensibility: number;
  38850. /**
  38851. * Defines wether maintaining the alt key down switch the movement mode from
  38852. * orientation to zoom.
  38853. */
  38854. useAltToZoom: boolean;
  38855. /**
  38856. * Rotation speed of the camera
  38857. */
  38858. angularSpeed: number;
  38859. private _keys;
  38860. private _ctrlPressed;
  38861. private _altPressed;
  38862. private _onCanvasBlurObserver;
  38863. private _onKeyboardObserver;
  38864. private _engine;
  38865. private _scene;
  38866. /**
  38867. * Attach the input controls to a specific dom element to get the input from.
  38868. * @param element Defines the element the controls should be listened from
  38869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38870. */
  38871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38872. /**
  38873. * Detach the current controls from the specified dom element.
  38874. * @param element Defines the element to stop listening the inputs from
  38875. */
  38876. detachControl(element: Nullable<HTMLElement>): void;
  38877. /**
  38878. * Update the current camera state depending on the inputs that have been used this frame.
  38879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38880. */
  38881. checkInputs(): void;
  38882. /**
  38883. * Gets the class name of the current intput.
  38884. * @returns the class name
  38885. */
  38886. getClassName(): string;
  38887. /**
  38888. * Get the friendly name associated with the input class.
  38889. * @returns the input friendly name
  38890. */
  38891. getSimpleName(): string;
  38892. }
  38893. }
  38894. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38895. import { Nullable } from "babylonjs/types";
  38896. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38897. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38898. /**
  38899. * Manage the mouse wheel inputs to control an arc rotate camera.
  38900. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38901. */
  38902. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38903. /**
  38904. * Defines the camera the input is attached to.
  38905. */
  38906. camera: ArcRotateCamera;
  38907. /**
  38908. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38909. */
  38910. wheelPrecision: number;
  38911. /**
  38912. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38913. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38914. */
  38915. wheelDeltaPercentage: number;
  38916. private _wheel;
  38917. private _observer;
  38918. private computeDeltaFromMouseWheelLegacyEvent;
  38919. /**
  38920. * Attach the input controls to a specific dom element to get the input from.
  38921. * @param element Defines the element the controls should be listened from
  38922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38923. */
  38924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38925. /**
  38926. * Detach the current controls from the specified dom element.
  38927. * @param element Defines the element to stop listening the inputs from
  38928. */
  38929. detachControl(element: Nullable<HTMLElement>): void;
  38930. /**
  38931. * Gets the class name of the current intput.
  38932. * @returns the class name
  38933. */
  38934. getClassName(): string;
  38935. /**
  38936. * Get the friendly name associated with the input class.
  38937. * @returns the input friendly name
  38938. */
  38939. getSimpleName(): string;
  38940. }
  38941. }
  38942. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38943. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38944. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38945. /**
  38946. * Default Inputs manager for the ArcRotateCamera.
  38947. * It groups all the default supported inputs for ease of use.
  38948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38949. */
  38950. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38951. /**
  38952. * Instantiates a new ArcRotateCameraInputsManager.
  38953. * @param camera Defines the camera the inputs belong to
  38954. */
  38955. constructor(camera: ArcRotateCamera);
  38956. /**
  38957. * Add mouse wheel input support to the input manager.
  38958. * @returns the current input manager
  38959. */
  38960. addMouseWheel(): ArcRotateCameraInputsManager;
  38961. /**
  38962. * Add pointers input support to the input manager.
  38963. * @returns the current input manager
  38964. */
  38965. addPointers(): ArcRotateCameraInputsManager;
  38966. /**
  38967. * Add keyboard input support to the input manager.
  38968. * @returns the current input manager
  38969. */
  38970. addKeyboard(): ArcRotateCameraInputsManager;
  38971. }
  38972. }
  38973. declare module "babylonjs/Cameras/arcRotateCamera" {
  38974. import { Observable } from "babylonjs/Misc/observable";
  38975. import { Nullable } from "babylonjs/types";
  38976. import { Scene } from "babylonjs/scene";
  38977. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  38978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38979. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38980. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38981. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  38982. import { Camera } from "babylonjs/Cameras/camera";
  38983. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38984. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  38985. import { Collider } from "babylonjs/Collisions/collider";
  38986. /**
  38987. * This represents an orbital type of camera.
  38988. *
  38989. * 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.
  38990. * 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.
  38991. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38992. */
  38993. export class ArcRotateCamera extends TargetCamera {
  38994. /**
  38995. * Defines the rotation angle of the camera along the longitudinal axis.
  38996. */
  38997. alpha: number;
  38998. /**
  38999. * Defines the rotation angle of the camera along the latitudinal axis.
  39000. */
  39001. beta: number;
  39002. /**
  39003. * Defines the radius of the camera from it s target point.
  39004. */
  39005. radius: number;
  39006. protected _target: Vector3;
  39007. protected _targetHost: Nullable<AbstractMesh>;
  39008. /**
  39009. * Defines the target point of the camera.
  39010. * The camera looks towards it form the radius distance.
  39011. */
  39012. target: Vector3;
  39013. /**
  39014. * Define the current local position of the camera in the scene
  39015. */
  39016. position: Vector3;
  39017. protected _upVector: Vector3;
  39018. protected _upToYMatrix: Matrix;
  39019. protected _YToUpMatrix: Matrix;
  39020. /**
  39021. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39022. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39023. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39024. */
  39025. upVector: Vector3;
  39026. /**
  39027. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39028. */
  39029. setMatUp(): void;
  39030. /**
  39031. * Current inertia value on the longitudinal axis.
  39032. * The bigger this number the longer it will take for the camera to stop.
  39033. */
  39034. inertialAlphaOffset: number;
  39035. /**
  39036. * Current inertia value on the latitudinal axis.
  39037. * The bigger this number the longer it will take for the camera to stop.
  39038. */
  39039. inertialBetaOffset: number;
  39040. /**
  39041. * Current inertia value on the radius axis.
  39042. * The bigger this number the longer it will take for the camera to stop.
  39043. */
  39044. inertialRadiusOffset: number;
  39045. /**
  39046. * Minimum allowed angle on the longitudinal axis.
  39047. * This can help limiting how the Camera is able to move in the scene.
  39048. */
  39049. lowerAlphaLimit: Nullable<number>;
  39050. /**
  39051. * Maximum allowed angle on the longitudinal axis.
  39052. * This can help limiting how the Camera is able to move in the scene.
  39053. */
  39054. upperAlphaLimit: Nullable<number>;
  39055. /**
  39056. * Minimum allowed angle on the latitudinal axis.
  39057. * This can help limiting how the Camera is able to move in the scene.
  39058. */
  39059. lowerBetaLimit: number;
  39060. /**
  39061. * Maximum allowed angle on the latitudinal axis.
  39062. * This can help limiting how the Camera is able to move in the scene.
  39063. */
  39064. upperBetaLimit: number;
  39065. /**
  39066. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39067. * This can help limiting how the Camera is able to move in the scene.
  39068. */
  39069. lowerRadiusLimit: Nullable<number>;
  39070. /**
  39071. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39072. * This can help limiting how the Camera is able to move in the scene.
  39073. */
  39074. upperRadiusLimit: Nullable<number>;
  39075. /**
  39076. * Defines the current inertia value used during panning of the camera along the X axis.
  39077. */
  39078. inertialPanningX: number;
  39079. /**
  39080. * Defines the current inertia value used during panning of the camera along the Y axis.
  39081. */
  39082. inertialPanningY: number;
  39083. /**
  39084. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39085. * Basically if your fingers moves away from more than this distance you will be considered
  39086. * in pinch mode.
  39087. */
  39088. pinchToPanMaxDistance: number;
  39089. /**
  39090. * Defines the maximum distance the camera can pan.
  39091. * This could help keeping the cammera always in your scene.
  39092. */
  39093. panningDistanceLimit: Nullable<number>;
  39094. /**
  39095. * Defines the target of the camera before paning.
  39096. */
  39097. panningOriginTarget: Vector3;
  39098. /**
  39099. * Defines the value of the inertia used during panning.
  39100. * 0 would mean stop inertia and one would mean no decelleration at all.
  39101. */
  39102. panningInertia: number;
  39103. /**
  39104. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39105. */
  39106. angularSensibilityX: number;
  39107. /**
  39108. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39109. */
  39110. angularSensibilityY: number;
  39111. /**
  39112. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39113. */
  39114. pinchPrecision: number;
  39115. /**
  39116. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39117. * It will be used instead of pinchDeltaPrecision if different from 0.
  39118. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39119. */
  39120. pinchDeltaPercentage: number;
  39121. /**
  39122. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39123. */
  39124. panningSensibility: number;
  39125. /**
  39126. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39127. */
  39128. keysUp: number[];
  39129. /**
  39130. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39131. */
  39132. keysDown: number[];
  39133. /**
  39134. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39135. */
  39136. keysLeft: number[];
  39137. /**
  39138. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39139. */
  39140. keysRight: number[];
  39141. /**
  39142. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39143. */
  39144. wheelPrecision: number;
  39145. /**
  39146. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39147. * It will be used instead of pinchDeltaPrecision if different from 0.
  39148. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39149. */
  39150. wheelDeltaPercentage: number;
  39151. /**
  39152. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39153. */
  39154. zoomOnFactor: number;
  39155. /**
  39156. * Defines a screen offset for the camera position.
  39157. */
  39158. targetScreenOffset: Vector2;
  39159. /**
  39160. * Allows the camera to be completely reversed.
  39161. * If false the camera can not arrive upside down.
  39162. */
  39163. allowUpsideDown: boolean;
  39164. /**
  39165. * Define if double tap/click is used to restore the previously saved state of the camera.
  39166. */
  39167. useInputToRestoreState: boolean;
  39168. /** @hidden */
  39169. _viewMatrix: Matrix;
  39170. /** @hidden */
  39171. _useCtrlForPanning: boolean;
  39172. /** @hidden */
  39173. _panningMouseButton: number;
  39174. /**
  39175. * Defines the input associated to the camera.
  39176. */
  39177. inputs: ArcRotateCameraInputsManager;
  39178. /** @hidden */
  39179. _reset: () => void;
  39180. /**
  39181. * Defines the allowed panning axis.
  39182. */
  39183. panningAxis: Vector3;
  39184. protected _localDirection: Vector3;
  39185. protected _transformedDirection: Vector3;
  39186. private _bouncingBehavior;
  39187. /**
  39188. * Gets the bouncing behavior of the camera if it has been enabled.
  39189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39190. */
  39191. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39192. /**
  39193. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39194. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39195. */
  39196. useBouncingBehavior: boolean;
  39197. private _framingBehavior;
  39198. /**
  39199. * Gets the framing behavior of the camera if it has been enabled.
  39200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39201. */
  39202. readonly framingBehavior: Nullable<FramingBehavior>;
  39203. /**
  39204. * Defines if the framing behavior of the camera is enabled on the camera.
  39205. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39206. */
  39207. useFramingBehavior: boolean;
  39208. private _autoRotationBehavior;
  39209. /**
  39210. * Gets the auto rotation behavior of the camera if it has been enabled.
  39211. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39212. */
  39213. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39214. /**
  39215. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39216. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39217. */
  39218. useAutoRotationBehavior: boolean;
  39219. /**
  39220. * Observable triggered when the mesh target has been changed on the camera.
  39221. */
  39222. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39223. /**
  39224. * Event raised when the camera is colliding with a mesh.
  39225. */
  39226. onCollide: (collidedMesh: AbstractMesh) => void;
  39227. /**
  39228. * Defines whether the camera should check collision with the objects oh the scene.
  39229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39230. */
  39231. checkCollisions: boolean;
  39232. /**
  39233. * Defines the collision radius of the camera.
  39234. * This simulates a sphere around the camera.
  39235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39236. */
  39237. collisionRadius: Vector3;
  39238. protected _collider: Collider;
  39239. protected _previousPosition: Vector3;
  39240. protected _collisionVelocity: Vector3;
  39241. protected _newPosition: Vector3;
  39242. protected _previousAlpha: number;
  39243. protected _previousBeta: number;
  39244. protected _previousRadius: number;
  39245. protected _collisionTriggered: boolean;
  39246. protected _targetBoundingCenter: Nullable<Vector3>;
  39247. private _computationVector;
  39248. /**
  39249. * Instantiates a new ArcRotateCamera in a given scene
  39250. * @param name Defines the name of the camera
  39251. * @param alpha Defines the camera rotation along the logitudinal axis
  39252. * @param beta Defines the camera rotation along the latitudinal axis
  39253. * @param radius Defines the camera distance from its target
  39254. * @param target Defines the camera target
  39255. * @param scene Defines the scene the camera belongs to
  39256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39257. */
  39258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39259. /** @hidden */
  39260. _initCache(): void;
  39261. /** @hidden */
  39262. _updateCache(ignoreParentClass?: boolean): void;
  39263. protected _getTargetPosition(): Vector3;
  39264. private _storedAlpha;
  39265. private _storedBeta;
  39266. private _storedRadius;
  39267. private _storedTarget;
  39268. private _storedTargetScreenOffset;
  39269. /**
  39270. * Stores the current state of the camera (alpha, beta, radius and target)
  39271. * @returns the camera itself
  39272. */
  39273. storeState(): Camera;
  39274. /**
  39275. * @hidden
  39276. * Restored camera state. You must call storeState() first
  39277. */
  39278. _restoreStateValues(): boolean;
  39279. /** @hidden */
  39280. _isSynchronizedViewMatrix(): boolean;
  39281. /**
  39282. * Attached controls to the current camera.
  39283. * @param element Defines the element the controls should be listened from
  39284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39285. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39286. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39287. */
  39288. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39289. /**
  39290. * Detach the current controls from the camera.
  39291. * The camera will stop reacting to inputs.
  39292. * @param element Defines the element to stop listening the inputs from
  39293. */
  39294. detachControl(element: HTMLElement): void;
  39295. /** @hidden */
  39296. _checkInputs(): void;
  39297. protected _checkLimits(): void;
  39298. /**
  39299. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39300. */
  39301. rebuildAnglesAndRadius(): void;
  39302. /**
  39303. * Use a position to define the current camera related information like alpha, beta and radius
  39304. * @param position Defines the position to set the camera at
  39305. */
  39306. setPosition(position: Vector3): void;
  39307. /**
  39308. * Defines the target the camera should look at.
  39309. * This will automatically adapt alpha beta and radius to fit within the new target.
  39310. * @param target Defines the new target as a Vector or a mesh
  39311. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39312. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39313. */
  39314. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39315. /** @hidden */
  39316. _getViewMatrix(): Matrix;
  39317. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39318. /**
  39319. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39320. * @param meshes Defines the mesh to zoom on
  39321. * @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)
  39322. */
  39323. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39324. /**
  39325. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39326. * The target will be changed but the radius
  39327. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39328. * @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)
  39329. */
  39330. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39331. min: Vector3;
  39332. max: Vector3;
  39333. distance: number;
  39334. }, doNotUpdateMaxZ?: boolean): void;
  39335. /**
  39336. * @override
  39337. * Override Camera.createRigCamera
  39338. */
  39339. createRigCamera(name: string, cameraIndex: number): Camera;
  39340. /**
  39341. * @hidden
  39342. * @override
  39343. * Override Camera._updateRigCameras
  39344. */
  39345. _updateRigCameras(): void;
  39346. /**
  39347. * Destroy the camera and release the current resources hold by it.
  39348. */
  39349. dispose(): void;
  39350. /**
  39351. * Gets the current object class name.
  39352. * @return the class name
  39353. */
  39354. getClassName(): string;
  39355. }
  39356. }
  39357. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39358. import { Behavior } from "babylonjs/Behaviors/behavior";
  39359. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39360. /**
  39361. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39363. */
  39364. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39365. /**
  39366. * Gets the name of the behavior.
  39367. */
  39368. readonly name: string;
  39369. private _zoomStopsAnimation;
  39370. private _idleRotationSpeed;
  39371. private _idleRotationWaitTime;
  39372. private _idleRotationSpinupTime;
  39373. /**
  39374. * Sets the flag that indicates if user zooming should stop animation.
  39375. */
  39376. /**
  39377. * Gets the flag that indicates if user zooming should stop animation.
  39378. */
  39379. zoomStopsAnimation: boolean;
  39380. /**
  39381. * Sets the default speed at which the camera rotates around the model.
  39382. */
  39383. /**
  39384. * Gets the default speed at which the camera rotates around the model.
  39385. */
  39386. idleRotationSpeed: number;
  39387. /**
  39388. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39389. */
  39390. /**
  39391. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39392. */
  39393. idleRotationWaitTime: number;
  39394. /**
  39395. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39396. */
  39397. /**
  39398. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39399. */
  39400. idleRotationSpinupTime: number;
  39401. /**
  39402. * Gets a value indicating if the camera is currently rotating because of this behavior
  39403. */
  39404. readonly rotationInProgress: boolean;
  39405. private _onPrePointerObservableObserver;
  39406. private _onAfterCheckInputsObserver;
  39407. private _attachedCamera;
  39408. private _isPointerDown;
  39409. private _lastFrameTime;
  39410. private _lastInteractionTime;
  39411. private _cameraRotationSpeed;
  39412. /**
  39413. * Initializes the behavior.
  39414. */
  39415. init(): void;
  39416. /**
  39417. * Attaches the behavior to its arc rotate camera.
  39418. * @param camera Defines the camera to attach the behavior to
  39419. */
  39420. attach(camera: ArcRotateCamera): void;
  39421. /**
  39422. * Detaches the behavior from its current arc rotate camera.
  39423. */
  39424. detach(): void;
  39425. /**
  39426. * Returns true if user is scrolling.
  39427. * @return true if user is scrolling.
  39428. */
  39429. private _userIsZooming;
  39430. private _lastFrameRadius;
  39431. private _shouldAnimationStopForInteraction;
  39432. /**
  39433. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39434. */
  39435. private _applyUserInteraction;
  39436. private _userIsMoving;
  39437. }
  39438. }
  39439. declare module "babylonjs/Behaviors/Cameras/index" {
  39440. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39441. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39442. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39443. }
  39444. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39445. import { Mesh } from "babylonjs/Meshes/mesh";
  39446. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39447. import { Behavior } from "babylonjs/Behaviors/behavior";
  39448. /**
  39449. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39450. */
  39451. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39452. private ui;
  39453. /**
  39454. * The name of the behavior
  39455. */
  39456. name: string;
  39457. /**
  39458. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39459. */
  39460. distanceAwayFromFace: number;
  39461. /**
  39462. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39463. */
  39464. distanceAwayFromBottomOfFace: number;
  39465. private _faceVectors;
  39466. private _target;
  39467. private _scene;
  39468. private _onRenderObserver;
  39469. private _tmpMatrix;
  39470. private _tmpVector;
  39471. /**
  39472. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39473. * @param ui The transform node that should be attched to the mesh
  39474. */
  39475. constructor(ui: TransformNode);
  39476. /**
  39477. * Initializes the behavior
  39478. */
  39479. init(): void;
  39480. private _closestFace;
  39481. private _zeroVector;
  39482. private _lookAtTmpMatrix;
  39483. private _lookAtToRef;
  39484. /**
  39485. * Attaches the AttachToBoxBehavior to the passed in mesh
  39486. * @param target The mesh that the specified node will be attached to
  39487. */
  39488. attach(target: Mesh): void;
  39489. /**
  39490. * Detaches the behavior from the mesh
  39491. */
  39492. detach(): void;
  39493. }
  39494. }
  39495. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39496. import { Behavior } from "babylonjs/Behaviors/behavior";
  39497. import { Mesh } from "babylonjs/Meshes/mesh";
  39498. /**
  39499. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39500. */
  39501. export class FadeInOutBehavior implements Behavior<Mesh> {
  39502. /**
  39503. * Time in milliseconds to delay before fading in (Default: 0)
  39504. */
  39505. delay: number;
  39506. /**
  39507. * Time in milliseconds for the mesh to fade in (Default: 300)
  39508. */
  39509. fadeInTime: number;
  39510. private _millisecondsPerFrame;
  39511. private _hovered;
  39512. private _hoverValue;
  39513. private _ownerNode;
  39514. /**
  39515. * Instatiates the FadeInOutBehavior
  39516. */
  39517. constructor();
  39518. /**
  39519. * The name of the behavior
  39520. */
  39521. readonly name: string;
  39522. /**
  39523. * Initializes the behavior
  39524. */
  39525. init(): void;
  39526. /**
  39527. * Attaches the fade behavior on the passed in mesh
  39528. * @param ownerNode The mesh that will be faded in/out once attached
  39529. */
  39530. attach(ownerNode: Mesh): void;
  39531. /**
  39532. * Detaches the behavior from the mesh
  39533. */
  39534. detach(): void;
  39535. /**
  39536. * Triggers the mesh to begin fading in or out
  39537. * @param value if the object should fade in or out (true to fade in)
  39538. */
  39539. fadeIn(value: boolean): void;
  39540. private _update;
  39541. private _setAllVisibility;
  39542. }
  39543. }
  39544. declare module "babylonjs/Misc/pivotTools" {
  39545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39546. /**
  39547. * Class containing a set of static utilities functions for managing Pivots
  39548. * @hidden
  39549. */
  39550. export class PivotTools {
  39551. private static _PivotCached;
  39552. private static _OldPivotPoint;
  39553. private static _PivotTranslation;
  39554. private static _PivotTmpVector;
  39555. /** @hidden */
  39556. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39557. /** @hidden */
  39558. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39559. }
  39560. }
  39561. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39562. import { Scene } from "babylonjs/scene";
  39563. import { Vector4 } from "babylonjs/Maths/math.vector";
  39564. import { Mesh } from "babylonjs/Meshes/mesh";
  39565. import { Nullable } from "babylonjs/types";
  39566. import { Plane } from "babylonjs/Maths/math.plane";
  39567. /**
  39568. * Class containing static functions to help procedurally build meshes
  39569. */
  39570. export class PlaneBuilder {
  39571. /**
  39572. * Creates a plane mesh
  39573. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39574. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39575. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39579. * @param name defines the name of the mesh
  39580. * @param options defines the options used to create the mesh
  39581. * @param scene defines the hosting scene
  39582. * @returns the plane mesh
  39583. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39584. */
  39585. static CreatePlane(name: string, options: {
  39586. size?: number;
  39587. width?: number;
  39588. height?: number;
  39589. sideOrientation?: number;
  39590. frontUVs?: Vector4;
  39591. backUVs?: Vector4;
  39592. updatable?: boolean;
  39593. sourcePlane?: Plane;
  39594. }, scene?: Nullable<Scene>): Mesh;
  39595. }
  39596. }
  39597. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39598. import { Behavior } from "babylonjs/Behaviors/behavior";
  39599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39600. import { Observable } from "babylonjs/Misc/observable";
  39601. import { Vector3 } from "babylonjs/Maths/math.vector";
  39602. import { Ray } from "babylonjs/Culling/ray";
  39603. import "babylonjs/Meshes/Builders/planeBuilder";
  39604. /**
  39605. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39606. */
  39607. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39608. private static _AnyMouseID;
  39609. /**
  39610. * Abstract mesh the behavior is set on
  39611. */
  39612. attachedNode: AbstractMesh;
  39613. private _dragPlane;
  39614. private _scene;
  39615. private _pointerObserver;
  39616. private _beforeRenderObserver;
  39617. private static _planeScene;
  39618. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39619. /**
  39620. * 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)
  39621. */
  39622. maxDragAngle: number;
  39623. /**
  39624. * @hidden
  39625. */
  39626. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39627. /**
  39628. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39629. */
  39630. currentDraggingPointerID: number;
  39631. /**
  39632. * The last position where the pointer hit the drag plane in world space
  39633. */
  39634. lastDragPosition: Vector3;
  39635. /**
  39636. * If the behavior is currently in a dragging state
  39637. */
  39638. dragging: boolean;
  39639. /**
  39640. * 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)
  39641. */
  39642. dragDeltaRatio: number;
  39643. /**
  39644. * If the drag plane orientation should be updated during the dragging (Default: true)
  39645. */
  39646. updateDragPlane: boolean;
  39647. private _debugMode;
  39648. private _moving;
  39649. /**
  39650. * Fires each time the attached mesh is dragged with the pointer
  39651. * * delta between last drag position and current drag position in world space
  39652. * * dragDistance along the drag axis
  39653. * * dragPlaneNormal normal of the current drag plane used during the drag
  39654. * * dragPlanePoint in world space where the drag intersects the drag plane
  39655. */
  39656. onDragObservable: Observable<{
  39657. delta: Vector3;
  39658. dragPlanePoint: Vector3;
  39659. dragPlaneNormal: Vector3;
  39660. dragDistance: number;
  39661. pointerId: number;
  39662. }>;
  39663. /**
  39664. * Fires each time a drag begins (eg. mouse down on mesh)
  39665. */
  39666. onDragStartObservable: Observable<{
  39667. dragPlanePoint: Vector3;
  39668. pointerId: number;
  39669. }>;
  39670. /**
  39671. * Fires each time a drag ends (eg. mouse release after drag)
  39672. */
  39673. onDragEndObservable: Observable<{
  39674. dragPlanePoint: Vector3;
  39675. pointerId: number;
  39676. }>;
  39677. /**
  39678. * If the attached mesh should be moved when dragged
  39679. */
  39680. moveAttached: boolean;
  39681. /**
  39682. * If the drag behavior will react to drag events (Default: true)
  39683. */
  39684. enabled: boolean;
  39685. /**
  39686. * If pointer events should start and release the drag (Default: true)
  39687. */
  39688. startAndReleaseDragOnPointerEvents: boolean;
  39689. /**
  39690. * If camera controls should be detached during the drag
  39691. */
  39692. detachCameraControls: boolean;
  39693. /**
  39694. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39695. */
  39696. useObjectOrienationForDragging: boolean;
  39697. private _options;
  39698. /**
  39699. * Gets the options used by the behavior
  39700. */
  39701. /**
  39702. * Sets the options used by the behavior
  39703. */
  39704. options: {
  39705. dragAxis?: Vector3;
  39706. dragPlaneNormal?: Vector3;
  39707. };
  39708. /**
  39709. * Creates a pointer drag behavior that can be attached to a mesh
  39710. * @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)
  39711. */
  39712. constructor(options?: {
  39713. dragAxis?: Vector3;
  39714. dragPlaneNormal?: Vector3;
  39715. });
  39716. /**
  39717. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39718. */
  39719. validateDrag: (targetPosition: Vector3) => boolean;
  39720. /**
  39721. * The name of the behavior
  39722. */
  39723. readonly name: string;
  39724. /**
  39725. * Initializes the behavior
  39726. */
  39727. init(): void;
  39728. private _tmpVector;
  39729. private _alternatePickedPoint;
  39730. private _worldDragAxis;
  39731. private _targetPosition;
  39732. private _attachedElement;
  39733. /**
  39734. * Attaches the drag behavior the passed in mesh
  39735. * @param ownerNode The mesh that will be dragged around once attached
  39736. * @param predicate Predicate to use for pick filtering
  39737. */
  39738. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39739. /**
  39740. * Force relase the drag action by code.
  39741. */
  39742. releaseDrag(): void;
  39743. private _startDragRay;
  39744. private _lastPointerRay;
  39745. /**
  39746. * Simulates the start of a pointer drag event on the behavior
  39747. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39748. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39749. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39750. */
  39751. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39752. private _startDrag;
  39753. private _dragDelta;
  39754. private _moveDrag;
  39755. private _pickWithRayOnDragPlane;
  39756. private _pointA;
  39757. private _pointB;
  39758. private _pointC;
  39759. private _lineA;
  39760. private _lineB;
  39761. private _localAxis;
  39762. private _lookAt;
  39763. private _updateDragPlanePosition;
  39764. /**
  39765. * Detaches the behavior from the mesh
  39766. */
  39767. detach(): void;
  39768. }
  39769. }
  39770. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39771. import { Mesh } from "babylonjs/Meshes/mesh";
  39772. import { Behavior } from "babylonjs/Behaviors/behavior";
  39773. /**
  39774. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39775. */
  39776. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39777. private _dragBehaviorA;
  39778. private _dragBehaviorB;
  39779. private _startDistance;
  39780. private _initialScale;
  39781. private _targetScale;
  39782. private _ownerNode;
  39783. private _sceneRenderObserver;
  39784. /**
  39785. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39786. */
  39787. constructor();
  39788. /**
  39789. * The name of the behavior
  39790. */
  39791. readonly name: string;
  39792. /**
  39793. * Initializes the behavior
  39794. */
  39795. init(): void;
  39796. private _getCurrentDistance;
  39797. /**
  39798. * Attaches the scale behavior the passed in mesh
  39799. * @param ownerNode The mesh that will be scaled around once attached
  39800. */
  39801. attach(ownerNode: Mesh): void;
  39802. /**
  39803. * Detaches the behavior from the mesh
  39804. */
  39805. detach(): void;
  39806. }
  39807. }
  39808. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39809. import { Behavior } from "babylonjs/Behaviors/behavior";
  39810. import { Mesh } from "babylonjs/Meshes/mesh";
  39811. import { Observable } from "babylonjs/Misc/observable";
  39812. /**
  39813. * 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
  39814. */
  39815. export class SixDofDragBehavior implements Behavior<Mesh> {
  39816. private static _virtualScene;
  39817. private _ownerNode;
  39818. private _sceneRenderObserver;
  39819. private _scene;
  39820. private _targetPosition;
  39821. private _virtualOriginMesh;
  39822. private _virtualDragMesh;
  39823. private _pointerObserver;
  39824. private _moving;
  39825. private _startingOrientation;
  39826. /**
  39827. * 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)
  39828. */
  39829. private zDragFactor;
  39830. /**
  39831. * If the object should rotate to face the drag origin
  39832. */
  39833. rotateDraggedObject: boolean;
  39834. /**
  39835. * If the behavior is currently in a dragging state
  39836. */
  39837. dragging: boolean;
  39838. /**
  39839. * 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)
  39840. */
  39841. dragDeltaRatio: number;
  39842. /**
  39843. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39844. */
  39845. currentDraggingPointerID: number;
  39846. /**
  39847. * If camera controls should be detached during the drag
  39848. */
  39849. detachCameraControls: boolean;
  39850. /**
  39851. * Fires each time a drag starts
  39852. */
  39853. onDragStartObservable: Observable<{}>;
  39854. /**
  39855. * Fires each time a drag ends (eg. mouse release after drag)
  39856. */
  39857. onDragEndObservable: Observable<{}>;
  39858. /**
  39859. * 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
  39860. */
  39861. constructor();
  39862. /**
  39863. * The name of the behavior
  39864. */
  39865. readonly name: string;
  39866. /**
  39867. * Initializes the behavior
  39868. */
  39869. init(): void;
  39870. /**
  39871. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39872. */
  39873. private readonly _pointerCamera;
  39874. /**
  39875. * Attaches the scale behavior the passed in mesh
  39876. * @param ownerNode The mesh that will be scaled around once attached
  39877. */
  39878. attach(ownerNode: Mesh): void;
  39879. /**
  39880. * Detaches the behavior from the mesh
  39881. */
  39882. detach(): void;
  39883. }
  39884. }
  39885. declare module "babylonjs/Behaviors/Meshes/index" {
  39886. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39887. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39888. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39889. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39890. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39891. }
  39892. declare module "babylonjs/Behaviors/index" {
  39893. export * from "babylonjs/Behaviors/behavior";
  39894. export * from "babylonjs/Behaviors/Cameras/index";
  39895. export * from "babylonjs/Behaviors/Meshes/index";
  39896. }
  39897. declare module "babylonjs/Bones/boneIKController" {
  39898. import { Bone } from "babylonjs/Bones/bone";
  39899. import { Vector3 } from "babylonjs/Maths/math.vector";
  39900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39901. import { Nullable } from "babylonjs/types";
  39902. /**
  39903. * Class used to apply inverse kinematics to bones
  39904. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39905. */
  39906. export class BoneIKController {
  39907. private static _tmpVecs;
  39908. private static _tmpQuat;
  39909. private static _tmpMats;
  39910. /**
  39911. * Gets or sets the target mesh
  39912. */
  39913. targetMesh: AbstractMesh;
  39914. /** Gets or sets the mesh used as pole */
  39915. poleTargetMesh: AbstractMesh;
  39916. /**
  39917. * Gets or sets the bone used as pole
  39918. */
  39919. poleTargetBone: Nullable<Bone>;
  39920. /**
  39921. * Gets or sets the target position
  39922. */
  39923. targetPosition: Vector3;
  39924. /**
  39925. * Gets or sets the pole target position
  39926. */
  39927. poleTargetPosition: Vector3;
  39928. /**
  39929. * Gets or sets the pole target local offset
  39930. */
  39931. poleTargetLocalOffset: Vector3;
  39932. /**
  39933. * Gets or sets the pole angle
  39934. */
  39935. poleAngle: number;
  39936. /**
  39937. * Gets or sets the mesh associated with the controller
  39938. */
  39939. mesh: AbstractMesh;
  39940. /**
  39941. * 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)
  39942. */
  39943. slerpAmount: number;
  39944. private _bone1Quat;
  39945. private _bone1Mat;
  39946. private _bone2Ang;
  39947. private _bone1;
  39948. private _bone2;
  39949. private _bone1Length;
  39950. private _bone2Length;
  39951. private _maxAngle;
  39952. private _maxReach;
  39953. private _rightHandedSystem;
  39954. private _bendAxis;
  39955. private _slerping;
  39956. private _adjustRoll;
  39957. /**
  39958. * Gets or sets maximum allowed angle
  39959. */
  39960. maxAngle: number;
  39961. /**
  39962. * Creates a new BoneIKController
  39963. * @param mesh defines the mesh to control
  39964. * @param bone defines the bone to control
  39965. * @param options defines options to set up the controller
  39966. */
  39967. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39968. targetMesh?: AbstractMesh;
  39969. poleTargetMesh?: AbstractMesh;
  39970. poleTargetBone?: Bone;
  39971. poleTargetLocalOffset?: Vector3;
  39972. poleAngle?: number;
  39973. bendAxis?: Vector3;
  39974. maxAngle?: number;
  39975. slerpAmount?: number;
  39976. });
  39977. private _setMaxAngle;
  39978. /**
  39979. * Force the controller to update the bones
  39980. */
  39981. update(): void;
  39982. }
  39983. }
  39984. declare module "babylonjs/Bones/boneLookController" {
  39985. import { Vector3 } from "babylonjs/Maths/math.vector";
  39986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39987. import { Bone } from "babylonjs/Bones/bone";
  39988. import { Space } from "babylonjs/Maths/math.axis";
  39989. /**
  39990. * Class used to make a bone look toward a point in space
  39991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39992. */
  39993. export class BoneLookController {
  39994. private static _tmpVecs;
  39995. private static _tmpQuat;
  39996. private static _tmpMats;
  39997. /**
  39998. * The target Vector3 that the bone will look at
  39999. */
  40000. target: Vector3;
  40001. /**
  40002. * The mesh that the bone is attached to
  40003. */
  40004. mesh: AbstractMesh;
  40005. /**
  40006. * The bone that will be looking to the target
  40007. */
  40008. bone: Bone;
  40009. /**
  40010. * The up axis of the coordinate system that is used when the bone is rotated
  40011. */
  40012. upAxis: Vector3;
  40013. /**
  40014. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40015. */
  40016. upAxisSpace: Space;
  40017. /**
  40018. * Used to make an adjustment to the yaw of the bone
  40019. */
  40020. adjustYaw: number;
  40021. /**
  40022. * Used to make an adjustment to the pitch of the bone
  40023. */
  40024. adjustPitch: number;
  40025. /**
  40026. * Used to make an adjustment to the roll of the bone
  40027. */
  40028. adjustRoll: number;
  40029. /**
  40030. * 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)
  40031. */
  40032. slerpAmount: number;
  40033. private _minYaw;
  40034. private _maxYaw;
  40035. private _minPitch;
  40036. private _maxPitch;
  40037. private _minYawSin;
  40038. private _minYawCos;
  40039. private _maxYawSin;
  40040. private _maxYawCos;
  40041. private _midYawConstraint;
  40042. private _minPitchTan;
  40043. private _maxPitchTan;
  40044. private _boneQuat;
  40045. private _slerping;
  40046. private _transformYawPitch;
  40047. private _transformYawPitchInv;
  40048. private _firstFrameSkipped;
  40049. private _yawRange;
  40050. private _fowardAxis;
  40051. /**
  40052. * Gets or sets the minimum yaw angle that the bone can look to
  40053. */
  40054. minYaw: number;
  40055. /**
  40056. * Gets or sets the maximum yaw angle that the bone can look to
  40057. */
  40058. maxYaw: number;
  40059. /**
  40060. * Gets or sets the minimum pitch angle that the bone can look to
  40061. */
  40062. minPitch: number;
  40063. /**
  40064. * Gets or sets the maximum pitch angle that the bone can look to
  40065. */
  40066. maxPitch: number;
  40067. /**
  40068. * Create a BoneLookController
  40069. * @param mesh the mesh that the bone belongs to
  40070. * @param bone the bone that will be looking to the target
  40071. * @param target the target Vector3 to look at
  40072. * @param options optional settings:
  40073. * * maxYaw: the maximum angle the bone will yaw to
  40074. * * minYaw: the minimum angle the bone will yaw to
  40075. * * maxPitch: the maximum angle the bone will pitch to
  40076. * * minPitch: the minimum angle the bone will yaw to
  40077. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40078. * * upAxis: the up axis of the coordinate system
  40079. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40080. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40081. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40082. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40083. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40084. * * adjustRoll: used to make an adjustment to the roll of the bone
  40085. **/
  40086. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40087. maxYaw?: number;
  40088. minYaw?: number;
  40089. maxPitch?: number;
  40090. minPitch?: number;
  40091. slerpAmount?: number;
  40092. upAxis?: Vector3;
  40093. upAxisSpace?: Space;
  40094. yawAxis?: Vector3;
  40095. pitchAxis?: Vector3;
  40096. adjustYaw?: number;
  40097. adjustPitch?: number;
  40098. adjustRoll?: number;
  40099. });
  40100. /**
  40101. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40102. */
  40103. update(): void;
  40104. private _getAngleDiff;
  40105. private _getAngleBetween;
  40106. private _isAngleBetween;
  40107. }
  40108. }
  40109. declare module "babylonjs/Bones/index" {
  40110. export * from "babylonjs/Bones/bone";
  40111. export * from "babylonjs/Bones/boneIKController";
  40112. export * from "babylonjs/Bones/boneLookController";
  40113. export * from "babylonjs/Bones/skeleton";
  40114. }
  40115. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40116. import { Nullable } from "babylonjs/types";
  40117. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40118. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40119. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40120. /**
  40121. * Manage the gamepad inputs to control an arc rotate camera.
  40122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40123. */
  40124. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40125. /**
  40126. * Defines the camera the input is attached to.
  40127. */
  40128. camera: ArcRotateCamera;
  40129. /**
  40130. * Defines the gamepad the input is gathering event from.
  40131. */
  40132. gamepad: Nullable<Gamepad>;
  40133. /**
  40134. * Defines the gamepad rotation sensiblity.
  40135. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40136. */
  40137. gamepadRotationSensibility: number;
  40138. /**
  40139. * Defines the gamepad move sensiblity.
  40140. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40141. */
  40142. gamepadMoveSensibility: number;
  40143. private _yAxisScale;
  40144. /**
  40145. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40146. */
  40147. invertYAxis: boolean;
  40148. private _onGamepadConnectedObserver;
  40149. private _onGamepadDisconnectedObserver;
  40150. /**
  40151. * Attach the input controls to a specific dom element to get the input from.
  40152. * @param element Defines the element the controls should be listened from
  40153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40154. */
  40155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40156. /**
  40157. * Detach the current controls from the specified dom element.
  40158. * @param element Defines the element to stop listening the inputs from
  40159. */
  40160. detachControl(element: Nullable<HTMLElement>): void;
  40161. /**
  40162. * Update the current camera state depending on the inputs that have been used this frame.
  40163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40164. */
  40165. checkInputs(): void;
  40166. /**
  40167. * Gets the class name of the current intput.
  40168. * @returns the class name
  40169. */
  40170. getClassName(): string;
  40171. /**
  40172. * Get the friendly name associated with the input class.
  40173. * @returns the input friendly name
  40174. */
  40175. getSimpleName(): string;
  40176. }
  40177. }
  40178. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40179. import { Nullable } from "babylonjs/types";
  40180. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40181. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40182. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40183. interface ArcRotateCameraInputsManager {
  40184. /**
  40185. * Add orientation input support to the input manager.
  40186. * @returns the current input manager
  40187. */
  40188. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40189. }
  40190. }
  40191. /**
  40192. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40194. */
  40195. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40196. /**
  40197. * Defines the camera the input is attached to.
  40198. */
  40199. camera: ArcRotateCamera;
  40200. /**
  40201. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40202. */
  40203. alphaCorrection: number;
  40204. /**
  40205. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40206. */
  40207. gammaCorrection: number;
  40208. private _alpha;
  40209. private _gamma;
  40210. private _dirty;
  40211. private _deviceOrientationHandler;
  40212. /**
  40213. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40214. */
  40215. constructor();
  40216. /**
  40217. * Attach the input controls to a specific dom element to get the input from.
  40218. * @param element Defines the element the controls should be listened from
  40219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40220. */
  40221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40222. /** @hidden */
  40223. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40224. /**
  40225. * Update the current camera state depending on the inputs that have been used this frame.
  40226. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40227. */
  40228. checkInputs(): void;
  40229. /**
  40230. * Detach the current controls from the specified dom element.
  40231. * @param element Defines the element to stop listening the inputs from
  40232. */
  40233. detachControl(element: Nullable<HTMLElement>): void;
  40234. /**
  40235. * Gets the class name of the current intput.
  40236. * @returns the class name
  40237. */
  40238. getClassName(): string;
  40239. /**
  40240. * Get the friendly name associated with the input class.
  40241. * @returns the input friendly name
  40242. */
  40243. getSimpleName(): string;
  40244. }
  40245. }
  40246. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40247. import { Nullable } from "babylonjs/types";
  40248. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40249. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40250. /**
  40251. * Listen to mouse events to control the camera.
  40252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40253. */
  40254. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40255. /**
  40256. * Defines the camera the input is attached to.
  40257. */
  40258. camera: FlyCamera;
  40259. /**
  40260. * Defines if touch is enabled. (Default is true.)
  40261. */
  40262. touchEnabled: boolean;
  40263. /**
  40264. * Defines the buttons associated with the input to handle camera rotation.
  40265. */
  40266. buttons: number[];
  40267. /**
  40268. * Assign buttons for Yaw control.
  40269. */
  40270. buttonsYaw: number[];
  40271. /**
  40272. * Assign buttons for Pitch control.
  40273. */
  40274. buttonsPitch: number[];
  40275. /**
  40276. * Assign buttons for Roll control.
  40277. */
  40278. buttonsRoll: number[];
  40279. /**
  40280. * Detect if any button is being pressed while mouse is moved.
  40281. * -1 = Mouse locked.
  40282. * 0 = Left button.
  40283. * 1 = Middle Button.
  40284. * 2 = Right Button.
  40285. */
  40286. activeButton: number;
  40287. /**
  40288. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40289. * Higher values reduce its sensitivity.
  40290. */
  40291. angularSensibility: number;
  40292. private _mousemoveCallback;
  40293. private _observer;
  40294. private _rollObserver;
  40295. private previousPosition;
  40296. private noPreventDefault;
  40297. private element;
  40298. /**
  40299. * Listen to mouse events to control the camera.
  40300. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40301. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40302. */
  40303. constructor(touchEnabled?: boolean);
  40304. /**
  40305. * Attach the mouse control to the HTML DOM element.
  40306. * @param element Defines the element that listens to the input events.
  40307. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40308. */
  40309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40310. /**
  40311. * Detach the current controls from the specified dom element.
  40312. * @param element Defines the element to stop listening the inputs from
  40313. */
  40314. detachControl(element: Nullable<HTMLElement>): void;
  40315. /**
  40316. * Gets the class name of the current input.
  40317. * @returns the class name.
  40318. */
  40319. getClassName(): string;
  40320. /**
  40321. * Get the friendly name associated with the input class.
  40322. * @returns the input's friendly name.
  40323. */
  40324. getSimpleName(): string;
  40325. private _pointerInput;
  40326. private _onMouseMove;
  40327. /**
  40328. * Rotate camera by mouse offset.
  40329. */
  40330. private rotateCamera;
  40331. }
  40332. }
  40333. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40334. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40335. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40336. /**
  40337. * Default Inputs manager for the FlyCamera.
  40338. * It groups all the default supported inputs for ease of use.
  40339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40340. */
  40341. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40342. /**
  40343. * Instantiates a new FlyCameraInputsManager.
  40344. * @param camera Defines the camera the inputs belong to.
  40345. */
  40346. constructor(camera: FlyCamera);
  40347. /**
  40348. * Add keyboard input support to the input manager.
  40349. * @returns the new FlyCameraKeyboardMoveInput().
  40350. */
  40351. addKeyboard(): FlyCameraInputsManager;
  40352. /**
  40353. * Add mouse input support to the input manager.
  40354. * @param touchEnabled Enable touch screen support.
  40355. * @returns the new FlyCameraMouseInput().
  40356. */
  40357. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40358. }
  40359. }
  40360. declare module "babylonjs/Cameras/flyCamera" {
  40361. import { Scene } from "babylonjs/scene";
  40362. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40364. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40365. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40366. /**
  40367. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40368. * such as in a 3D Space Shooter or a Flight Simulator.
  40369. */
  40370. export class FlyCamera extends TargetCamera {
  40371. /**
  40372. * Define the collision ellipsoid of the camera.
  40373. * This is helpful for simulating a camera body, like a player's body.
  40374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40375. */
  40376. ellipsoid: Vector3;
  40377. /**
  40378. * Define an offset for the position of the ellipsoid around the camera.
  40379. * This can be helpful if the camera is attached away from the player's body center,
  40380. * such as at its head.
  40381. */
  40382. ellipsoidOffset: Vector3;
  40383. /**
  40384. * Enable or disable collisions of the camera with the rest of the scene objects.
  40385. */
  40386. checkCollisions: boolean;
  40387. /**
  40388. * Enable or disable gravity on the camera.
  40389. */
  40390. applyGravity: boolean;
  40391. /**
  40392. * Define the current direction the camera is moving to.
  40393. */
  40394. cameraDirection: Vector3;
  40395. /**
  40396. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40397. * This overrides and empties cameraRotation.
  40398. */
  40399. rotationQuaternion: Quaternion;
  40400. /**
  40401. * Track Roll to maintain the wanted Rolling when looking around.
  40402. */
  40403. _trackRoll: number;
  40404. /**
  40405. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40406. */
  40407. rollCorrect: number;
  40408. /**
  40409. * Mimic a banked turn, Rolling the camera when Yawing.
  40410. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40411. */
  40412. bankedTurn: boolean;
  40413. /**
  40414. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40415. */
  40416. bankedTurnLimit: number;
  40417. /**
  40418. * Value of 0 disables the banked Roll.
  40419. * Value of 1 is equal to the Yaw angle in radians.
  40420. */
  40421. bankedTurnMultiplier: number;
  40422. /**
  40423. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40424. */
  40425. inputs: FlyCameraInputsManager;
  40426. /**
  40427. * Gets the input sensibility for mouse input.
  40428. * Higher values reduce sensitivity.
  40429. */
  40430. /**
  40431. * Sets the input sensibility for a mouse input.
  40432. * Higher values reduce sensitivity.
  40433. */
  40434. angularSensibility: number;
  40435. /**
  40436. * Get the keys for camera movement forward.
  40437. */
  40438. /**
  40439. * Set the keys for camera movement forward.
  40440. */
  40441. keysForward: number[];
  40442. /**
  40443. * Get the keys for camera movement backward.
  40444. */
  40445. keysBackward: number[];
  40446. /**
  40447. * Get the keys for camera movement up.
  40448. */
  40449. /**
  40450. * Set the keys for camera movement up.
  40451. */
  40452. keysUp: number[];
  40453. /**
  40454. * Get the keys for camera movement down.
  40455. */
  40456. /**
  40457. * Set the keys for camera movement down.
  40458. */
  40459. keysDown: number[];
  40460. /**
  40461. * Get the keys for camera movement left.
  40462. */
  40463. /**
  40464. * Set the keys for camera movement left.
  40465. */
  40466. keysLeft: number[];
  40467. /**
  40468. * Set the keys for camera movement right.
  40469. */
  40470. /**
  40471. * Set the keys for camera movement right.
  40472. */
  40473. keysRight: number[];
  40474. /**
  40475. * Event raised when the camera collides with a mesh in the scene.
  40476. */
  40477. onCollide: (collidedMesh: AbstractMesh) => void;
  40478. private _collider;
  40479. private _needMoveForGravity;
  40480. private _oldPosition;
  40481. private _diffPosition;
  40482. private _newPosition;
  40483. /** @hidden */
  40484. _localDirection: Vector3;
  40485. /** @hidden */
  40486. _transformedDirection: Vector3;
  40487. /**
  40488. * Instantiates a FlyCamera.
  40489. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40490. * such as in a 3D Space Shooter or a Flight Simulator.
  40491. * @param name Define the name of the camera in the scene.
  40492. * @param position Define the starting position of the camera in the scene.
  40493. * @param scene Define the scene the camera belongs to.
  40494. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40495. */
  40496. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40497. /**
  40498. * Attach a control to the HTML DOM element.
  40499. * @param element Defines the element that listens to the input events.
  40500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40501. */
  40502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40503. /**
  40504. * Detach a control from the HTML DOM element.
  40505. * The camera will stop reacting to that input.
  40506. * @param element Defines the element that listens to the input events.
  40507. */
  40508. detachControl(element: HTMLElement): void;
  40509. private _collisionMask;
  40510. /**
  40511. * Get the mask that the camera ignores in collision events.
  40512. */
  40513. /**
  40514. * Set the mask that the camera ignores in collision events.
  40515. */
  40516. collisionMask: number;
  40517. /** @hidden */
  40518. _collideWithWorld(displacement: Vector3): void;
  40519. /** @hidden */
  40520. private _onCollisionPositionChange;
  40521. /** @hidden */
  40522. _checkInputs(): void;
  40523. /** @hidden */
  40524. _decideIfNeedsToMove(): boolean;
  40525. /** @hidden */
  40526. _updatePosition(): void;
  40527. /**
  40528. * Restore the Roll to its target value at the rate specified.
  40529. * @param rate - Higher means slower restoring.
  40530. * @hidden
  40531. */
  40532. restoreRoll(rate: number): void;
  40533. /**
  40534. * Destroy the camera and release the current resources held by it.
  40535. */
  40536. dispose(): void;
  40537. /**
  40538. * Get the current object class name.
  40539. * @returns the class name.
  40540. */
  40541. getClassName(): string;
  40542. }
  40543. }
  40544. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40545. import { Nullable } from "babylonjs/types";
  40546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40547. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40548. /**
  40549. * Listen to keyboard events to control the camera.
  40550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40551. */
  40552. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40553. /**
  40554. * Defines the camera the input is attached to.
  40555. */
  40556. camera: FlyCamera;
  40557. /**
  40558. * The list of keyboard keys used to control the forward move of the camera.
  40559. */
  40560. keysForward: number[];
  40561. /**
  40562. * The list of keyboard keys used to control the backward move of the camera.
  40563. */
  40564. keysBackward: number[];
  40565. /**
  40566. * The list of keyboard keys used to control the forward move of the camera.
  40567. */
  40568. keysUp: number[];
  40569. /**
  40570. * The list of keyboard keys used to control the backward move of the camera.
  40571. */
  40572. keysDown: number[];
  40573. /**
  40574. * The list of keyboard keys used to control the right strafe move of the camera.
  40575. */
  40576. keysRight: number[];
  40577. /**
  40578. * The list of keyboard keys used to control the left strafe move of the camera.
  40579. */
  40580. keysLeft: number[];
  40581. private _keys;
  40582. private _onCanvasBlurObserver;
  40583. private _onKeyboardObserver;
  40584. private _engine;
  40585. private _scene;
  40586. /**
  40587. * Attach the input controls to a specific dom element to get the input from.
  40588. * @param element Defines the element the controls should be listened from
  40589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40590. */
  40591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40592. /**
  40593. * Detach the current controls from the specified dom element.
  40594. * @param element Defines the element to stop listening the inputs from
  40595. */
  40596. detachControl(element: Nullable<HTMLElement>): void;
  40597. /**
  40598. * Gets the class name of the current intput.
  40599. * @returns the class name
  40600. */
  40601. getClassName(): string;
  40602. /** @hidden */
  40603. _onLostFocus(e: FocusEvent): void;
  40604. /**
  40605. * Get the friendly name associated with the input class.
  40606. * @returns the input friendly name
  40607. */
  40608. getSimpleName(): string;
  40609. /**
  40610. * Update the current camera state depending on the inputs that have been used this frame.
  40611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40612. */
  40613. checkInputs(): void;
  40614. }
  40615. }
  40616. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40617. import { Nullable } from "babylonjs/types";
  40618. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40619. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40620. /**
  40621. * Manage the mouse wheel inputs to control a follow camera.
  40622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40623. */
  40624. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40625. /**
  40626. * Defines the camera the input is attached to.
  40627. */
  40628. camera: FollowCamera;
  40629. /**
  40630. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40631. */
  40632. axisControlRadius: boolean;
  40633. /**
  40634. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40635. */
  40636. axisControlHeight: boolean;
  40637. /**
  40638. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40639. */
  40640. axisControlRotation: boolean;
  40641. /**
  40642. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40643. * relation to mouseWheel events.
  40644. */
  40645. wheelPrecision: number;
  40646. /**
  40647. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40648. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40649. */
  40650. wheelDeltaPercentage: number;
  40651. private _wheel;
  40652. private _observer;
  40653. /**
  40654. * Attach the input controls to a specific dom element to get the input from.
  40655. * @param element Defines the element the controls should be listened from
  40656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40657. */
  40658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40659. /**
  40660. * Detach the current controls from the specified dom element.
  40661. * @param element Defines the element to stop listening the inputs from
  40662. */
  40663. detachControl(element: Nullable<HTMLElement>): void;
  40664. /**
  40665. * Gets the class name of the current intput.
  40666. * @returns the class name
  40667. */
  40668. getClassName(): string;
  40669. /**
  40670. * Get the friendly name associated with the input class.
  40671. * @returns the input friendly name
  40672. */
  40673. getSimpleName(): string;
  40674. }
  40675. }
  40676. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40677. import { Nullable } from "babylonjs/types";
  40678. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40679. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40680. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40681. /**
  40682. * Manage the pointers inputs to control an follow camera.
  40683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40684. */
  40685. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40686. /**
  40687. * Defines the camera the input is attached to.
  40688. */
  40689. camera: FollowCamera;
  40690. /**
  40691. * Gets the class name of the current input.
  40692. * @returns the class name
  40693. */
  40694. getClassName(): string;
  40695. /**
  40696. * Defines the pointer angular sensibility along the X axis or how fast is
  40697. * the camera rotating.
  40698. * A negative number will reverse the axis direction.
  40699. */
  40700. angularSensibilityX: number;
  40701. /**
  40702. * Defines the pointer angular sensibility along the Y axis or how fast is
  40703. * the camera rotating.
  40704. * A negative number will reverse the axis direction.
  40705. */
  40706. angularSensibilityY: number;
  40707. /**
  40708. * Defines the pointer pinch precision or how fast is the camera zooming.
  40709. * A negative number will reverse the axis direction.
  40710. */
  40711. pinchPrecision: number;
  40712. /**
  40713. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40714. * from 0.
  40715. * It defines the percentage of current camera.radius to use as delta when
  40716. * pinch zoom is used.
  40717. */
  40718. pinchDeltaPercentage: number;
  40719. /**
  40720. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40721. */
  40722. axisXControlRadius: boolean;
  40723. /**
  40724. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40725. */
  40726. axisXControlHeight: boolean;
  40727. /**
  40728. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40729. */
  40730. axisXControlRotation: boolean;
  40731. /**
  40732. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40733. */
  40734. axisYControlRadius: boolean;
  40735. /**
  40736. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40737. */
  40738. axisYControlHeight: boolean;
  40739. /**
  40740. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40741. */
  40742. axisYControlRotation: boolean;
  40743. /**
  40744. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40745. */
  40746. axisPinchControlRadius: boolean;
  40747. /**
  40748. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40749. */
  40750. axisPinchControlHeight: boolean;
  40751. /**
  40752. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40753. */
  40754. axisPinchControlRotation: boolean;
  40755. /**
  40756. * Log error messages if basic misconfiguration has occurred.
  40757. */
  40758. warningEnable: boolean;
  40759. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40760. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40761. private _warningCounter;
  40762. private _warning;
  40763. }
  40764. }
  40765. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40766. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40767. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40768. /**
  40769. * Default Inputs manager for the FollowCamera.
  40770. * It groups all the default supported inputs for ease of use.
  40771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40772. */
  40773. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40774. /**
  40775. * Instantiates a new FollowCameraInputsManager.
  40776. * @param camera Defines the camera the inputs belong to
  40777. */
  40778. constructor(camera: FollowCamera);
  40779. /**
  40780. * Add keyboard input support to the input manager.
  40781. * @returns the current input manager
  40782. */
  40783. addKeyboard(): FollowCameraInputsManager;
  40784. /**
  40785. * Add mouse wheel input support to the input manager.
  40786. * @returns the current input manager
  40787. */
  40788. addMouseWheel(): FollowCameraInputsManager;
  40789. /**
  40790. * Add pointers input support to the input manager.
  40791. * @returns the current input manager
  40792. */
  40793. addPointers(): FollowCameraInputsManager;
  40794. /**
  40795. * Add orientation input support to the input manager.
  40796. * @returns the current input manager
  40797. */
  40798. addVRDeviceOrientation(): FollowCameraInputsManager;
  40799. }
  40800. }
  40801. declare module "babylonjs/Cameras/followCamera" {
  40802. import { Nullable } from "babylonjs/types";
  40803. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40804. import { Scene } from "babylonjs/scene";
  40805. import { Vector3 } from "babylonjs/Maths/math.vector";
  40806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40807. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40808. /**
  40809. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40810. * an arc rotate version arcFollowCamera are available.
  40811. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40812. */
  40813. export class FollowCamera extends TargetCamera {
  40814. /**
  40815. * Distance the follow camera should follow an object at
  40816. */
  40817. radius: number;
  40818. /**
  40819. * Minimum allowed distance of the camera to the axis of rotation
  40820. * (The camera can not get closer).
  40821. * This can help limiting how the Camera is able to move in the scene.
  40822. */
  40823. lowerRadiusLimit: Nullable<number>;
  40824. /**
  40825. * Maximum allowed distance of the camera to the axis of rotation
  40826. * (The camera can not get further).
  40827. * This can help limiting how the Camera is able to move in the scene.
  40828. */
  40829. upperRadiusLimit: Nullable<number>;
  40830. /**
  40831. * Define a rotation offset between the camera and the object it follows
  40832. */
  40833. rotationOffset: number;
  40834. /**
  40835. * Minimum allowed angle to camera position relative to target object.
  40836. * This can help limiting how the Camera is able to move in the scene.
  40837. */
  40838. lowerRotationOffsetLimit: Nullable<number>;
  40839. /**
  40840. * Maximum allowed angle to camera position relative to target object.
  40841. * This can help limiting how the Camera is able to move in the scene.
  40842. */
  40843. upperRotationOffsetLimit: Nullable<number>;
  40844. /**
  40845. * Define a height offset between the camera and the object it follows.
  40846. * It can help following an object from the top (like a car chaing a plane)
  40847. */
  40848. heightOffset: number;
  40849. /**
  40850. * Minimum allowed height of camera position relative to target object.
  40851. * This can help limiting how the Camera is able to move in the scene.
  40852. */
  40853. lowerHeightOffsetLimit: Nullable<number>;
  40854. /**
  40855. * Maximum allowed height of camera position relative to target object.
  40856. * This can help limiting how the Camera is able to move in the scene.
  40857. */
  40858. upperHeightOffsetLimit: Nullable<number>;
  40859. /**
  40860. * Define how fast the camera can accelerate to follow it s target.
  40861. */
  40862. cameraAcceleration: number;
  40863. /**
  40864. * Define the speed limit of the camera following an object.
  40865. */
  40866. maxCameraSpeed: number;
  40867. /**
  40868. * Define the target of the camera.
  40869. */
  40870. lockedTarget: Nullable<AbstractMesh>;
  40871. /**
  40872. * Defines the input associated with the camera.
  40873. */
  40874. inputs: FollowCameraInputsManager;
  40875. /**
  40876. * Instantiates the follow camera.
  40877. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40878. * @param name Define the name of the camera in the scene
  40879. * @param position Define the position of the camera
  40880. * @param scene Define the scene the camera belong to
  40881. * @param lockedTarget Define the target of the camera
  40882. */
  40883. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40884. private _follow;
  40885. /**
  40886. * Attached controls to the current camera.
  40887. * @param element Defines the element the controls should be listened from
  40888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40889. */
  40890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40891. /**
  40892. * Detach the current controls from the camera.
  40893. * The camera will stop reacting to inputs.
  40894. * @param element Defines the element to stop listening the inputs from
  40895. */
  40896. detachControl(element: HTMLElement): void;
  40897. /** @hidden */
  40898. _checkInputs(): void;
  40899. private _checkLimits;
  40900. /**
  40901. * Gets the camera class name.
  40902. * @returns the class name
  40903. */
  40904. getClassName(): string;
  40905. }
  40906. /**
  40907. * Arc Rotate version of the follow camera.
  40908. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40909. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40910. */
  40911. export class ArcFollowCamera extends TargetCamera {
  40912. /** The longitudinal angle of the camera */
  40913. alpha: number;
  40914. /** The latitudinal angle of the camera */
  40915. beta: number;
  40916. /** The radius of the camera from its target */
  40917. radius: number;
  40918. /** Define the camera target (the messh it should follow) */
  40919. target: Nullable<AbstractMesh>;
  40920. private _cartesianCoordinates;
  40921. /**
  40922. * Instantiates a new ArcFollowCamera
  40923. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40924. * @param name Define the name of the camera
  40925. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40926. * @param beta Define the rotation angle of the camera around the elevation axis
  40927. * @param radius Define the radius of the camera from its target point
  40928. * @param target Define the target of the camera
  40929. * @param scene Define the scene the camera belongs to
  40930. */
  40931. constructor(name: string,
  40932. /** The longitudinal angle of the camera */
  40933. alpha: number,
  40934. /** The latitudinal angle of the camera */
  40935. beta: number,
  40936. /** The radius of the camera from its target */
  40937. radius: number,
  40938. /** Define the camera target (the messh it should follow) */
  40939. target: Nullable<AbstractMesh>, scene: Scene);
  40940. private _follow;
  40941. /** @hidden */
  40942. _checkInputs(): void;
  40943. /**
  40944. * Returns the class name of the object.
  40945. * It is mostly used internally for serialization purposes.
  40946. */
  40947. getClassName(): string;
  40948. }
  40949. }
  40950. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  40951. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40952. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40953. import { Nullable } from "babylonjs/types";
  40954. /**
  40955. * Manage the keyboard inputs to control the movement of a follow camera.
  40956. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40957. */
  40958. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40959. /**
  40960. * Defines the camera the input is attached to.
  40961. */
  40962. camera: FollowCamera;
  40963. /**
  40964. * Defines the list of key codes associated with the up action (increase heightOffset)
  40965. */
  40966. keysHeightOffsetIncr: number[];
  40967. /**
  40968. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40969. */
  40970. keysHeightOffsetDecr: number[];
  40971. /**
  40972. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40973. */
  40974. keysHeightOffsetModifierAlt: boolean;
  40975. /**
  40976. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40977. */
  40978. keysHeightOffsetModifierCtrl: boolean;
  40979. /**
  40980. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40981. */
  40982. keysHeightOffsetModifierShift: boolean;
  40983. /**
  40984. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40985. */
  40986. keysRotationOffsetIncr: number[];
  40987. /**
  40988. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40989. */
  40990. keysRotationOffsetDecr: number[];
  40991. /**
  40992. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40993. */
  40994. keysRotationOffsetModifierAlt: boolean;
  40995. /**
  40996. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40997. */
  40998. keysRotationOffsetModifierCtrl: boolean;
  40999. /**
  41000. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41001. */
  41002. keysRotationOffsetModifierShift: boolean;
  41003. /**
  41004. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41005. */
  41006. keysRadiusIncr: number[];
  41007. /**
  41008. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41009. */
  41010. keysRadiusDecr: number[];
  41011. /**
  41012. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41013. */
  41014. keysRadiusModifierAlt: boolean;
  41015. /**
  41016. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41017. */
  41018. keysRadiusModifierCtrl: boolean;
  41019. /**
  41020. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41021. */
  41022. keysRadiusModifierShift: boolean;
  41023. /**
  41024. * Defines the rate of change of heightOffset.
  41025. */
  41026. heightSensibility: number;
  41027. /**
  41028. * Defines the rate of change of rotationOffset.
  41029. */
  41030. rotationSensibility: number;
  41031. /**
  41032. * Defines the rate of change of radius.
  41033. */
  41034. radiusSensibility: number;
  41035. private _keys;
  41036. private _ctrlPressed;
  41037. private _altPressed;
  41038. private _shiftPressed;
  41039. private _onCanvasBlurObserver;
  41040. private _onKeyboardObserver;
  41041. private _engine;
  41042. private _scene;
  41043. /**
  41044. * Attach the input controls to a specific dom element to get the input from.
  41045. * @param element Defines the element the controls should be listened from
  41046. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41047. */
  41048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41049. /**
  41050. * Detach the current controls from the specified dom element.
  41051. * @param element Defines the element to stop listening the inputs from
  41052. */
  41053. detachControl(element: Nullable<HTMLElement>): void;
  41054. /**
  41055. * Update the current camera state depending on the inputs that have been used this frame.
  41056. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41057. */
  41058. checkInputs(): void;
  41059. /**
  41060. * Gets the class name of the current input.
  41061. * @returns the class name
  41062. */
  41063. getClassName(): string;
  41064. /**
  41065. * Get the friendly name associated with the input class.
  41066. * @returns the input friendly name
  41067. */
  41068. getSimpleName(): string;
  41069. /**
  41070. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41071. * allow modification of the heightOffset value.
  41072. */
  41073. private _modifierHeightOffset;
  41074. /**
  41075. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41076. * allow modification of the rotationOffset value.
  41077. */
  41078. private _modifierRotationOffset;
  41079. /**
  41080. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41081. * allow modification of the radius value.
  41082. */
  41083. private _modifierRadius;
  41084. }
  41085. }
  41086. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41087. import { Nullable } from "babylonjs/types";
  41088. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41089. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41090. import { Observable } from "babylonjs/Misc/observable";
  41091. module "babylonjs/Cameras/freeCameraInputsManager" {
  41092. interface FreeCameraInputsManager {
  41093. /**
  41094. * @hidden
  41095. */
  41096. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41097. /**
  41098. * Add orientation input support to the input manager.
  41099. * @returns the current input manager
  41100. */
  41101. addDeviceOrientation(): FreeCameraInputsManager;
  41102. }
  41103. }
  41104. /**
  41105. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41106. * Screen rotation is taken into account.
  41107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41108. */
  41109. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41110. private _camera;
  41111. private _screenOrientationAngle;
  41112. private _constantTranform;
  41113. private _screenQuaternion;
  41114. private _alpha;
  41115. private _beta;
  41116. private _gamma;
  41117. /**
  41118. * Can be used to detect if a device orientation sensor is availible on a device
  41119. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41120. * @returns a promise that will resolve on orientation change
  41121. */
  41122. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41123. /**
  41124. * @hidden
  41125. */
  41126. _onDeviceOrientationChangedObservable: Observable<void>;
  41127. /**
  41128. * Instantiates a new input
  41129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41130. */
  41131. constructor();
  41132. /**
  41133. * Define the camera controlled by the input.
  41134. */
  41135. camera: FreeCamera;
  41136. /**
  41137. * Attach the input controls to a specific dom element to get the input from.
  41138. * @param element Defines the element the controls should be listened from
  41139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41140. */
  41141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41142. private _orientationChanged;
  41143. private _deviceOrientation;
  41144. /**
  41145. * Detach the current controls from the specified dom element.
  41146. * @param element Defines the element to stop listening the inputs from
  41147. */
  41148. detachControl(element: Nullable<HTMLElement>): void;
  41149. /**
  41150. * Update the current camera state depending on the inputs that have been used this frame.
  41151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41152. */
  41153. checkInputs(): void;
  41154. /**
  41155. * Gets the class name of the current intput.
  41156. * @returns the class name
  41157. */
  41158. getClassName(): string;
  41159. /**
  41160. * Get the friendly name associated with the input class.
  41161. * @returns the input friendly name
  41162. */
  41163. getSimpleName(): string;
  41164. }
  41165. }
  41166. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41167. import { Nullable } from "babylonjs/types";
  41168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41170. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41171. /**
  41172. * Manage the gamepad inputs to control a free camera.
  41173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41174. */
  41175. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41176. /**
  41177. * Define the camera the input is attached to.
  41178. */
  41179. camera: FreeCamera;
  41180. /**
  41181. * Define the Gamepad controlling the input
  41182. */
  41183. gamepad: Nullable<Gamepad>;
  41184. /**
  41185. * Defines the gamepad rotation sensiblity.
  41186. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41187. */
  41188. gamepadAngularSensibility: number;
  41189. /**
  41190. * Defines the gamepad move sensiblity.
  41191. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41192. */
  41193. gamepadMoveSensibility: number;
  41194. private _yAxisScale;
  41195. /**
  41196. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41197. */
  41198. invertYAxis: boolean;
  41199. private _onGamepadConnectedObserver;
  41200. private _onGamepadDisconnectedObserver;
  41201. private _cameraTransform;
  41202. private _deltaTransform;
  41203. private _vector3;
  41204. private _vector2;
  41205. /**
  41206. * Attach the input controls to a specific dom element to get the input from.
  41207. * @param element Defines the element the controls should be listened from
  41208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41209. */
  41210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41211. /**
  41212. * Detach the current controls from the specified dom element.
  41213. * @param element Defines the element to stop listening the inputs from
  41214. */
  41215. detachControl(element: Nullable<HTMLElement>): void;
  41216. /**
  41217. * Update the current camera state depending on the inputs that have been used this frame.
  41218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41219. */
  41220. checkInputs(): void;
  41221. /**
  41222. * Gets the class name of the current intput.
  41223. * @returns the class name
  41224. */
  41225. getClassName(): string;
  41226. /**
  41227. * Get the friendly name associated with the input class.
  41228. * @returns the input friendly name
  41229. */
  41230. getSimpleName(): string;
  41231. }
  41232. }
  41233. declare module "babylonjs/Misc/virtualJoystick" {
  41234. import { Nullable } from "babylonjs/types";
  41235. import { Vector3 } from "babylonjs/Maths/math.vector";
  41236. /**
  41237. * Defines the potential axis of a Joystick
  41238. */
  41239. export enum JoystickAxis {
  41240. /** X axis */
  41241. X = 0,
  41242. /** Y axis */
  41243. Y = 1,
  41244. /** Z axis */
  41245. Z = 2
  41246. }
  41247. /**
  41248. * Class used to define virtual joystick (used in touch mode)
  41249. */
  41250. export class VirtualJoystick {
  41251. /**
  41252. * Gets or sets a boolean indicating that left and right values must be inverted
  41253. */
  41254. reverseLeftRight: boolean;
  41255. /**
  41256. * Gets or sets a boolean indicating that up and down values must be inverted
  41257. */
  41258. reverseUpDown: boolean;
  41259. /**
  41260. * Gets the offset value for the position (ie. the change of the position value)
  41261. */
  41262. deltaPosition: Vector3;
  41263. /**
  41264. * Gets a boolean indicating if the virtual joystick was pressed
  41265. */
  41266. pressed: boolean;
  41267. /**
  41268. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41269. */
  41270. static Canvas: Nullable<HTMLCanvasElement>;
  41271. private static _globalJoystickIndex;
  41272. private static vjCanvasContext;
  41273. private static vjCanvasWidth;
  41274. private static vjCanvasHeight;
  41275. private static halfWidth;
  41276. private _action;
  41277. private _axisTargetedByLeftAndRight;
  41278. private _axisTargetedByUpAndDown;
  41279. private _joystickSensibility;
  41280. private _inversedSensibility;
  41281. private _joystickPointerID;
  41282. private _joystickColor;
  41283. private _joystickPointerPos;
  41284. private _joystickPreviousPointerPos;
  41285. private _joystickPointerStartPos;
  41286. private _deltaJoystickVector;
  41287. private _leftJoystick;
  41288. private _touches;
  41289. private _onPointerDownHandlerRef;
  41290. private _onPointerMoveHandlerRef;
  41291. private _onPointerUpHandlerRef;
  41292. private _onResize;
  41293. /**
  41294. * Creates a new virtual joystick
  41295. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41296. */
  41297. constructor(leftJoystick?: boolean);
  41298. /**
  41299. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41300. * @param newJoystickSensibility defines the new sensibility
  41301. */
  41302. setJoystickSensibility(newJoystickSensibility: number): void;
  41303. private _onPointerDown;
  41304. private _onPointerMove;
  41305. private _onPointerUp;
  41306. /**
  41307. * Change the color of the virtual joystick
  41308. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41309. */
  41310. setJoystickColor(newColor: string): void;
  41311. /**
  41312. * Defines a callback to call when the joystick is touched
  41313. * @param action defines the callback
  41314. */
  41315. setActionOnTouch(action: () => any): void;
  41316. /**
  41317. * Defines which axis you'd like to control for left & right
  41318. * @param axis defines the axis to use
  41319. */
  41320. setAxisForLeftRight(axis: JoystickAxis): void;
  41321. /**
  41322. * Defines which axis you'd like to control for up & down
  41323. * @param axis defines the axis to use
  41324. */
  41325. setAxisForUpDown(axis: JoystickAxis): void;
  41326. private _drawVirtualJoystick;
  41327. /**
  41328. * Release internal HTML canvas
  41329. */
  41330. releaseCanvas(): void;
  41331. }
  41332. }
  41333. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41334. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41335. import { Nullable } from "babylonjs/types";
  41336. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41337. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41338. module "babylonjs/Cameras/freeCameraInputsManager" {
  41339. interface FreeCameraInputsManager {
  41340. /**
  41341. * Add virtual joystick input support to the input manager.
  41342. * @returns the current input manager
  41343. */
  41344. addVirtualJoystick(): FreeCameraInputsManager;
  41345. }
  41346. }
  41347. /**
  41348. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41350. */
  41351. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41352. /**
  41353. * Defines the camera the input is attached to.
  41354. */
  41355. camera: FreeCamera;
  41356. private _leftjoystick;
  41357. private _rightjoystick;
  41358. /**
  41359. * Gets the left stick of the virtual joystick.
  41360. * @returns The virtual Joystick
  41361. */
  41362. getLeftJoystick(): VirtualJoystick;
  41363. /**
  41364. * Gets the right stick of the virtual joystick.
  41365. * @returns The virtual Joystick
  41366. */
  41367. getRightJoystick(): VirtualJoystick;
  41368. /**
  41369. * Update the current camera state depending on the inputs that have been used this frame.
  41370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41371. */
  41372. checkInputs(): void;
  41373. /**
  41374. * Attach the input controls to a specific dom element to get the input from.
  41375. * @param element Defines the element the controls should be listened from
  41376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41377. */
  41378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41379. /**
  41380. * Detach the current controls from the specified dom element.
  41381. * @param element Defines the element to stop listening the inputs from
  41382. */
  41383. detachControl(element: Nullable<HTMLElement>): void;
  41384. /**
  41385. * Gets the class name of the current intput.
  41386. * @returns the class name
  41387. */
  41388. getClassName(): string;
  41389. /**
  41390. * Get the friendly name associated with the input class.
  41391. * @returns the input friendly name
  41392. */
  41393. getSimpleName(): string;
  41394. }
  41395. }
  41396. declare module "babylonjs/Cameras/Inputs/index" {
  41397. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41398. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41399. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41400. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41401. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41402. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41403. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41404. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41405. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41406. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41407. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41408. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41409. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41410. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41411. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41412. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41413. }
  41414. declare module "babylonjs/Cameras/touchCamera" {
  41415. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41416. import { Scene } from "babylonjs/scene";
  41417. import { Vector3 } from "babylonjs/Maths/math.vector";
  41418. /**
  41419. * This represents a FPS type of camera controlled by touch.
  41420. * This is like a universal camera minus the Gamepad controls.
  41421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41422. */
  41423. export class TouchCamera extends FreeCamera {
  41424. /**
  41425. * Defines the touch sensibility for rotation.
  41426. * The higher the faster.
  41427. */
  41428. touchAngularSensibility: number;
  41429. /**
  41430. * Defines the touch sensibility for move.
  41431. * The higher the faster.
  41432. */
  41433. touchMoveSensibility: number;
  41434. /**
  41435. * Instantiates a new touch camera.
  41436. * This represents a FPS type of camera controlled by touch.
  41437. * This is like a universal camera minus the Gamepad controls.
  41438. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41439. * @param name Define the name of the camera in the scene
  41440. * @param position Define the start position of the camera in the scene
  41441. * @param scene Define the scene the camera belongs to
  41442. */
  41443. constructor(name: string, position: Vector3, scene: Scene);
  41444. /**
  41445. * Gets the current object class name.
  41446. * @return the class name
  41447. */
  41448. getClassName(): string;
  41449. /** @hidden */
  41450. _setupInputs(): void;
  41451. }
  41452. }
  41453. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41454. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41455. import { Scene } from "babylonjs/scene";
  41456. import { Vector3 } from "babylonjs/Maths/math.vector";
  41457. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41458. import { Axis } from "babylonjs/Maths/math.axis";
  41459. /**
  41460. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41461. * being tilted forward or back and left or right.
  41462. */
  41463. export class DeviceOrientationCamera extends FreeCamera {
  41464. private _initialQuaternion;
  41465. private _quaternionCache;
  41466. private _tmpDragQuaternion;
  41467. private _disablePointerInputWhenUsingDeviceOrientation;
  41468. /**
  41469. * Creates a new device orientation camera
  41470. * @param name The name of the camera
  41471. * @param position The start position camera
  41472. * @param scene The scene the camera belongs to
  41473. */
  41474. constructor(name: string, position: Vector3, scene: Scene);
  41475. /**
  41476. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41477. */
  41478. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41479. private _dragFactor;
  41480. /**
  41481. * Enabled turning on the y axis when the orientation sensor is active
  41482. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41483. */
  41484. enableHorizontalDragging(dragFactor?: number): void;
  41485. /**
  41486. * Gets the current instance class name ("DeviceOrientationCamera").
  41487. * This helps avoiding instanceof at run time.
  41488. * @returns the class name
  41489. */
  41490. getClassName(): string;
  41491. /**
  41492. * @hidden
  41493. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41494. */
  41495. _checkInputs(): void;
  41496. /**
  41497. * Reset the camera to its default orientation on the specified axis only.
  41498. * @param axis The axis to reset
  41499. */
  41500. resetToCurrentRotation(axis?: Axis): void;
  41501. }
  41502. }
  41503. declare module "babylonjs/Gamepads/xboxGamepad" {
  41504. import { Observable } from "babylonjs/Misc/observable";
  41505. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41506. /**
  41507. * Defines supported buttons for XBox360 compatible gamepads
  41508. */
  41509. export enum Xbox360Button {
  41510. /** A */
  41511. A = 0,
  41512. /** B */
  41513. B = 1,
  41514. /** X */
  41515. X = 2,
  41516. /** Y */
  41517. Y = 3,
  41518. /** Start */
  41519. Start = 4,
  41520. /** Back */
  41521. Back = 5,
  41522. /** Left button */
  41523. LB = 6,
  41524. /** Right button */
  41525. RB = 7,
  41526. /** Left stick */
  41527. LeftStick = 8,
  41528. /** Right stick */
  41529. RightStick = 9
  41530. }
  41531. /** Defines values for XBox360 DPad */
  41532. export enum Xbox360Dpad {
  41533. /** Up */
  41534. Up = 0,
  41535. /** Down */
  41536. Down = 1,
  41537. /** Left */
  41538. Left = 2,
  41539. /** Right */
  41540. Right = 3
  41541. }
  41542. /**
  41543. * Defines a XBox360 gamepad
  41544. */
  41545. export class Xbox360Pad extends Gamepad {
  41546. private _leftTrigger;
  41547. private _rightTrigger;
  41548. private _onlefttriggerchanged;
  41549. private _onrighttriggerchanged;
  41550. private _onbuttondown;
  41551. private _onbuttonup;
  41552. private _ondpaddown;
  41553. private _ondpadup;
  41554. /** Observable raised when a button is pressed */
  41555. onButtonDownObservable: Observable<Xbox360Button>;
  41556. /** Observable raised when a button is released */
  41557. onButtonUpObservable: Observable<Xbox360Button>;
  41558. /** Observable raised when a pad is pressed */
  41559. onPadDownObservable: Observable<Xbox360Dpad>;
  41560. /** Observable raised when a pad is released */
  41561. onPadUpObservable: Observable<Xbox360Dpad>;
  41562. private _buttonA;
  41563. private _buttonB;
  41564. private _buttonX;
  41565. private _buttonY;
  41566. private _buttonBack;
  41567. private _buttonStart;
  41568. private _buttonLB;
  41569. private _buttonRB;
  41570. private _buttonLeftStick;
  41571. private _buttonRightStick;
  41572. private _dPadUp;
  41573. private _dPadDown;
  41574. private _dPadLeft;
  41575. private _dPadRight;
  41576. private _isXboxOnePad;
  41577. /**
  41578. * Creates a new XBox360 gamepad object
  41579. * @param id defines the id of this gamepad
  41580. * @param index defines its index
  41581. * @param gamepad defines the internal HTML gamepad object
  41582. * @param xboxOne defines if it is a XBox One gamepad
  41583. */
  41584. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41585. /**
  41586. * Defines the callback to call when left trigger is pressed
  41587. * @param callback defines the callback to use
  41588. */
  41589. onlefttriggerchanged(callback: (value: number) => void): void;
  41590. /**
  41591. * Defines the callback to call when right trigger is pressed
  41592. * @param callback defines the callback to use
  41593. */
  41594. onrighttriggerchanged(callback: (value: number) => void): void;
  41595. /**
  41596. * Gets the left trigger value
  41597. */
  41598. /**
  41599. * Sets the left trigger value
  41600. */
  41601. leftTrigger: number;
  41602. /**
  41603. * Gets the right trigger value
  41604. */
  41605. /**
  41606. * Sets the right trigger value
  41607. */
  41608. rightTrigger: number;
  41609. /**
  41610. * Defines the callback to call when a button is pressed
  41611. * @param callback defines the callback to use
  41612. */
  41613. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41614. /**
  41615. * Defines the callback to call when a button is released
  41616. * @param callback defines the callback to use
  41617. */
  41618. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41619. /**
  41620. * Defines the callback to call when a pad is pressed
  41621. * @param callback defines the callback to use
  41622. */
  41623. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41624. /**
  41625. * Defines the callback to call when a pad is released
  41626. * @param callback defines the callback to use
  41627. */
  41628. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41629. private _setButtonValue;
  41630. private _setDPadValue;
  41631. /**
  41632. * Gets the value of the `A` button
  41633. */
  41634. /**
  41635. * Sets the value of the `A` button
  41636. */
  41637. buttonA: number;
  41638. /**
  41639. * Gets the value of the `B` button
  41640. */
  41641. /**
  41642. * Sets the value of the `B` button
  41643. */
  41644. buttonB: number;
  41645. /**
  41646. * Gets the value of the `X` button
  41647. */
  41648. /**
  41649. * Sets the value of the `X` button
  41650. */
  41651. buttonX: number;
  41652. /**
  41653. * Gets the value of the `Y` button
  41654. */
  41655. /**
  41656. * Sets the value of the `Y` button
  41657. */
  41658. buttonY: number;
  41659. /**
  41660. * Gets the value of the `Start` button
  41661. */
  41662. /**
  41663. * Sets the value of the `Start` button
  41664. */
  41665. buttonStart: number;
  41666. /**
  41667. * Gets the value of the `Back` button
  41668. */
  41669. /**
  41670. * Sets the value of the `Back` button
  41671. */
  41672. buttonBack: number;
  41673. /**
  41674. * Gets the value of the `Left` button
  41675. */
  41676. /**
  41677. * Sets the value of the `Left` button
  41678. */
  41679. buttonLB: number;
  41680. /**
  41681. * Gets the value of the `Right` button
  41682. */
  41683. /**
  41684. * Sets the value of the `Right` button
  41685. */
  41686. buttonRB: number;
  41687. /**
  41688. * Gets the value of the Left joystick
  41689. */
  41690. /**
  41691. * Sets the value of the Left joystick
  41692. */
  41693. buttonLeftStick: number;
  41694. /**
  41695. * Gets the value of the Right joystick
  41696. */
  41697. /**
  41698. * Sets the value of the Right joystick
  41699. */
  41700. buttonRightStick: number;
  41701. /**
  41702. * Gets the value of D-pad up
  41703. */
  41704. /**
  41705. * Sets the value of D-pad up
  41706. */
  41707. dPadUp: number;
  41708. /**
  41709. * Gets the value of D-pad down
  41710. */
  41711. /**
  41712. * Sets the value of D-pad down
  41713. */
  41714. dPadDown: number;
  41715. /**
  41716. * Gets the value of D-pad left
  41717. */
  41718. /**
  41719. * Sets the value of D-pad left
  41720. */
  41721. dPadLeft: number;
  41722. /**
  41723. * Gets the value of D-pad right
  41724. */
  41725. /**
  41726. * Sets the value of D-pad right
  41727. */
  41728. dPadRight: number;
  41729. /**
  41730. * Force the gamepad to synchronize with device values
  41731. */
  41732. update(): void;
  41733. /**
  41734. * Disposes the gamepad
  41735. */
  41736. dispose(): void;
  41737. }
  41738. }
  41739. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41740. import { Observable } from "babylonjs/Misc/observable";
  41741. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41742. /**
  41743. * Defines supported buttons for DualShock compatible gamepads
  41744. */
  41745. export enum DualShockButton {
  41746. /** Cross */
  41747. Cross = 0,
  41748. /** Circle */
  41749. Circle = 1,
  41750. /** Square */
  41751. Square = 2,
  41752. /** Triangle */
  41753. Triangle = 3,
  41754. /** Options */
  41755. Options = 4,
  41756. /** Share */
  41757. Share = 5,
  41758. /** L1 */
  41759. L1 = 6,
  41760. /** R1 */
  41761. R1 = 7,
  41762. /** Left stick */
  41763. LeftStick = 8,
  41764. /** Right stick */
  41765. RightStick = 9
  41766. }
  41767. /** Defines values for DualShock DPad */
  41768. export enum DualShockDpad {
  41769. /** Up */
  41770. Up = 0,
  41771. /** Down */
  41772. Down = 1,
  41773. /** Left */
  41774. Left = 2,
  41775. /** Right */
  41776. Right = 3
  41777. }
  41778. /**
  41779. * Defines a DualShock gamepad
  41780. */
  41781. export class DualShockPad extends Gamepad {
  41782. private _leftTrigger;
  41783. private _rightTrigger;
  41784. private _onlefttriggerchanged;
  41785. private _onrighttriggerchanged;
  41786. private _onbuttondown;
  41787. private _onbuttonup;
  41788. private _ondpaddown;
  41789. private _ondpadup;
  41790. /** Observable raised when a button is pressed */
  41791. onButtonDownObservable: Observable<DualShockButton>;
  41792. /** Observable raised when a button is released */
  41793. onButtonUpObservable: Observable<DualShockButton>;
  41794. /** Observable raised when a pad is pressed */
  41795. onPadDownObservable: Observable<DualShockDpad>;
  41796. /** Observable raised when a pad is released */
  41797. onPadUpObservable: Observable<DualShockDpad>;
  41798. private _buttonCross;
  41799. private _buttonCircle;
  41800. private _buttonSquare;
  41801. private _buttonTriangle;
  41802. private _buttonShare;
  41803. private _buttonOptions;
  41804. private _buttonL1;
  41805. private _buttonR1;
  41806. private _buttonLeftStick;
  41807. private _buttonRightStick;
  41808. private _dPadUp;
  41809. private _dPadDown;
  41810. private _dPadLeft;
  41811. private _dPadRight;
  41812. /**
  41813. * Creates a new DualShock gamepad object
  41814. * @param id defines the id of this gamepad
  41815. * @param index defines its index
  41816. * @param gamepad defines the internal HTML gamepad object
  41817. */
  41818. constructor(id: string, index: number, gamepad: any);
  41819. /**
  41820. * Defines the callback to call when left trigger is pressed
  41821. * @param callback defines the callback to use
  41822. */
  41823. onlefttriggerchanged(callback: (value: number) => void): void;
  41824. /**
  41825. * Defines the callback to call when right trigger is pressed
  41826. * @param callback defines the callback to use
  41827. */
  41828. onrighttriggerchanged(callback: (value: number) => void): void;
  41829. /**
  41830. * Gets the left trigger value
  41831. */
  41832. /**
  41833. * Sets the left trigger value
  41834. */
  41835. leftTrigger: number;
  41836. /**
  41837. * Gets the right trigger value
  41838. */
  41839. /**
  41840. * Sets the right trigger value
  41841. */
  41842. rightTrigger: number;
  41843. /**
  41844. * Defines the callback to call when a button is pressed
  41845. * @param callback defines the callback to use
  41846. */
  41847. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41848. /**
  41849. * Defines the callback to call when a button is released
  41850. * @param callback defines the callback to use
  41851. */
  41852. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41853. /**
  41854. * Defines the callback to call when a pad is pressed
  41855. * @param callback defines the callback to use
  41856. */
  41857. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41858. /**
  41859. * Defines the callback to call when a pad is released
  41860. * @param callback defines the callback to use
  41861. */
  41862. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41863. private _setButtonValue;
  41864. private _setDPadValue;
  41865. /**
  41866. * Gets the value of the `Cross` button
  41867. */
  41868. /**
  41869. * Sets the value of the `Cross` button
  41870. */
  41871. buttonCross: number;
  41872. /**
  41873. * Gets the value of the `Circle` button
  41874. */
  41875. /**
  41876. * Sets the value of the `Circle` button
  41877. */
  41878. buttonCircle: number;
  41879. /**
  41880. * Gets the value of the `Square` button
  41881. */
  41882. /**
  41883. * Sets the value of the `Square` button
  41884. */
  41885. buttonSquare: number;
  41886. /**
  41887. * Gets the value of the `Triangle` button
  41888. */
  41889. /**
  41890. * Sets the value of the `Triangle` button
  41891. */
  41892. buttonTriangle: number;
  41893. /**
  41894. * Gets the value of the `Options` button
  41895. */
  41896. /**
  41897. * Sets the value of the `Options` button
  41898. */
  41899. buttonOptions: number;
  41900. /**
  41901. * Gets the value of the `Share` button
  41902. */
  41903. /**
  41904. * Sets the value of the `Share` button
  41905. */
  41906. buttonShare: number;
  41907. /**
  41908. * Gets the value of the `L1` button
  41909. */
  41910. /**
  41911. * Sets the value of the `L1` button
  41912. */
  41913. buttonL1: number;
  41914. /**
  41915. * Gets the value of the `R1` button
  41916. */
  41917. /**
  41918. * Sets the value of the `R1` button
  41919. */
  41920. buttonR1: number;
  41921. /**
  41922. * Gets the value of the Left joystick
  41923. */
  41924. /**
  41925. * Sets the value of the Left joystick
  41926. */
  41927. buttonLeftStick: number;
  41928. /**
  41929. * Gets the value of the Right joystick
  41930. */
  41931. /**
  41932. * Sets the value of the Right joystick
  41933. */
  41934. buttonRightStick: number;
  41935. /**
  41936. * Gets the value of D-pad up
  41937. */
  41938. /**
  41939. * Sets the value of D-pad up
  41940. */
  41941. dPadUp: number;
  41942. /**
  41943. * Gets the value of D-pad down
  41944. */
  41945. /**
  41946. * Sets the value of D-pad down
  41947. */
  41948. dPadDown: number;
  41949. /**
  41950. * Gets the value of D-pad left
  41951. */
  41952. /**
  41953. * Sets the value of D-pad left
  41954. */
  41955. dPadLeft: number;
  41956. /**
  41957. * Gets the value of D-pad right
  41958. */
  41959. /**
  41960. * Sets the value of D-pad right
  41961. */
  41962. dPadRight: number;
  41963. /**
  41964. * Force the gamepad to synchronize with device values
  41965. */
  41966. update(): void;
  41967. /**
  41968. * Disposes the gamepad
  41969. */
  41970. dispose(): void;
  41971. }
  41972. }
  41973. declare module "babylonjs/Gamepads/gamepadManager" {
  41974. import { Observable } from "babylonjs/Misc/observable";
  41975. import { Nullable } from "babylonjs/types";
  41976. import { Scene } from "babylonjs/scene";
  41977. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41978. /**
  41979. * Manager for handling gamepads
  41980. */
  41981. export class GamepadManager {
  41982. private _scene?;
  41983. private _babylonGamepads;
  41984. private _oneGamepadConnected;
  41985. /** @hidden */
  41986. _isMonitoring: boolean;
  41987. private _gamepadEventSupported;
  41988. private _gamepadSupport;
  41989. /**
  41990. * observable to be triggered when the gamepad controller has been connected
  41991. */
  41992. onGamepadConnectedObservable: Observable<Gamepad>;
  41993. /**
  41994. * observable to be triggered when the gamepad controller has been disconnected
  41995. */
  41996. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41997. private _onGamepadConnectedEvent;
  41998. private _onGamepadDisconnectedEvent;
  41999. /**
  42000. * Initializes the gamepad manager
  42001. * @param _scene BabylonJS scene
  42002. */
  42003. constructor(_scene?: Scene | undefined);
  42004. /**
  42005. * The gamepads in the game pad manager
  42006. */
  42007. readonly gamepads: Gamepad[];
  42008. /**
  42009. * Get the gamepad controllers based on type
  42010. * @param type The type of gamepad controller
  42011. * @returns Nullable gamepad
  42012. */
  42013. getGamepadByType(type?: number): Nullable<Gamepad>;
  42014. /**
  42015. * Disposes the gamepad manager
  42016. */
  42017. dispose(): void;
  42018. private _addNewGamepad;
  42019. private _startMonitoringGamepads;
  42020. private _stopMonitoringGamepads;
  42021. /** @hidden */
  42022. _checkGamepadsStatus(): void;
  42023. private _updateGamepadObjects;
  42024. }
  42025. }
  42026. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42027. import { Nullable } from "babylonjs/types";
  42028. import { Scene } from "babylonjs/scene";
  42029. import { ISceneComponent } from "babylonjs/sceneComponent";
  42030. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42031. module "babylonjs/scene" {
  42032. interface Scene {
  42033. /** @hidden */
  42034. _gamepadManager: Nullable<GamepadManager>;
  42035. /**
  42036. * Gets the gamepad manager associated with the scene
  42037. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42038. */
  42039. gamepadManager: GamepadManager;
  42040. }
  42041. }
  42042. module "babylonjs/Cameras/freeCameraInputsManager" {
  42043. /**
  42044. * Interface representing a free camera inputs manager
  42045. */
  42046. interface FreeCameraInputsManager {
  42047. /**
  42048. * Adds gamepad input support to the FreeCameraInputsManager.
  42049. * @returns the FreeCameraInputsManager
  42050. */
  42051. addGamepad(): FreeCameraInputsManager;
  42052. }
  42053. }
  42054. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42055. /**
  42056. * Interface representing an arc rotate camera inputs manager
  42057. */
  42058. interface ArcRotateCameraInputsManager {
  42059. /**
  42060. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42061. * @returns the camera inputs manager
  42062. */
  42063. addGamepad(): ArcRotateCameraInputsManager;
  42064. }
  42065. }
  42066. /**
  42067. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42068. */
  42069. export class GamepadSystemSceneComponent implements ISceneComponent {
  42070. /**
  42071. * The component name helpfull to identify the component in the list of scene components.
  42072. */
  42073. readonly name: string;
  42074. /**
  42075. * The scene the component belongs to.
  42076. */
  42077. scene: Scene;
  42078. /**
  42079. * Creates a new instance of the component for the given scene
  42080. * @param scene Defines the scene to register the component in
  42081. */
  42082. constructor(scene: Scene);
  42083. /**
  42084. * Registers the component in a given scene
  42085. */
  42086. register(): void;
  42087. /**
  42088. * Rebuilds the elements related to this component in case of
  42089. * context lost for instance.
  42090. */
  42091. rebuild(): void;
  42092. /**
  42093. * Disposes the component and the associated ressources
  42094. */
  42095. dispose(): void;
  42096. private _beforeCameraUpdate;
  42097. }
  42098. }
  42099. declare module "babylonjs/Cameras/universalCamera" {
  42100. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42101. import { Scene } from "babylonjs/scene";
  42102. import { Vector3 } from "babylonjs/Maths/math.vector";
  42103. import "babylonjs/Gamepads/gamepadSceneComponent";
  42104. /**
  42105. * 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,
  42106. * which still works and will still be found in many Playgrounds.
  42107. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42108. */
  42109. export class UniversalCamera extends TouchCamera {
  42110. /**
  42111. * Defines the gamepad rotation sensiblity.
  42112. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42113. */
  42114. gamepadAngularSensibility: number;
  42115. /**
  42116. * Defines the gamepad move sensiblity.
  42117. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42118. */
  42119. gamepadMoveSensibility: number;
  42120. /**
  42121. * 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,
  42122. * which still works and will still be found in many Playgrounds.
  42123. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42124. * @param name Define the name of the camera in the scene
  42125. * @param position Define the start position of the camera in the scene
  42126. * @param scene Define the scene the camera belongs to
  42127. */
  42128. constructor(name: string, position: Vector3, scene: Scene);
  42129. /**
  42130. * Gets the current object class name.
  42131. * @return the class name
  42132. */
  42133. getClassName(): string;
  42134. }
  42135. }
  42136. declare module "babylonjs/Cameras/gamepadCamera" {
  42137. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42138. import { Scene } from "babylonjs/scene";
  42139. import { Vector3 } from "babylonjs/Maths/math.vector";
  42140. /**
  42141. * This represents a FPS type of camera. This is only here for back compat purpose.
  42142. * Please use the UniversalCamera instead as both are identical.
  42143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42144. */
  42145. export class GamepadCamera extends UniversalCamera {
  42146. /**
  42147. * Instantiates a new Gamepad Camera
  42148. * This represents a FPS type of camera. This is only here for back compat purpose.
  42149. * Please use the UniversalCamera instead as both are identical.
  42150. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42151. * @param name Define the name of the camera in the scene
  42152. * @param position Define the start position of the camera in the scene
  42153. * @param scene Define the scene the camera belongs to
  42154. */
  42155. constructor(name: string, position: Vector3, scene: Scene);
  42156. /**
  42157. * Gets the current object class name.
  42158. * @return the class name
  42159. */
  42160. getClassName(): string;
  42161. }
  42162. }
  42163. declare module "babylonjs/Shaders/pass.fragment" {
  42164. /** @hidden */
  42165. export var passPixelShader: {
  42166. name: string;
  42167. shader: string;
  42168. };
  42169. }
  42170. declare module "babylonjs/Shaders/passCube.fragment" {
  42171. /** @hidden */
  42172. export var passCubePixelShader: {
  42173. name: string;
  42174. shader: string;
  42175. };
  42176. }
  42177. declare module "babylonjs/PostProcesses/passPostProcess" {
  42178. import { Nullable } from "babylonjs/types";
  42179. import { Camera } from "babylonjs/Cameras/camera";
  42180. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42181. import { Engine } from "babylonjs/Engines/engine";
  42182. import "babylonjs/Shaders/pass.fragment";
  42183. import "babylonjs/Shaders/passCube.fragment";
  42184. /**
  42185. * PassPostProcess which produces an output the same as it's input
  42186. */
  42187. export class PassPostProcess extends PostProcess {
  42188. /**
  42189. * Creates the PassPostProcess
  42190. * @param name The name of the effect.
  42191. * @param options The required width/height ratio to downsize to before computing the render pass.
  42192. * @param camera The camera to apply the render pass to.
  42193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42194. * @param engine The engine which the post process will be applied. (default: current engine)
  42195. * @param reusable If the post process can be reused on the same frame. (default: false)
  42196. * @param textureType The type of texture to be used when performing the post processing.
  42197. * @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)
  42198. */
  42199. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42200. }
  42201. /**
  42202. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42203. */
  42204. export class PassCubePostProcess extends PostProcess {
  42205. private _face;
  42206. /**
  42207. * Gets or sets the cube face to display.
  42208. * * 0 is +X
  42209. * * 1 is -X
  42210. * * 2 is +Y
  42211. * * 3 is -Y
  42212. * * 4 is +Z
  42213. * * 5 is -Z
  42214. */
  42215. face: number;
  42216. /**
  42217. * Creates the PassCubePostProcess
  42218. * @param name The name of the effect.
  42219. * @param options The required width/height ratio to downsize to before computing the render pass.
  42220. * @param camera The camera to apply the render pass to.
  42221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42222. * @param engine The engine which the post process will be applied. (default: current engine)
  42223. * @param reusable If the post process can be reused on the same frame. (default: false)
  42224. * @param textureType The type of texture to be used when performing the post processing.
  42225. * @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)
  42226. */
  42227. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42228. }
  42229. }
  42230. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42231. /** @hidden */
  42232. export var anaglyphPixelShader: {
  42233. name: string;
  42234. shader: string;
  42235. };
  42236. }
  42237. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42238. import { Engine } from "babylonjs/Engines/engine";
  42239. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42240. import { Camera } from "babylonjs/Cameras/camera";
  42241. import "babylonjs/Shaders/anaglyph.fragment";
  42242. /**
  42243. * Postprocess used to generate anaglyphic rendering
  42244. */
  42245. export class AnaglyphPostProcess extends PostProcess {
  42246. private _passedProcess;
  42247. /**
  42248. * Creates a new AnaglyphPostProcess
  42249. * @param name defines postprocess name
  42250. * @param options defines creation options or target ratio scale
  42251. * @param rigCameras defines cameras using this postprocess
  42252. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42253. * @param engine defines hosting engine
  42254. * @param reusable defines if the postprocess will be reused multiple times per frame
  42255. */
  42256. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42257. }
  42258. }
  42259. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42260. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42261. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42262. import { Scene } from "babylonjs/scene";
  42263. import { Vector3 } from "babylonjs/Maths/math.vector";
  42264. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42265. /**
  42266. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42267. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42268. */
  42269. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42270. /**
  42271. * Creates a new AnaglyphArcRotateCamera
  42272. * @param name defines camera name
  42273. * @param alpha defines alpha angle (in radians)
  42274. * @param beta defines beta angle (in radians)
  42275. * @param radius defines radius
  42276. * @param target defines camera target
  42277. * @param interaxialDistance defines distance between each color axis
  42278. * @param scene defines the hosting scene
  42279. */
  42280. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42281. /**
  42282. * Gets camera class name
  42283. * @returns AnaglyphArcRotateCamera
  42284. */
  42285. getClassName(): string;
  42286. }
  42287. }
  42288. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42289. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42290. import { Scene } from "babylonjs/scene";
  42291. import { Vector3 } from "babylonjs/Maths/math.vector";
  42292. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42293. /**
  42294. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42295. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42296. */
  42297. export class AnaglyphFreeCamera extends FreeCamera {
  42298. /**
  42299. * Creates a new AnaglyphFreeCamera
  42300. * @param name defines camera name
  42301. * @param position defines initial position
  42302. * @param interaxialDistance defines distance between each color axis
  42303. * @param scene defines the hosting scene
  42304. */
  42305. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42306. /**
  42307. * Gets camera class name
  42308. * @returns AnaglyphFreeCamera
  42309. */
  42310. getClassName(): string;
  42311. }
  42312. }
  42313. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42314. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42315. import { Scene } from "babylonjs/scene";
  42316. import { Vector3 } from "babylonjs/Maths/math.vector";
  42317. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42318. /**
  42319. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42320. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42321. */
  42322. export class AnaglyphGamepadCamera extends GamepadCamera {
  42323. /**
  42324. * Creates a new AnaglyphGamepadCamera
  42325. * @param name defines camera name
  42326. * @param position defines initial position
  42327. * @param interaxialDistance defines distance between each color axis
  42328. * @param scene defines the hosting scene
  42329. */
  42330. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42331. /**
  42332. * Gets camera class name
  42333. * @returns AnaglyphGamepadCamera
  42334. */
  42335. getClassName(): string;
  42336. }
  42337. }
  42338. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42339. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42340. import { Scene } from "babylonjs/scene";
  42341. import { Vector3 } from "babylonjs/Maths/math.vector";
  42342. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42343. /**
  42344. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42345. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42346. */
  42347. export class AnaglyphUniversalCamera extends UniversalCamera {
  42348. /**
  42349. * Creates a new AnaglyphUniversalCamera
  42350. * @param name defines camera name
  42351. * @param position defines initial position
  42352. * @param interaxialDistance defines distance between each color axis
  42353. * @param scene defines the hosting scene
  42354. */
  42355. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42356. /**
  42357. * Gets camera class name
  42358. * @returns AnaglyphUniversalCamera
  42359. */
  42360. getClassName(): string;
  42361. }
  42362. }
  42363. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42364. /** @hidden */
  42365. export var stereoscopicInterlacePixelShader: {
  42366. name: string;
  42367. shader: string;
  42368. };
  42369. }
  42370. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42371. import { Camera } from "babylonjs/Cameras/camera";
  42372. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42373. import { Engine } from "babylonjs/Engines/engine";
  42374. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42375. /**
  42376. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42377. */
  42378. export class StereoscopicInterlacePostProcess extends PostProcess {
  42379. private _stepSize;
  42380. private _passedProcess;
  42381. /**
  42382. * Initializes a StereoscopicInterlacePostProcess
  42383. * @param name The name of the effect.
  42384. * @param rigCameras The rig cameras to be appled to the post process
  42385. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42387. * @param engine The engine which the post process will be applied. (default: current engine)
  42388. * @param reusable If the post process can be reused on the same frame. (default: false)
  42389. */
  42390. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42391. }
  42392. }
  42393. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42394. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42395. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42396. import { Scene } from "babylonjs/scene";
  42397. import { Vector3 } from "babylonjs/Maths/math.vector";
  42398. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42399. /**
  42400. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42401. * @see http://doc.babylonjs.com/features/cameras
  42402. */
  42403. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42404. /**
  42405. * Creates a new StereoscopicArcRotateCamera
  42406. * @param name defines camera name
  42407. * @param alpha defines alpha angle (in radians)
  42408. * @param beta defines beta angle (in radians)
  42409. * @param radius defines radius
  42410. * @param target defines camera target
  42411. * @param interaxialDistance defines distance between each color axis
  42412. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42413. * @param scene defines the hosting scene
  42414. */
  42415. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42416. /**
  42417. * Gets camera class name
  42418. * @returns StereoscopicArcRotateCamera
  42419. */
  42420. getClassName(): string;
  42421. }
  42422. }
  42423. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42424. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42425. import { Scene } from "babylonjs/scene";
  42426. import { Vector3 } from "babylonjs/Maths/math.vector";
  42427. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42428. /**
  42429. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42430. * @see http://doc.babylonjs.com/features/cameras
  42431. */
  42432. export class StereoscopicFreeCamera extends FreeCamera {
  42433. /**
  42434. * Creates a new StereoscopicFreeCamera
  42435. * @param name defines camera name
  42436. * @param position defines initial position
  42437. * @param interaxialDistance defines distance between each color axis
  42438. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42439. * @param scene defines the hosting scene
  42440. */
  42441. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42442. /**
  42443. * Gets camera class name
  42444. * @returns StereoscopicFreeCamera
  42445. */
  42446. getClassName(): string;
  42447. }
  42448. }
  42449. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42450. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42451. import { Scene } from "babylonjs/scene";
  42452. import { Vector3 } from "babylonjs/Maths/math.vector";
  42453. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42454. /**
  42455. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42456. * @see http://doc.babylonjs.com/features/cameras
  42457. */
  42458. export class StereoscopicGamepadCamera extends GamepadCamera {
  42459. /**
  42460. * Creates a new StereoscopicGamepadCamera
  42461. * @param name defines camera name
  42462. * @param position defines initial position
  42463. * @param interaxialDistance defines distance between each color axis
  42464. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42465. * @param scene defines the hosting scene
  42466. */
  42467. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42468. /**
  42469. * Gets camera class name
  42470. * @returns StereoscopicGamepadCamera
  42471. */
  42472. getClassName(): string;
  42473. }
  42474. }
  42475. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42476. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42477. import { Scene } from "babylonjs/scene";
  42478. import { Vector3 } from "babylonjs/Maths/math.vector";
  42479. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42480. /**
  42481. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42482. * @see http://doc.babylonjs.com/features/cameras
  42483. */
  42484. export class StereoscopicUniversalCamera extends UniversalCamera {
  42485. /**
  42486. * Creates a new StereoscopicUniversalCamera
  42487. * @param name defines camera name
  42488. * @param position defines initial position
  42489. * @param interaxialDistance defines distance between each color axis
  42490. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42491. * @param scene defines the hosting scene
  42492. */
  42493. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42494. /**
  42495. * Gets camera class name
  42496. * @returns StereoscopicUniversalCamera
  42497. */
  42498. getClassName(): string;
  42499. }
  42500. }
  42501. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42502. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42503. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42504. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42505. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42506. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42507. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42508. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42509. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42510. }
  42511. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42513. import { Scene } from "babylonjs/scene";
  42514. import { Vector3 } from "babylonjs/Maths/math.vector";
  42515. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42516. /**
  42517. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42518. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42519. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42520. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42521. */
  42522. export class VirtualJoysticksCamera extends FreeCamera {
  42523. /**
  42524. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42525. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42526. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42527. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42528. * @param name Define the name of the camera in the scene
  42529. * @param position Define the start position of the camera in the scene
  42530. * @param scene Define the scene the camera belongs to
  42531. */
  42532. constructor(name: string, position: Vector3, scene: Scene);
  42533. /**
  42534. * Gets the current object class name.
  42535. * @return the class name
  42536. */
  42537. getClassName(): string;
  42538. }
  42539. }
  42540. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42541. import { Matrix } from "babylonjs/Maths/math.vector";
  42542. /**
  42543. * This represents all the required metrics to create a VR camera.
  42544. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42545. */
  42546. export class VRCameraMetrics {
  42547. /**
  42548. * Define the horizontal resolution off the screen.
  42549. */
  42550. hResolution: number;
  42551. /**
  42552. * Define the vertical resolution off the screen.
  42553. */
  42554. vResolution: number;
  42555. /**
  42556. * Define the horizontal screen size.
  42557. */
  42558. hScreenSize: number;
  42559. /**
  42560. * Define the vertical screen size.
  42561. */
  42562. vScreenSize: number;
  42563. /**
  42564. * Define the vertical screen center position.
  42565. */
  42566. vScreenCenter: number;
  42567. /**
  42568. * Define the distance of the eyes to the screen.
  42569. */
  42570. eyeToScreenDistance: number;
  42571. /**
  42572. * Define the distance between both lenses
  42573. */
  42574. lensSeparationDistance: number;
  42575. /**
  42576. * Define the distance between both viewer's eyes.
  42577. */
  42578. interpupillaryDistance: number;
  42579. /**
  42580. * Define the distortion factor of the VR postprocess.
  42581. * Please, touch with care.
  42582. */
  42583. distortionK: number[];
  42584. /**
  42585. * Define the chromatic aberration correction factors for the VR post process.
  42586. */
  42587. chromaAbCorrection: number[];
  42588. /**
  42589. * Define the scale factor of the post process.
  42590. * The smaller the better but the slower.
  42591. */
  42592. postProcessScaleFactor: number;
  42593. /**
  42594. * Define an offset for the lens center.
  42595. */
  42596. lensCenterOffset: number;
  42597. /**
  42598. * Define if the current vr camera should compensate the distortion of the lense or not.
  42599. */
  42600. compensateDistortion: boolean;
  42601. /**
  42602. * Defines if multiview should be enabled when rendering (Default: false)
  42603. */
  42604. multiviewEnabled: boolean;
  42605. /**
  42606. * Gets the rendering aspect ratio based on the provided resolutions.
  42607. */
  42608. readonly aspectRatio: number;
  42609. /**
  42610. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42611. */
  42612. readonly aspectRatioFov: number;
  42613. /**
  42614. * @hidden
  42615. */
  42616. readonly leftHMatrix: Matrix;
  42617. /**
  42618. * @hidden
  42619. */
  42620. readonly rightHMatrix: Matrix;
  42621. /**
  42622. * @hidden
  42623. */
  42624. readonly leftPreViewMatrix: Matrix;
  42625. /**
  42626. * @hidden
  42627. */
  42628. readonly rightPreViewMatrix: Matrix;
  42629. /**
  42630. * Get the default VRMetrics based on the most generic setup.
  42631. * @returns the default vr metrics
  42632. */
  42633. static GetDefault(): VRCameraMetrics;
  42634. }
  42635. }
  42636. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42637. /** @hidden */
  42638. export var vrDistortionCorrectionPixelShader: {
  42639. name: string;
  42640. shader: string;
  42641. };
  42642. }
  42643. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42644. import { Camera } from "babylonjs/Cameras/camera";
  42645. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42646. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42647. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42648. /**
  42649. * VRDistortionCorrectionPostProcess used for mobile VR
  42650. */
  42651. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42652. private _isRightEye;
  42653. private _distortionFactors;
  42654. private _postProcessScaleFactor;
  42655. private _lensCenterOffset;
  42656. private _scaleIn;
  42657. private _scaleFactor;
  42658. private _lensCenter;
  42659. /**
  42660. * Initializes the VRDistortionCorrectionPostProcess
  42661. * @param name The name of the effect.
  42662. * @param camera The camera to apply the render pass to.
  42663. * @param isRightEye If this is for the right eye distortion
  42664. * @param vrMetrics All the required metrics for the VR camera
  42665. */
  42666. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42667. }
  42668. }
  42669. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42670. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42671. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42672. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42673. import { Scene } from "babylonjs/scene";
  42674. import { Vector3 } from "babylonjs/Maths/math.vector";
  42675. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42676. import "babylonjs/Cameras/RigModes/vrRigMode";
  42677. /**
  42678. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42679. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42680. */
  42681. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42682. /**
  42683. * Creates a new VRDeviceOrientationArcRotateCamera
  42684. * @param name defines camera name
  42685. * @param alpha defines the camera rotation along the logitudinal axis
  42686. * @param beta defines the camera rotation along the latitudinal axis
  42687. * @param radius defines the camera distance from its target
  42688. * @param target defines the camera target
  42689. * @param scene defines the scene the camera belongs to
  42690. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42691. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42692. */
  42693. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42694. /**
  42695. * Gets camera class name
  42696. * @returns VRDeviceOrientationArcRotateCamera
  42697. */
  42698. getClassName(): string;
  42699. }
  42700. }
  42701. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42702. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42703. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42704. import { Scene } from "babylonjs/scene";
  42705. import { Vector3 } from "babylonjs/Maths/math.vector";
  42706. import "babylonjs/Cameras/RigModes/vrRigMode";
  42707. /**
  42708. * Camera used to simulate VR rendering (based on FreeCamera)
  42709. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42710. */
  42711. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42712. /**
  42713. * Creates a new VRDeviceOrientationFreeCamera
  42714. * @param name defines camera name
  42715. * @param position defines the start position of the camera
  42716. * @param scene defines the scene the camera belongs to
  42717. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42718. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42719. */
  42720. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42721. /**
  42722. * Gets camera class name
  42723. * @returns VRDeviceOrientationFreeCamera
  42724. */
  42725. getClassName(): string;
  42726. }
  42727. }
  42728. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42729. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42730. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42731. import { Scene } from "babylonjs/scene";
  42732. import { Vector3 } from "babylonjs/Maths/math.vector";
  42733. import "babylonjs/Gamepads/gamepadSceneComponent";
  42734. /**
  42735. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42736. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42737. */
  42738. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42739. /**
  42740. * Creates a new VRDeviceOrientationGamepadCamera
  42741. * @param name defines camera name
  42742. * @param position defines the start position of the camera
  42743. * @param scene defines the scene the camera belongs to
  42744. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42745. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42746. */
  42747. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42748. /**
  42749. * Gets camera class name
  42750. * @returns VRDeviceOrientationGamepadCamera
  42751. */
  42752. getClassName(): string;
  42753. }
  42754. }
  42755. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42756. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42758. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42759. /** @hidden */
  42760. export var imageProcessingPixelShader: {
  42761. name: string;
  42762. shader: string;
  42763. };
  42764. }
  42765. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42766. import { Nullable } from "babylonjs/types";
  42767. import { Color4 } from "babylonjs/Maths/math.color";
  42768. import { Camera } from "babylonjs/Cameras/camera";
  42769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42770. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42771. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42772. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42773. import { Engine } from "babylonjs/Engines/engine";
  42774. import "babylonjs/Shaders/imageProcessing.fragment";
  42775. import "babylonjs/Shaders/postprocess.vertex";
  42776. /**
  42777. * ImageProcessingPostProcess
  42778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42779. */
  42780. export class ImageProcessingPostProcess extends PostProcess {
  42781. /**
  42782. * Default configuration related to image processing available in the PBR Material.
  42783. */
  42784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42785. /**
  42786. * Gets the image processing configuration used either in this material.
  42787. */
  42788. /**
  42789. * Sets the Default image processing configuration used either in the this material.
  42790. *
  42791. * If sets to null, the scene one is in use.
  42792. */
  42793. imageProcessingConfiguration: ImageProcessingConfiguration;
  42794. /**
  42795. * Keep track of the image processing observer to allow dispose and replace.
  42796. */
  42797. private _imageProcessingObserver;
  42798. /**
  42799. * Attaches a new image processing configuration to the PBR Material.
  42800. * @param configuration
  42801. */
  42802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42803. /**
  42804. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42805. */
  42806. /**
  42807. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42808. */
  42809. colorCurves: Nullable<ColorCurves>;
  42810. /**
  42811. * Gets wether the color curves effect is enabled.
  42812. */
  42813. /**
  42814. * Sets wether the color curves effect is enabled.
  42815. */
  42816. colorCurvesEnabled: boolean;
  42817. /**
  42818. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42819. */
  42820. /**
  42821. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42822. */
  42823. colorGradingTexture: Nullable<BaseTexture>;
  42824. /**
  42825. * Gets wether the color grading effect is enabled.
  42826. */
  42827. /**
  42828. * Gets wether the color grading effect is enabled.
  42829. */
  42830. colorGradingEnabled: boolean;
  42831. /**
  42832. * Gets exposure used in the effect.
  42833. */
  42834. /**
  42835. * Sets exposure used in the effect.
  42836. */
  42837. exposure: number;
  42838. /**
  42839. * Gets wether tonemapping is enabled or not.
  42840. */
  42841. /**
  42842. * Sets wether tonemapping is enabled or not
  42843. */
  42844. toneMappingEnabled: boolean;
  42845. /**
  42846. * Gets the type of tone mapping effect.
  42847. */
  42848. /**
  42849. * Sets the type of tone mapping effect.
  42850. */
  42851. toneMappingType: number;
  42852. /**
  42853. * Gets contrast used in the effect.
  42854. */
  42855. /**
  42856. * Sets contrast used in the effect.
  42857. */
  42858. contrast: number;
  42859. /**
  42860. * Gets Vignette stretch size.
  42861. */
  42862. /**
  42863. * Sets Vignette stretch size.
  42864. */
  42865. vignetteStretch: number;
  42866. /**
  42867. * Gets Vignette centre X Offset.
  42868. */
  42869. /**
  42870. * Sets Vignette centre X Offset.
  42871. */
  42872. vignetteCentreX: number;
  42873. /**
  42874. * Gets Vignette centre Y Offset.
  42875. */
  42876. /**
  42877. * Sets Vignette centre Y Offset.
  42878. */
  42879. vignetteCentreY: number;
  42880. /**
  42881. * Gets Vignette weight or intensity of the vignette effect.
  42882. */
  42883. /**
  42884. * Sets Vignette weight or intensity of the vignette effect.
  42885. */
  42886. vignetteWeight: number;
  42887. /**
  42888. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42889. * if vignetteEnabled is set to true.
  42890. */
  42891. /**
  42892. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42893. * if vignetteEnabled is set to true.
  42894. */
  42895. vignetteColor: Color4;
  42896. /**
  42897. * Gets Camera field of view used by the Vignette effect.
  42898. */
  42899. /**
  42900. * Sets Camera field of view used by the Vignette effect.
  42901. */
  42902. vignetteCameraFov: number;
  42903. /**
  42904. * Gets the vignette blend mode allowing different kind of effect.
  42905. */
  42906. /**
  42907. * Sets the vignette blend mode allowing different kind of effect.
  42908. */
  42909. vignetteBlendMode: number;
  42910. /**
  42911. * Gets wether the vignette effect is enabled.
  42912. */
  42913. /**
  42914. * Sets wether the vignette effect is enabled.
  42915. */
  42916. vignetteEnabled: boolean;
  42917. private _fromLinearSpace;
  42918. /**
  42919. * Gets wether the input of the processing is in Gamma or Linear Space.
  42920. */
  42921. /**
  42922. * Sets wether the input of the processing is in Gamma or Linear Space.
  42923. */
  42924. fromLinearSpace: boolean;
  42925. /**
  42926. * Defines cache preventing GC.
  42927. */
  42928. private _defines;
  42929. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42930. /**
  42931. * "ImageProcessingPostProcess"
  42932. * @returns "ImageProcessingPostProcess"
  42933. */
  42934. getClassName(): string;
  42935. protected _updateParameters(): void;
  42936. dispose(camera?: Camera): void;
  42937. }
  42938. }
  42939. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42940. import { Scene } from "babylonjs/scene";
  42941. import { Color3 } from "babylonjs/Maths/math.color";
  42942. import { Mesh } from "babylonjs/Meshes/mesh";
  42943. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42944. import { Nullable } from "babylonjs/types";
  42945. /**
  42946. * Class containing static functions to help procedurally build meshes
  42947. */
  42948. export class GroundBuilder {
  42949. /**
  42950. * Creates a ground mesh
  42951. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42952. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42954. * @param name defines the name of the mesh
  42955. * @param options defines the options used to create the mesh
  42956. * @param scene defines the hosting scene
  42957. * @returns the ground mesh
  42958. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42959. */
  42960. static CreateGround(name: string, options: {
  42961. width?: number;
  42962. height?: number;
  42963. subdivisions?: number;
  42964. subdivisionsX?: number;
  42965. subdivisionsY?: number;
  42966. updatable?: boolean;
  42967. }, scene: any): Mesh;
  42968. /**
  42969. * Creates a tiled ground mesh
  42970. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42971. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42972. * * 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
  42973. * * 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
  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 tiled ground mesh
  42979. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42980. */
  42981. static CreateTiledGround(name: string, options: {
  42982. xmin: number;
  42983. zmin: number;
  42984. xmax: number;
  42985. zmax: number;
  42986. subdivisions?: {
  42987. w: number;
  42988. h: number;
  42989. };
  42990. precision?: {
  42991. w: number;
  42992. h: number;
  42993. };
  42994. updatable?: boolean;
  42995. }, scene?: Nullable<Scene>): Mesh;
  42996. /**
  42997. * Creates a ground mesh from a height map
  42998. * * The parameter `url` sets the URL of the height map image resource.
  42999. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43000. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43001. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43002. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43003. * * 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.
  43004. * * 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).
  43005. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43007. * @param name defines the name of the mesh
  43008. * @param url defines the url to the height map
  43009. * @param options defines the options used to create the mesh
  43010. * @param scene defines the hosting scene
  43011. * @returns the ground mesh
  43012. * @see https://doc.babylonjs.com/babylon101/height_map
  43013. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43014. */
  43015. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43016. width?: number;
  43017. height?: number;
  43018. subdivisions?: number;
  43019. minHeight?: number;
  43020. maxHeight?: number;
  43021. colorFilter?: Color3;
  43022. alphaFilter?: number;
  43023. updatable?: boolean;
  43024. onReady?: (mesh: GroundMesh) => void;
  43025. }, scene?: Nullable<Scene>): GroundMesh;
  43026. }
  43027. }
  43028. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43029. import { Vector4 } from "babylonjs/Maths/math.vector";
  43030. import { Mesh } from "babylonjs/Meshes/mesh";
  43031. /**
  43032. * Class containing static functions to help procedurally build meshes
  43033. */
  43034. export class TorusBuilder {
  43035. /**
  43036. * Creates a torus mesh
  43037. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43038. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43039. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43043. * @param name defines the name of the mesh
  43044. * @param options defines the options used to create the mesh
  43045. * @param scene defines the hosting scene
  43046. * @returns the torus mesh
  43047. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43048. */
  43049. static CreateTorus(name: string, options: {
  43050. diameter?: number;
  43051. thickness?: number;
  43052. tessellation?: number;
  43053. updatable?: boolean;
  43054. sideOrientation?: number;
  43055. frontUVs?: Vector4;
  43056. backUVs?: Vector4;
  43057. }, scene: any): Mesh;
  43058. }
  43059. }
  43060. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43061. import { Vector4 } from "babylonjs/Maths/math.vector";
  43062. import { Color4 } from "babylonjs/Maths/math.color";
  43063. import { Mesh } from "babylonjs/Meshes/mesh";
  43064. /**
  43065. * Class containing static functions to help procedurally build meshes
  43066. */
  43067. export class CylinderBuilder {
  43068. /**
  43069. * Creates a cylinder or a cone mesh
  43070. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43071. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43072. * * 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.
  43073. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43074. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43075. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43076. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43077. * * 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).
  43078. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43079. * * 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).
  43080. * * 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
  43081. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43082. * * 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
  43083. * * 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.
  43084. * * If `enclose` is false, a ring surface is one element.
  43085. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43086. * * 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
  43087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43090. * @param name defines the name of the mesh
  43091. * @param options defines the options used to create the mesh
  43092. * @param scene defines the hosting scene
  43093. * @returns the cylinder mesh
  43094. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43095. */
  43096. static CreateCylinder(name: string, options: {
  43097. height?: number;
  43098. diameterTop?: number;
  43099. diameterBottom?: number;
  43100. diameter?: number;
  43101. tessellation?: number;
  43102. subdivisions?: number;
  43103. arc?: number;
  43104. faceColors?: Color4[];
  43105. faceUV?: Vector4[];
  43106. updatable?: boolean;
  43107. hasRings?: boolean;
  43108. enclose?: boolean;
  43109. cap?: number;
  43110. sideOrientation?: number;
  43111. frontUVs?: Vector4;
  43112. backUVs?: Vector4;
  43113. }, scene: any): Mesh;
  43114. }
  43115. }
  43116. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43117. import { Nullable } from "babylonjs/types";
  43118. import { IDisposable } from "babylonjs/scene";
  43119. /**
  43120. * States of the webXR experience
  43121. */
  43122. export enum WebXRState {
  43123. /**
  43124. * Transitioning to being in XR mode
  43125. */
  43126. ENTERING_XR = 0,
  43127. /**
  43128. * Transitioning to non XR mode
  43129. */
  43130. EXITING_XR = 1,
  43131. /**
  43132. * In XR mode and presenting
  43133. */
  43134. IN_XR = 2,
  43135. /**
  43136. * Not entered XR mode
  43137. */
  43138. NOT_IN_XR = 3
  43139. }
  43140. /**
  43141. * Abstraction of the XR render target
  43142. */
  43143. export interface WebXRRenderTarget extends IDisposable {
  43144. /**
  43145. * xrpresent context of the canvas which can be used to display/mirror xr content
  43146. */
  43147. canvasContext: WebGLRenderingContext;
  43148. /**
  43149. * xr layer for the canvas
  43150. */
  43151. xrLayer: Nullable<XRWebGLLayer>;
  43152. /**
  43153. * Initializes the xr layer for the session
  43154. * @param xrSession xr session
  43155. * @returns a promise that will resolve once the XR Layer has been created
  43156. */
  43157. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43158. }
  43159. }
  43160. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43161. import { Nullable } from "babylonjs/types";
  43162. import { Observable } from "babylonjs/Misc/observable";
  43163. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43164. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43165. /**
  43166. * COnfiguration object for WebXR output canvas
  43167. */
  43168. export class WebXRManagedOutputCanvasOptions {
  43169. /**
  43170. * Options for this XR Layer output
  43171. */
  43172. canvasOptions: XRWebGLLayerOptions;
  43173. /**
  43174. * CSS styling for a newly created canvas (if not provided)
  43175. */
  43176. newCanvasCssStyle?: string;
  43177. /**
  43178. * Get the default values of the configuration object
  43179. * @returns default values of this configuration object
  43180. */
  43181. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43182. }
  43183. /**
  43184. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43185. */
  43186. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43187. private configuration;
  43188. private _engine;
  43189. private _canvas;
  43190. /**
  43191. * xrpresent context of the canvas which can be used to display/mirror xr content
  43192. */
  43193. canvasContext: WebGLRenderingContext;
  43194. /**
  43195. * xr layer for the canvas
  43196. */
  43197. xrLayer: Nullable<XRWebGLLayer>;
  43198. /**
  43199. * Initializes the xr layer for the session
  43200. * @param xrSession xr session
  43201. * @returns a promise that will resolve once the XR Layer has been created
  43202. */
  43203. initializeXRLayerAsync(xrSession: any): any;
  43204. /**
  43205. * Initializes the canvas to be added/removed upon entering/exiting xr
  43206. * @param engine the Babylon engine
  43207. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43208. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43209. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43210. */
  43211. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43212. /**
  43213. * Disposes of the object
  43214. */
  43215. dispose(): void;
  43216. private _setManagedOutputCanvas;
  43217. private _addCanvas;
  43218. private _removeCanvas;
  43219. }
  43220. }
  43221. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43222. import { Observable } from "babylonjs/Misc/observable";
  43223. import { Nullable } from "babylonjs/types";
  43224. import { IDisposable, Scene } from "babylonjs/scene";
  43225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43226. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43227. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43228. /**
  43229. * Manages an XRSession to work with Babylon's engine
  43230. * @see https://doc.babylonjs.com/how_to/webxr
  43231. */
  43232. export class WebXRSessionManager implements IDisposable {
  43233. private scene;
  43234. /**
  43235. * Fires every time a new xrFrame arrives which can be used to update the camera
  43236. */
  43237. onXRFrameObservable: Observable<any>;
  43238. /**
  43239. * Fires when the xr session is ended either by the device or manually done
  43240. */
  43241. onXRSessionEnded: Observable<any>;
  43242. /**
  43243. * Underlying xr session
  43244. */
  43245. session: XRSession;
  43246. /**
  43247. * Type of reference space used when creating the session
  43248. */
  43249. referenceSpace: XRReferenceSpace;
  43250. /**
  43251. * Current XR frame
  43252. */
  43253. currentFrame: Nullable<XRFrame>;
  43254. private _xrNavigator;
  43255. private baseLayer;
  43256. private _rttProvider;
  43257. private _sessionEnded;
  43258. /**
  43259. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43260. * @param scene The scene which the session should be created for
  43261. */
  43262. constructor(scene: Scene);
  43263. /**
  43264. * Initializes the manager
  43265. * After initialization enterXR can be called to start an XR session
  43266. * @returns Promise which resolves after it is initialized
  43267. */
  43268. initializeAsync(): Promise<void>;
  43269. /**
  43270. * Initializes an xr session
  43271. * @param xrSessionMode mode to initialize
  43272. * @param optionalFeatures defines optional values to pass to the session builder
  43273. * @returns a promise which will resolve once the session has been initialized
  43274. */
  43275. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43276. /**
  43277. * Sets the reference space on the xr session
  43278. * @param referenceSpace space to set
  43279. * @returns a promise that will resolve once the reference space has been set
  43280. */
  43281. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43282. /**
  43283. * Updates the render state of the session
  43284. * @param state state to set
  43285. * @returns a promise that resolves once the render state has been updated
  43286. */
  43287. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43288. /**
  43289. * Starts rendering to the xr layer
  43290. * @returns a promise that will resolve once rendering has started
  43291. */
  43292. startRenderingToXRAsync(): Promise<void>;
  43293. /**
  43294. * Gets the correct render target texture to be rendered this frame for this eye
  43295. * @param eye the eye for which to get the render target
  43296. * @returns the render target for the specified eye
  43297. */
  43298. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43299. /**
  43300. * Stops the xrSession and restores the renderloop
  43301. * @returns Promise which resolves after it exits XR
  43302. */
  43303. exitXRAsync(): Promise<void>;
  43304. /**
  43305. * Checks if a session would be supported for the creation options specified
  43306. * @param sessionMode session mode to check if supported eg. immersive-vr
  43307. * @returns true if supported
  43308. */
  43309. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43310. /**
  43311. * Creates a WebXRRenderTarget object for the XR session
  43312. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43313. * @param options optional options to provide when creating a new render target
  43314. * @returns a WebXR render target to which the session can render
  43315. */
  43316. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43317. /**
  43318. * @hidden
  43319. * Converts the render layer of xrSession to a render target
  43320. * @param session session to create render target for
  43321. * @param scene scene the new render target should be created for
  43322. */
  43323. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43324. /**
  43325. * Disposes of the session manager
  43326. */
  43327. dispose(): void;
  43328. /**
  43329. * Gets a promise returning true when fullfiled if the given session mode is supported
  43330. * @param sessionMode defines the session to test
  43331. * @returns a promise
  43332. */
  43333. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43334. }
  43335. }
  43336. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43337. import { Scene } from "babylonjs/scene";
  43338. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43339. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43340. /**
  43341. * WebXR Camera which holds the views for the xrSession
  43342. * @see https://doc.babylonjs.com/how_to/webxr
  43343. */
  43344. export class WebXRCamera extends FreeCamera {
  43345. /**
  43346. * Is the camera in debug mode. Used when using an emulator
  43347. */
  43348. debugMode: boolean;
  43349. /**
  43350. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43351. * @param name the name of the camera
  43352. * @param scene the scene to add the camera to
  43353. */
  43354. constructor(name: string, scene: Scene);
  43355. private _updateNumberOfRigCameras;
  43356. /** @hidden */
  43357. _updateForDualEyeDebugging(): void;
  43358. /**
  43359. * Updates the cameras position from the current pose information of the XR session
  43360. * @param xrSessionManager the session containing pose information
  43361. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43362. */
  43363. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43364. }
  43365. }
  43366. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43367. import { Observable } from "babylonjs/Misc/observable";
  43368. import { IDisposable, Scene } from "babylonjs/scene";
  43369. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43371. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43372. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43373. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43374. /**
  43375. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43376. * @see https://doc.babylonjs.com/how_to/webxr
  43377. */
  43378. export class WebXRExperienceHelper implements IDisposable {
  43379. private scene;
  43380. /**
  43381. * 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
  43382. */
  43383. container: AbstractMesh;
  43384. /**
  43385. * Camera used to render xr content
  43386. */
  43387. camera: WebXRCamera;
  43388. /**
  43389. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43390. */
  43391. state: WebXRState;
  43392. private _setState;
  43393. private static _TmpVector;
  43394. /**
  43395. * Fires when the state of the experience helper has changed
  43396. */
  43397. onStateChangedObservable: Observable<WebXRState>;
  43398. /** Session manager used to keep track of xr session */
  43399. sessionManager: WebXRSessionManager;
  43400. private _nonVRCamera;
  43401. private _originalSceneAutoClear;
  43402. private _supported;
  43403. /**
  43404. * Creates the experience helper
  43405. * @param scene the scene to attach the experience helper to
  43406. * @returns a promise for the experience helper
  43407. */
  43408. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43409. /**
  43410. * Creates a WebXRExperienceHelper
  43411. * @param scene The scene the helper should be created in
  43412. */
  43413. private constructor();
  43414. /**
  43415. * Exits XR mode and returns the scene to its original state
  43416. * @returns promise that resolves after xr mode has exited
  43417. */
  43418. exitXRAsync(): Promise<void>;
  43419. /**
  43420. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43421. * @param sessionMode options for the XR session
  43422. * @param referenceSpaceType frame of reference of the XR session
  43423. * @param renderTarget the output canvas that will be used to enter XR mode
  43424. * @returns promise that resolves after xr mode has entered
  43425. */
  43426. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43427. /**
  43428. * Updates the global position of the camera by moving the camera's container
  43429. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43430. * @param position The desired global position of the camera
  43431. */
  43432. setPositionOfCameraUsingContainer(position: Vector3): void;
  43433. /**
  43434. * Rotates the xr camera by rotating the camera's container around the camera's position
  43435. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43436. * @param rotation the desired quaternion rotation to apply to the camera
  43437. */
  43438. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43439. /**
  43440. * Disposes of the experience helper
  43441. */
  43442. dispose(): void;
  43443. }
  43444. }
  43445. declare module "babylonjs/Cameras/XR/webXRController" {
  43446. import { Nullable } from "babylonjs/types";
  43447. import { Observable } from "babylonjs/Misc/observable";
  43448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43449. import { Ray } from "babylonjs/Culling/ray";
  43450. import { Scene } from "babylonjs/scene";
  43451. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43452. /**
  43453. * Represents an XR input
  43454. */
  43455. export class WebXRController {
  43456. private scene;
  43457. /** The underlying input source for the controller */
  43458. inputSource: XRInputSource;
  43459. private parentContainer;
  43460. /**
  43461. * 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
  43462. */
  43463. grip?: AbstractMesh;
  43464. /**
  43465. * Pointer which can be used to select objects or attach a visible laser to
  43466. */
  43467. pointer: AbstractMesh;
  43468. private _gamepadMode;
  43469. /**
  43470. * If available, this is the gamepad object related to this controller.
  43471. * Using this object it is possible to get click events and trackpad changes of the
  43472. * webxr controller that is currently being used.
  43473. */
  43474. gamepadController?: WebVRController;
  43475. /**
  43476. * Event that fires when the controller is removed/disposed
  43477. */
  43478. onDisposeObservable: Observable<{}>;
  43479. private _tmpQuaternion;
  43480. private _tmpVector;
  43481. /**
  43482. * Creates the controller
  43483. * @see https://doc.babylonjs.com/how_to/webxr
  43484. * @param scene the scene which the controller should be associated to
  43485. * @param inputSource the underlying input source for the controller
  43486. * @param parentContainer parent that the controller meshes should be children of
  43487. */
  43488. constructor(scene: Scene,
  43489. /** The underlying input source for the controller */
  43490. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43491. /**
  43492. * Updates the controller pose based on the given XRFrame
  43493. * @param xrFrame xr frame to update the pose with
  43494. * @param referenceSpace reference space to use
  43495. */
  43496. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43497. /**
  43498. * Gets a world space ray coming from the controller
  43499. * @param result the resulting ray
  43500. */
  43501. getWorldPointerRayToRef(result: Ray): void;
  43502. /**
  43503. * Get the scene associated with this controller
  43504. * @returns the scene object
  43505. */
  43506. getScene(): Scene;
  43507. /**
  43508. * Disposes of the object
  43509. */
  43510. dispose(): void;
  43511. }
  43512. }
  43513. declare module "babylonjs/Cameras/XR/webXRInput" {
  43514. import { Observable } from "babylonjs/Misc/observable";
  43515. import { IDisposable } from "babylonjs/scene";
  43516. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43517. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43518. /**
  43519. * XR input used to track XR inputs such as controllers/rays
  43520. */
  43521. export class WebXRInput implements IDisposable {
  43522. /**
  43523. * Base experience the input listens to
  43524. */
  43525. baseExperience: WebXRExperienceHelper;
  43526. /**
  43527. * XR controllers being tracked
  43528. */
  43529. controllers: Array<WebXRController>;
  43530. private _frameObserver;
  43531. private _stateObserver;
  43532. /**
  43533. * Event when a controller has been connected/added
  43534. */
  43535. onControllerAddedObservable: Observable<WebXRController>;
  43536. /**
  43537. * Event when a controller has been removed/disconnected
  43538. */
  43539. onControllerRemovedObservable: Observable<WebXRController>;
  43540. /**
  43541. * Initializes the WebXRInput
  43542. * @param baseExperience experience helper which the input should be created for
  43543. */
  43544. constructor(
  43545. /**
  43546. * Base experience the input listens to
  43547. */
  43548. baseExperience: WebXRExperienceHelper);
  43549. private _onInputSourcesChange;
  43550. private _addAndRemoveControllers;
  43551. /**
  43552. * Disposes of the object
  43553. */
  43554. dispose(): void;
  43555. }
  43556. }
  43557. declare module "babylonjs/Loading/sceneLoader" {
  43558. import { Observable } from "babylonjs/Misc/observable";
  43559. import { Nullable } from "babylonjs/types";
  43560. import { Scene } from "babylonjs/scene";
  43561. import { Engine } from "babylonjs/Engines/engine";
  43562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43563. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43564. import { AssetContainer } from "babylonjs/assetContainer";
  43565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43566. import { Skeleton } from "babylonjs/Bones/skeleton";
  43567. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43568. import { WebRequest } from "babylonjs/Misc/webRequest";
  43569. /**
  43570. * Class used to represent data loading progression
  43571. */
  43572. export class SceneLoaderProgressEvent {
  43573. /** defines if data length to load can be evaluated */
  43574. readonly lengthComputable: boolean;
  43575. /** defines the loaded data length */
  43576. readonly loaded: number;
  43577. /** defines the data length to load */
  43578. readonly total: number;
  43579. /**
  43580. * Create a new progress event
  43581. * @param lengthComputable defines if data length to load can be evaluated
  43582. * @param loaded defines the loaded data length
  43583. * @param total defines the data length to load
  43584. */
  43585. constructor(
  43586. /** defines if data length to load can be evaluated */
  43587. lengthComputable: boolean,
  43588. /** defines the loaded data length */
  43589. loaded: number,
  43590. /** defines the data length to load */
  43591. total: number);
  43592. /**
  43593. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43594. * @param event defines the source event
  43595. * @returns a new SceneLoaderProgressEvent
  43596. */
  43597. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43598. }
  43599. /**
  43600. * Interface used by SceneLoader plugins to define supported file extensions
  43601. */
  43602. export interface ISceneLoaderPluginExtensions {
  43603. /**
  43604. * Defines the list of supported extensions
  43605. */
  43606. [extension: string]: {
  43607. isBinary: boolean;
  43608. };
  43609. }
  43610. /**
  43611. * Interface used by SceneLoader plugin factory
  43612. */
  43613. export interface ISceneLoaderPluginFactory {
  43614. /**
  43615. * Defines the name of the factory
  43616. */
  43617. name: string;
  43618. /**
  43619. * Function called to create a new plugin
  43620. * @return the new plugin
  43621. */
  43622. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43623. /**
  43624. * The callback that returns true if the data can be directly loaded.
  43625. * @param data string containing the file data
  43626. * @returns if the data can be loaded directly
  43627. */
  43628. canDirectLoad?(data: string): boolean;
  43629. }
  43630. /**
  43631. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43632. */
  43633. export interface ISceneLoaderPluginBase {
  43634. /**
  43635. * The friendly name of this plugin.
  43636. */
  43637. name: string;
  43638. /**
  43639. * The file extensions supported by this plugin.
  43640. */
  43641. extensions: string | ISceneLoaderPluginExtensions;
  43642. /**
  43643. * The callback called when loading from a url.
  43644. * @param scene scene loading this url
  43645. * @param url url to load
  43646. * @param onSuccess callback called when the file successfully loads
  43647. * @param onProgress callback called while file is loading (if the server supports this mode)
  43648. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43649. * @param onError callback called when the file fails to load
  43650. * @returns a file request object
  43651. */
  43652. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43653. /**
  43654. * The callback called when loading from a file object.
  43655. * @param scene scene loading this file
  43656. * @param file defines the file to load
  43657. * @param onSuccess defines the callback to call when data is loaded
  43658. * @param onProgress defines the callback to call during loading process
  43659. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43660. * @param onError defines the callback to call when an error occurs
  43661. * @returns a file request object
  43662. */
  43663. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43664. /**
  43665. * The callback that returns true if the data can be directly loaded.
  43666. * @param data string containing the file data
  43667. * @returns if the data can be loaded directly
  43668. */
  43669. canDirectLoad?(data: string): boolean;
  43670. /**
  43671. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43672. * @param scene scene loading this data
  43673. * @param data string containing the data
  43674. * @returns data to pass to the plugin
  43675. */
  43676. directLoad?(scene: Scene, data: string): any;
  43677. /**
  43678. * The callback that allows custom handling of the root url based on the response url.
  43679. * @param rootUrl the original root url
  43680. * @param responseURL the response url if available
  43681. * @returns the new root url
  43682. */
  43683. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43684. }
  43685. /**
  43686. * Interface used to define a SceneLoader plugin
  43687. */
  43688. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43689. /**
  43690. * Import meshes into a scene.
  43691. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43692. * @param scene The scene to import into
  43693. * @param data The data to import
  43694. * @param rootUrl The root url for scene and resources
  43695. * @param meshes The meshes array to import into
  43696. * @param particleSystems The particle systems array to import into
  43697. * @param skeletons The skeletons array to import into
  43698. * @param onError The callback when import fails
  43699. * @returns True if successful or false otherwise
  43700. */
  43701. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43702. /**
  43703. * Load into a scene.
  43704. * @param scene The scene to load into
  43705. * @param data The data to import
  43706. * @param rootUrl The root url for scene and resources
  43707. * @param onError The callback when import fails
  43708. * @returns True if successful or false otherwise
  43709. */
  43710. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43711. /**
  43712. * Load into an asset container.
  43713. * @param scene The scene to load into
  43714. * @param data The data to import
  43715. * @param rootUrl The root url for scene and resources
  43716. * @param onError The callback when import fails
  43717. * @returns The loaded asset container
  43718. */
  43719. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43720. }
  43721. /**
  43722. * Interface used to define an async SceneLoader plugin
  43723. */
  43724. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43725. /**
  43726. * Import meshes into a scene.
  43727. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43728. * @param scene The scene to import into
  43729. * @param data The data to import
  43730. * @param rootUrl The root url for scene and resources
  43731. * @param onProgress The callback when the load progresses
  43732. * @param fileName Defines the name of the file to load
  43733. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43734. */
  43735. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43736. meshes: AbstractMesh[];
  43737. particleSystems: IParticleSystem[];
  43738. skeletons: Skeleton[];
  43739. animationGroups: AnimationGroup[];
  43740. }>;
  43741. /**
  43742. * Load into a scene.
  43743. * @param scene The scene to load into
  43744. * @param data The data to import
  43745. * @param rootUrl The root url for scene and resources
  43746. * @param onProgress The callback when the load progresses
  43747. * @param fileName Defines the name of the file to load
  43748. * @returns Nothing
  43749. */
  43750. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43751. /**
  43752. * Load into an asset container.
  43753. * @param scene The scene to load into
  43754. * @param data The data to import
  43755. * @param rootUrl The root url for scene and resources
  43756. * @param onProgress The callback when the load progresses
  43757. * @param fileName Defines the name of the file to load
  43758. * @returns The loaded asset container
  43759. */
  43760. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43761. }
  43762. /**
  43763. * Class used to load scene from various file formats using registered plugins
  43764. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43765. */
  43766. export class SceneLoader {
  43767. /**
  43768. * No logging while loading
  43769. */
  43770. static readonly NO_LOGGING: number;
  43771. /**
  43772. * Minimal logging while loading
  43773. */
  43774. static readonly MINIMAL_LOGGING: number;
  43775. /**
  43776. * Summary logging while loading
  43777. */
  43778. static readonly SUMMARY_LOGGING: number;
  43779. /**
  43780. * Detailled logging while loading
  43781. */
  43782. static readonly DETAILED_LOGGING: number;
  43783. /**
  43784. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43785. */
  43786. static ForceFullSceneLoadingForIncremental: boolean;
  43787. /**
  43788. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43789. */
  43790. static ShowLoadingScreen: boolean;
  43791. /**
  43792. * Defines the current logging level (while loading the scene)
  43793. * @ignorenaming
  43794. */
  43795. static loggingLevel: number;
  43796. /**
  43797. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43798. */
  43799. static CleanBoneMatrixWeights: boolean;
  43800. /**
  43801. * Event raised when a plugin is used to load a scene
  43802. */
  43803. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43804. private static _registeredPlugins;
  43805. private static _getDefaultPlugin;
  43806. private static _getPluginForExtension;
  43807. private static _getPluginForDirectLoad;
  43808. private static _getPluginForFilename;
  43809. private static _getDirectLoad;
  43810. private static _loadData;
  43811. private static _getFileInfo;
  43812. /**
  43813. * Gets a plugin that can load the given extension
  43814. * @param extension defines the extension to load
  43815. * @returns a plugin or null if none works
  43816. */
  43817. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43818. /**
  43819. * Gets a boolean indicating that the given extension can be loaded
  43820. * @param extension defines the extension to load
  43821. * @returns true if the extension is supported
  43822. */
  43823. static IsPluginForExtensionAvailable(extension: string): boolean;
  43824. /**
  43825. * Adds a new plugin to the list of registered plugins
  43826. * @param plugin defines the plugin to add
  43827. */
  43828. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43829. /**
  43830. * Import meshes into a scene
  43831. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43832. * @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)
  43833. * @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)
  43834. * @param scene the instance of BABYLON.Scene to append to
  43835. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43836. * @param onProgress a callback with a progress event for each file being loaded
  43837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43838. * @param pluginExtension the extension used to determine the plugin
  43839. * @returns The loaded plugin
  43840. */
  43841. 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>;
  43842. /**
  43843. * Import meshes into a scene
  43844. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43845. * @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)
  43846. * @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)
  43847. * @param scene the instance of BABYLON.Scene to append to
  43848. * @param onProgress a callback with a progress event for each file being loaded
  43849. * @param pluginExtension the extension used to determine the plugin
  43850. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43851. */
  43852. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43853. meshes: AbstractMesh[];
  43854. particleSystems: IParticleSystem[];
  43855. skeletons: Skeleton[];
  43856. animationGroups: AnimationGroup[];
  43857. }>;
  43858. /**
  43859. * Load a scene
  43860. * @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)
  43861. * @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)
  43862. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43863. * @param onSuccess a callback with the scene when import succeeds
  43864. * @param onProgress a callback with a progress event for each file being loaded
  43865. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43866. * @param pluginExtension the extension used to determine the plugin
  43867. * @returns The loaded plugin
  43868. */
  43869. 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>;
  43870. /**
  43871. * Load a scene
  43872. * @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)
  43873. * @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)
  43874. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43875. * @param onProgress a callback with a progress event for each file being loaded
  43876. * @param pluginExtension the extension used to determine the plugin
  43877. * @returns The loaded scene
  43878. */
  43879. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43880. /**
  43881. * Append a scene
  43882. * @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)
  43883. * @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)
  43884. * @param scene is the instance of BABYLON.Scene to append to
  43885. * @param onSuccess a callback with the scene when import succeeds
  43886. * @param onProgress a callback with a progress event for each file being loaded
  43887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43888. * @param pluginExtension the extension used to determine the plugin
  43889. * @returns The loaded plugin
  43890. */
  43891. 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>;
  43892. /**
  43893. * Append a scene
  43894. * @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)
  43895. * @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)
  43896. * @param scene is the instance of BABYLON.Scene to append to
  43897. * @param onProgress a callback with a progress event for each file being loaded
  43898. * @param pluginExtension the extension used to determine the plugin
  43899. * @returns The given scene
  43900. */
  43901. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43902. /**
  43903. * Load a scene into an asset container
  43904. * @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)
  43905. * @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)
  43906. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43907. * @param onSuccess a callback with the scene when import succeeds
  43908. * @param onProgress a callback with a progress event for each file being loaded
  43909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43910. * @param pluginExtension the extension used to determine the plugin
  43911. * @returns The loaded plugin
  43912. */
  43913. 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>;
  43914. /**
  43915. * Load a scene into an asset container
  43916. * @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)
  43917. * @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)
  43918. * @param scene is the instance of Scene to append to
  43919. * @param onProgress a callback with a progress event for each file being loaded
  43920. * @param pluginExtension the extension used to determine the plugin
  43921. * @returns The loaded asset container
  43922. */
  43923. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43924. }
  43925. }
  43926. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43927. import { Scene } from "babylonjs/scene";
  43928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43929. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43930. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43931. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43932. /**
  43933. * Generic Controller
  43934. */
  43935. export class GenericController extends WebVRController {
  43936. /**
  43937. * Base Url for the controller model.
  43938. */
  43939. static readonly MODEL_BASE_URL: string;
  43940. /**
  43941. * File name for the controller model.
  43942. */
  43943. static readonly MODEL_FILENAME: string;
  43944. /**
  43945. * Creates a new GenericController from a gamepad
  43946. * @param vrGamepad the gamepad that the controller should be created from
  43947. */
  43948. constructor(vrGamepad: any);
  43949. /**
  43950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43951. * @param scene scene in which to add meshes
  43952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43953. */
  43954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43955. /**
  43956. * Called once for each button that changed state since the last frame
  43957. * @param buttonIdx Which button index changed
  43958. * @param state New state of the button
  43959. * @param changes Which properties on the state changed since last frame
  43960. */
  43961. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43962. }
  43963. }
  43964. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43965. import { Observable } from "babylonjs/Misc/observable";
  43966. import { Scene } from "babylonjs/scene";
  43967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43968. import { Ray } from "babylonjs/Culling/ray";
  43969. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43970. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43971. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43972. /**
  43973. * Defines the WindowsMotionController object that the state of the windows motion controller
  43974. */
  43975. export class WindowsMotionController extends WebVRController {
  43976. /**
  43977. * The base url used to load the left and right controller models
  43978. */
  43979. static MODEL_BASE_URL: string;
  43980. /**
  43981. * The name of the left controller model file
  43982. */
  43983. static MODEL_LEFT_FILENAME: string;
  43984. /**
  43985. * The name of the right controller model file
  43986. */
  43987. static MODEL_RIGHT_FILENAME: string;
  43988. /**
  43989. * The controller name prefix for this controller type
  43990. */
  43991. static readonly GAMEPAD_ID_PREFIX: string;
  43992. /**
  43993. * The controller id pattern for this controller type
  43994. */
  43995. private static readonly GAMEPAD_ID_PATTERN;
  43996. private _loadedMeshInfo;
  43997. protected readonly _mapping: {
  43998. buttons: string[];
  43999. buttonMeshNames: {
  44000. 'trigger': string;
  44001. 'menu': string;
  44002. 'grip': string;
  44003. 'thumbstick': string;
  44004. 'trackpad': string;
  44005. };
  44006. buttonObservableNames: {
  44007. 'trigger': string;
  44008. 'menu': string;
  44009. 'grip': string;
  44010. 'thumbstick': string;
  44011. 'trackpad': string;
  44012. };
  44013. axisMeshNames: string[];
  44014. pointingPoseMeshName: string;
  44015. };
  44016. /**
  44017. * Fired when the trackpad on this controller is clicked
  44018. */
  44019. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44020. /**
  44021. * Fired when the trackpad on this controller is modified
  44022. */
  44023. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44024. /**
  44025. * The current x and y values of this controller's trackpad
  44026. */
  44027. trackpad: StickValues;
  44028. /**
  44029. * Creates a new WindowsMotionController from a gamepad
  44030. * @param vrGamepad the gamepad that the controller should be created from
  44031. */
  44032. constructor(vrGamepad: any);
  44033. /**
  44034. * Fired when the trigger on this controller is modified
  44035. */
  44036. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44037. /**
  44038. * Fired when the menu button on this controller is modified
  44039. */
  44040. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44041. /**
  44042. * Fired when the grip button on this controller is modified
  44043. */
  44044. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44045. /**
  44046. * Fired when the thumbstick button on this controller is modified
  44047. */
  44048. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44049. /**
  44050. * Fired when the touchpad button on this controller is modified
  44051. */
  44052. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44053. /**
  44054. * Fired when the touchpad values on this controller are modified
  44055. */
  44056. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44057. protected _updateTrackpad(): void;
  44058. /**
  44059. * Called once per frame by the engine.
  44060. */
  44061. update(): void;
  44062. /**
  44063. * Called once for each button that changed state since the last frame
  44064. * @param buttonIdx Which button index changed
  44065. * @param state New state of the button
  44066. * @param changes Which properties on the state changed since last frame
  44067. */
  44068. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44069. /**
  44070. * Moves the buttons on the controller mesh based on their current state
  44071. * @param buttonName the name of the button to move
  44072. * @param buttonValue the value of the button which determines the buttons new position
  44073. */
  44074. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44075. /**
  44076. * Moves the axis on the controller mesh based on its current state
  44077. * @param axis the index of the axis
  44078. * @param axisValue the value of the axis which determines the meshes new position
  44079. * @hidden
  44080. */
  44081. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44082. /**
  44083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44084. * @param scene scene in which to add meshes
  44085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44086. */
  44087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44088. /**
  44089. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44090. * can be transformed by button presses and axes values, based on this._mapping.
  44091. *
  44092. * @param scene scene in which the meshes exist
  44093. * @param meshes list of meshes that make up the controller model to process
  44094. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44095. */
  44096. private processModel;
  44097. private createMeshInfo;
  44098. /**
  44099. * Gets the ray of the controller in the direction the controller is pointing
  44100. * @param length the length the resulting ray should be
  44101. * @returns a ray in the direction the controller is pointing
  44102. */
  44103. getForwardRay(length?: number): Ray;
  44104. /**
  44105. * Disposes of the controller
  44106. */
  44107. dispose(): void;
  44108. }
  44109. /**
  44110. * This class represents a new windows motion controller in XR.
  44111. */
  44112. export class XRWindowsMotionController extends WindowsMotionController {
  44113. /**
  44114. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44115. */
  44116. protected readonly _mapping: {
  44117. buttons: string[];
  44118. buttonMeshNames: {
  44119. 'trigger': string;
  44120. 'menu': string;
  44121. 'grip': string;
  44122. 'thumbstick': string;
  44123. 'trackpad': string;
  44124. };
  44125. buttonObservableNames: {
  44126. 'trigger': string;
  44127. 'menu': string;
  44128. 'grip': string;
  44129. 'thumbstick': string;
  44130. 'trackpad': string;
  44131. };
  44132. axisMeshNames: string[];
  44133. pointingPoseMeshName: string;
  44134. };
  44135. /**
  44136. * Construct a new XR-Based windows motion controller
  44137. *
  44138. * @param gamepadInfo the gamepad object from the browser
  44139. */
  44140. constructor(gamepadInfo: any);
  44141. /**
  44142. * holds the thumbstick values (X,Y)
  44143. */
  44144. thumbstickValues: StickValues;
  44145. /**
  44146. * Fired when the thumbstick on this controller is clicked
  44147. */
  44148. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44149. /**
  44150. * Fired when the thumbstick on this controller is modified
  44151. */
  44152. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44153. /**
  44154. * Fired when the touchpad button on this controller is modified
  44155. */
  44156. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44157. /**
  44158. * Fired when the touchpad values on this controller are modified
  44159. */
  44160. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44161. /**
  44162. * Fired when the thumbstick button on this controller is modified
  44163. * here to prevent breaking changes
  44164. */
  44165. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44166. /**
  44167. * updating the thumbstick(!) and not the trackpad.
  44168. * This is named this way due to the difference between WebVR and XR and to avoid
  44169. * changing the parent class.
  44170. */
  44171. protected _updateTrackpad(): void;
  44172. /**
  44173. * Disposes the class with joy
  44174. */
  44175. dispose(): void;
  44176. }
  44177. }
  44178. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44179. import { Observable } from "babylonjs/Misc/observable";
  44180. import { Scene } from "babylonjs/scene";
  44181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44182. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44183. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44184. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44185. /**
  44186. * Oculus Touch Controller
  44187. */
  44188. export class OculusTouchController extends WebVRController {
  44189. /**
  44190. * Base Url for the controller model.
  44191. */
  44192. static MODEL_BASE_URL: string;
  44193. /**
  44194. * File name for the left controller model.
  44195. */
  44196. static MODEL_LEFT_FILENAME: string;
  44197. /**
  44198. * File name for the right controller model.
  44199. */
  44200. static MODEL_RIGHT_FILENAME: string;
  44201. /**
  44202. * Base Url for the Quest controller model.
  44203. */
  44204. static QUEST_MODEL_BASE_URL: string;
  44205. /**
  44206. * @hidden
  44207. * If the controllers are running on a device that needs the updated Quest controller models
  44208. */
  44209. static _IsQuest: boolean;
  44210. /**
  44211. * Fired when the secondary trigger on this controller is modified
  44212. */
  44213. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44214. /**
  44215. * Fired when the thumb rest on this controller is modified
  44216. */
  44217. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44218. /**
  44219. * Creates a new OculusTouchController from a gamepad
  44220. * @param vrGamepad the gamepad that the controller should be created from
  44221. */
  44222. constructor(vrGamepad: any);
  44223. /**
  44224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44225. * @param scene scene in which to add meshes
  44226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44227. */
  44228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44229. /**
  44230. * Fired when the A button on this controller is modified
  44231. */
  44232. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44233. /**
  44234. * Fired when the B button on this controller is modified
  44235. */
  44236. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44237. /**
  44238. * Fired when the X button on this controller is modified
  44239. */
  44240. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44241. /**
  44242. * Fired when the Y button on this controller is modified
  44243. */
  44244. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44245. /**
  44246. * Called once for each button that changed state since the last frame
  44247. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44248. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44249. * 2) secondary trigger (same)
  44250. * 3) A (right) X (left), touch, pressed = value
  44251. * 4) B / Y
  44252. * 5) thumb rest
  44253. * @param buttonIdx Which button index changed
  44254. * @param state New state of the button
  44255. * @param changes Which properties on the state changed since last frame
  44256. */
  44257. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44258. }
  44259. }
  44260. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44261. import { Scene } from "babylonjs/scene";
  44262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44263. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44264. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44265. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44266. import { Observable } from "babylonjs/Misc/observable";
  44267. /**
  44268. * Vive Controller
  44269. */
  44270. export class ViveController extends WebVRController {
  44271. /**
  44272. * Base Url for the controller model.
  44273. */
  44274. static MODEL_BASE_URL: string;
  44275. /**
  44276. * File name for the controller model.
  44277. */
  44278. static MODEL_FILENAME: string;
  44279. /**
  44280. * Creates a new ViveController from a gamepad
  44281. * @param vrGamepad the gamepad that the controller should be created from
  44282. */
  44283. constructor(vrGamepad: any);
  44284. /**
  44285. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44286. * @param scene scene in which to add meshes
  44287. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44288. */
  44289. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44290. /**
  44291. * Fired when the left button on this controller is modified
  44292. */
  44293. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44294. /**
  44295. * Fired when the right button on this controller is modified
  44296. */
  44297. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44298. /**
  44299. * Fired when the menu button on this controller is modified
  44300. */
  44301. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44302. /**
  44303. * Called once for each button that changed state since the last frame
  44304. * Vive mapping:
  44305. * 0: touchpad
  44306. * 1: trigger
  44307. * 2: left AND right buttons
  44308. * 3: menu button
  44309. * @param buttonIdx Which button index changed
  44310. * @param state New state of the button
  44311. * @param changes Which properties on the state changed since last frame
  44312. */
  44313. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44314. }
  44315. }
  44316. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44317. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44318. import { Observable } from "babylonjs/Misc/observable";
  44319. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44320. /**
  44321. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44322. */
  44323. export class WebXRControllerModelLoader {
  44324. /**
  44325. * an observable that triggers when a new model (the mesh itself) was initialized.
  44326. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44327. */
  44328. onControllerModelLoaded: Observable<WebXRController>;
  44329. /**
  44330. * Creates the WebXRControllerModelLoader
  44331. * @param input xr input that creates the controllers
  44332. */
  44333. constructor(input: WebXRInput);
  44334. }
  44335. }
  44336. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44337. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44338. /**
  44339. * Handles pointer input automatically for the pointer of XR controllers
  44340. */
  44341. export class WebXRControllerPointerSelection {
  44342. private static _idCounter;
  44343. private _tmpRay;
  44344. /**
  44345. * Creates a WebXRControllerPointerSelection
  44346. * @param input input manager to setup pointer selection
  44347. */
  44348. constructor(input: WebXRInput);
  44349. private _convertNormalToDirectionOfRay;
  44350. private _updatePointerDistance;
  44351. }
  44352. }
  44353. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44355. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44356. /**
  44357. * Enables teleportation
  44358. */
  44359. export class WebXRControllerTeleportation {
  44360. private _teleportationFillColor;
  44361. private _teleportationBorderColor;
  44362. private _tmpRay;
  44363. private _tmpVector;
  44364. /**
  44365. * Creates a WebXRControllerTeleportation
  44366. * @param input input manager to add teleportation to
  44367. * @param floorMeshes floormeshes which can be teleported to
  44368. */
  44369. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44370. }
  44371. }
  44372. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44373. import { Nullable } from "babylonjs/types";
  44374. import { Observable } from "babylonjs/Misc/observable";
  44375. import { IDisposable, Scene } from "babylonjs/scene";
  44376. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44377. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44378. /**
  44379. * Button which can be used to enter a different mode of XR
  44380. */
  44381. export class WebXREnterExitUIButton {
  44382. /** button element */
  44383. element: HTMLElement;
  44384. /** XR initialization options for the button */
  44385. sessionMode: XRSessionMode;
  44386. /** Reference space type */
  44387. referenceSpaceType: XRReferenceSpaceType;
  44388. /**
  44389. * Creates a WebXREnterExitUIButton
  44390. * @param element button element
  44391. * @param sessionMode XR initialization session mode
  44392. * @param referenceSpaceType the type of reference space to be used
  44393. */
  44394. constructor(
  44395. /** button element */
  44396. element: HTMLElement,
  44397. /** XR initialization options for the button */
  44398. sessionMode: XRSessionMode,
  44399. /** Reference space type */
  44400. referenceSpaceType: XRReferenceSpaceType);
  44401. /**
  44402. * Overwritable function which can be used to update the button's visuals when the state changes
  44403. * @param activeButton the current active button in the UI
  44404. */
  44405. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44406. }
  44407. /**
  44408. * Options to create the webXR UI
  44409. */
  44410. export class WebXREnterExitUIOptions {
  44411. /**
  44412. * Context to enter xr with
  44413. */
  44414. renderTarget?: Nullable<WebXRRenderTarget>;
  44415. /**
  44416. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44417. */
  44418. customButtons?: Array<WebXREnterExitUIButton>;
  44419. /**
  44420. * A session mode to use when creating the default button.
  44421. * Default is immersive-vr
  44422. */
  44423. sessionMode?: XRSessionMode;
  44424. /**
  44425. * A reference space type to use when creating the default button.
  44426. * Default is local-floor
  44427. */
  44428. referenceSpaceType?: XRReferenceSpaceType;
  44429. }
  44430. /**
  44431. * UI to allow the user to enter/exit XR mode
  44432. */
  44433. export class WebXREnterExitUI implements IDisposable {
  44434. private scene;
  44435. private _overlay;
  44436. private _buttons;
  44437. private _activeButton;
  44438. /**
  44439. * Fired every time the active button is changed.
  44440. *
  44441. * When xr is entered via a button that launches xr that button will be the callback parameter
  44442. *
  44443. * When exiting xr the callback parameter will be null)
  44444. */
  44445. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44446. /**
  44447. * Creates UI to allow the user to enter/exit XR mode
  44448. * @param scene the scene to add the ui to
  44449. * @param helper the xr experience helper to enter/exit xr with
  44450. * @param options options to configure the UI
  44451. * @returns the created ui
  44452. */
  44453. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44454. private constructor();
  44455. private _updateButtons;
  44456. /**
  44457. * Disposes of the object
  44458. */
  44459. dispose(): void;
  44460. }
  44461. }
  44462. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44463. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44464. import { Scene } from "babylonjs/scene";
  44465. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44466. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44467. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44468. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44469. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44470. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44472. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44473. /**
  44474. * Options for the default xr helper
  44475. */
  44476. export class WebXRDefaultExperienceOptions {
  44477. /**
  44478. * Floor meshes that should be used for teleporting
  44479. */
  44480. floorMeshes: Array<AbstractMesh>;
  44481. /**
  44482. * Enable or disable default UI to enter XR
  44483. */
  44484. disableDefaultUI?: boolean;
  44485. /**
  44486. * optional configuration for the output canvas
  44487. */
  44488. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44489. }
  44490. /**
  44491. * Default experience which provides a similar setup to the previous webVRExperience
  44492. */
  44493. export class WebXRDefaultExperience {
  44494. /**
  44495. * Base experience
  44496. */
  44497. baseExperience: WebXRExperienceHelper;
  44498. /**
  44499. * Input experience extension
  44500. */
  44501. input: WebXRInput;
  44502. /**
  44503. * Loads the controller models
  44504. */
  44505. controllerModelLoader: WebXRControllerModelLoader;
  44506. /**
  44507. * Enables laser pointer and selection
  44508. */
  44509. pointerSelection: WebXRControllerPointerSelection;
  44510. /**
  44511. * Enables teleportation
  44512. */
  44513. teleportation: WebXRControllerTeleportation;
  44514. /**
  44515. * Enables ui for enetering/exiting xr
  44516. */
  44517. enterExitUI: WebXREnterExitUI;
  44518. /**
  44519. * Default target xr should render to
  44520. */
  44521. renderTarget: WebXRRenderTarget;
  44522. /**
  44523. * Creates the default xr experience
  44524. * @param scene scene
  44525. * @param options options for basic configuration
  44526. * @returns resulting WebXRDefaultExperience
  44527. */
  44528. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44529. private constructor();
  44530. /**
  44531. * DIsposes of the experience helper
  44532. */
  44533. dispose(): void;
  44534. }
  44535. }
  44536. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44537. import { Observable } from "babylonjs/Misc/observable";
  44538. import { Nullable } from "babylonjs/types";
  44539. import { Camera } from "babylonjs/Cameras/camera";
  44540. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44541. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44542. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44543. import { Scene } from "babylonjs/scene";
  44544. import { Vector3 } from "babylonjs/Maths/math.vector";
  44545. import { Color3 } from "babylonjs/Maths/math.color";
  44546. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44548. import { Mesh } from "babylonjs/Meshes/mesh";
  44549. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44550. import { EasingFunction } from "babylonjs/Animations/easing";
  44551. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44552. import "babylonjs/Meshes/Builders/groundBuilder";
  44553. import "babylonjs/Meshes/Builders/torusBuilder";
  44554. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44555. import "babylonjs/Gamepads/gamepadSceneComponent";
  44556. import "babylonjs/Animations/animatable";
  44557. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44558. /**
  44559. * Options to modify the vr teleportation behavior.
  44560. */
  44561. export interface VRTeleportationOptions {
  44562. /**
  44563. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44564. */
  44565. floorMeshName?: string;
  44566. /**
  44567. * A list of meshes to be used as the teleportation floor. (default: empty)
  44568. */
  44569. floorMeshes?: Mesh[];
  44570. /**
  44571. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44572. */
  44573. teleportationMode?: number;
  44574. /**
  44575. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44576. */
  44577. teleportationTime?: number;
  44578. /**
  44579. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44580. */
  44581. teleportationSpeed?: number;
  44582. /**
  44583. * The easing function used in the animation or null for Linear. (default CircleEase)
  44584. */
  44585. easingFunction?: EasingFunction;
  44586. }
  44587. /**
  44588. * Options to modify the vr experience helper's behavior.
  44589. */
  44590. export interface VRExperienceHelperOptions extends WebVROptions {
  44591. /**
  44592. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44593. */
  44594. createDeviceOrientationCamera?: boolean;
  44595. /**
  44596. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44597. */
  44598. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44599. /**
  44600. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44601. */
  44602. laserToggle?: boolean;
  44603. /**
  44604. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44605. */
  44606. floorMeshes?: Mesh[];
  44607. /**
  44608. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44609. */
  44610. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44611. /**
  44612. * Defines if WebXR should be used instead of WebVR (if available)
  44613. */
  44614. useXR?: boolean;
  44615. }
  44616. /**
  44617. * Event containing information after VR has been entered
  44618. */
  44619. export class OnAfterEnteringVRObservableEvent {
  44620. /**
  44621. * If entering vr was successful
  44622. */
  44623. success: boolean;
  44624. }
  44625. /**
  44626. * Helps to quickly add VR support to an existing scene.
  44627. * See http://doc.babylonjs.com/how_to/webvr_helper
  44628. */
  44629. export class VRExperienceHelper {
  44630. /** Options to modify the vr experience helper's behavior. */
  44631. webVROptions: VRExperienceHelperOptions;
  44632. private _scene;
  44633. private _position;
  44634. private _btnVR;
  44635. private _btnVRDisplayed;
  44636. private _webVRsupported;
  44637. private _webVRready;
  44638. private _webVRrequesting;
  44639. private _webVRpresenting;
  44640. private _hasEnteredVR;
  44641. private _fullscreenVRpresenting;
  44642. private _inputElement;
  44643. private _webVRCamera;
  44644. private _vrDeviceOrientationCamera;
  44645. private _deviceOrientationCamera;
  44646. private _existingCamera;
  44647. private _onKeyDown;
  44648. private _onVrDisplayPresentChange;
  44649. private _onVRDisplayChanged;
  44650. private _onVRRequestPresentStart;
  44651. private _onVRRequestPresentComplete;
  44652. /**
  44653. * 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)
  44654. */
  44655. enableGazeEvenWhenNoPointerLock: boolean;
  44656. /**
  44657. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44658. */
  44659. exitVROnDoubleTap: boolean;
  44660. /**
  44661. * Observable raised right before entering VR.
  44662. */
  44663. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44664. /**
  44665. * Observable raised when entering VR has completed.
  44666. */
  44667. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44668. /**
  44669. * Observable raised when exiting VR.
  44670. */
  44671. onExitingVRObservable: Observable<VRExperienceHelper>;
  44672. /**
  44673. * Observable raised when controller mesh is loaded.
  44674. */
  44675. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44676. /** Return this.onEnteringVRObservable
  44677. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44678. */
  44679. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44680. /** Return this.onExitingVRObservable
  44681. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44682. */
  44683. readonly onExitingVR: Observable<VRExperienceHelper>;
  44684. /** Return this.onControllerMeshLoadedObservable
  44685. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44686. */
  44687. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44688. private _rayLength;
  44689. private _useCustomVRButton;
  44690. private _teleportationRequested;
  44691. private _teleportActive;
  44692. private _floorMeshName;
  44693. private _floorMeshesCollection;
  44694. private _teleportationMode;
  44695. private _teleportationTime;
  44696. private _teleportationSpeed;
  44697. private _teleportationEasing;
  44698. private _rotationAllowed;
  44699. private _teleportBackwardsVector;
  44700. private _teleportationTarget;
  44701. private _isDefaultTeleportationTarget;
  44702. private _postProcessMove;
  44703. private _teleportationFillColor;
  44704. private _teleportationBorderColor;
  44705. private _rotationAngle;
  44706. private _haloCenter;
  44707. private _cameraGazer;
  44708. private _padSensibilityUp;
  44709. private _padSensibilityDown;
  44710. private _leftController;
  44711. private _rightController;
  44712. /**
  44713. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44714. */
  44715. onNewMeshSelected: Observable<AbstractMesh>;
  44716. /**
  44717. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44718. * This observable will provide the mesh and the controller used to select the mesh
  44719. */
  44720. onMeshSelectedWithController: Observable<{
  44721. mesh: AbstractMesh;
  44722. controller: WebVRController;
  44723. }>;
  44724. /**
  44725. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44726. */
  44727. onNewMeshPicked: Observable<PickingInfo>;
  44728. private _circleEase;
  44729. /**
  44730. * Observable raised before camera teleportation
  44731. */
  44732. onBeforeCameraTeleport: Observable<Vector3>;
  44733. /**
  44734. * Observable raised after camera teleportation
  44735. */
  44736. onAfterCameraTeleport: Observable<Vector3>;
  44737. /**
  44738. * Observable raised when current selected mesh gets unselected
  44739. */
  44740. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44741. private _raySelectionPredicate;
  44742. /**
  44743. * To be optionaly changed by user to define custom ray selection
  44744. */
  44745. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44746. /**
  44747. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44748. */
  44749. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44750. /**
  44751. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44752. */
  44753. teleportationEnabled: boolean;
  44754. private _defaultHeight;
  44755. private _teleportationInitialized;
  44756. private _interactionsEnabled;
  44757. private _interactionsRequested;
  44758. private _displayGaze;
  44759. private _displayLaserPointer;
  44760. /**
  44761. * The mesh used to display where the user is going to teleport.
  44762. */
  44763. /**
  44764. * Sets the mesh to be used to display where the user is going to teleport.
  44765. */
  44766. teleportationTarget: Mesh;
  44767. /**
  44768. * 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
  44769. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44770. * See http://doc.babylonjs.com/resources/baking_transformations
  44771. */
  44772. gazeTrackerMesh: Mesh;
  44773. /**
  44774. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44775. */
  44776. updateGazeTrackerScale: boolean;
  44777. /**
  44778. * If the gaze trackers color should be updated when selecting meshes
  44779. */
  44780. updateGazeTrackerColor: boolean;
  44781. /**
  44782. * If the controller laser color should be updated when selecting meshes
  44783. */
  44784. updateControllerLaserColor: boolean;
  44785. /**
  44786. * The gaze tracking mesh corresponding to the left controller
  44787. */
  44788. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44789. /**
  44790. * The gaze tracking mesh corresponding to the right controller
  44791. */
  44792. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44793. /**
  44794. * If the ray of the gaze should be displayed.
  44795. */
  44796. /**
  44797. * Sets if the ray of the gaze should be displayed.
  44798. */
  44799. displayGaze: boolean;
  44800. /**
  44801. * If the ray of the LaserPointer should be displayed.
  44802. */
  44803. /**
  44804. * Sets if the ray of the LaserPointer should be displayed.
  44805. */
  44806. displayLaserPointer: boolean;
  44807. /**
  44808. * The deviceOrientationCamera used as the camera when not in VR.
  44809. */
  44810. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44811. /**
  44812. * Based on the current WebVR support, returns the current VR camera used.
  44813. */
  44814. readonly currentVRCamera: Nullable<Camera>;
  44815. /**
  44816. * The webVRCamera which is used when in VR.
  44817. */
  44818. readonly webVRCamera: WebVRFreeCamera;
  44819. /**
  44820. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44821. */
  44822. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44823. /**
  44824. * The html button that is used to trigger entering into VR.
  44825. */
  44826. readonly vrButton: Nullable<HTMLButtonElement>;
  44827. private readonly _teleportationRequestInitiated;
  44828. /**
  44829. * Defines wether or not Pointer lock should be requested when switching to
  44830. * full screen.
  44831. */
  44832. requestPointerLockOnFullScreen: boolean;
  44833. /**
  44834. * If asking to force XR, this will be populated with the default xr experience
  44835. */
  44836. xr: WebXRDefaultExperience;
  44837. /**
  44838. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44839. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44840. */
  44841. xrTestDone: boolean;
  44842. /**
  44843. * Instantiates a VRExperienceHelper.
  44844. * Helps to quickly add VR support to an existing scene.
  44845. * @param scene The scene the VRExperienceHelper belongs to.
  44846. * @param webVROptions Options to modify the vr experience helper's behavior.
  44847. */
  44848. constructor(scene: Scene,
  44849. /** Options to modify the vr experience helper's behavior. */
  44850. webVROptions?: VRExperienceHelperOptions);
  44851. private completeVRInit;
  44852. private _onDefaultMeshLoaded;
  44853. private _onResize;
  44854. private _onFullscreenChange;
  44855. /**
  44856. * Gets a value indicating if we are currently in VR mode.
  44857. */
  44858. readonly isInVRMode: boolean;
  44859. private onVrDisplayPresentChange;
  44860. private onVRDisplayChanged;
  44861. private moveButtonToBottomRight;
  44862. private displayVRButton;
  44863. private updateButtonVisibility;
  44864. private _cachedAngularSensibility;
  44865. /**
  44866. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44867. * Otherwise, will use the fullscreen API.
  44868. */
  44869. enterVR(): void;
  44870. /**
  44871. * Attempt to exit VR, or fullscreen.
  44872. */
  44873. exitVR(): void;
  44874. /**
  44875. * The position of the vr experience helper.
  44876. */
  44877. /**
  44878. * Sets the position of the vr experience helper.
  44879. */
  44880. position: Vector3;
  44881. /**
  44882. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44883. */
  44884. enableInteractions(): void;
  44885. private readonly _noControllerIsActive;
  44886. private beforeRender;
  44887. private _isTeleportationFloor;
  44888. /**
  44889. * Adds a floor mesh to be used for teleportation.
  44890. * @param floorMesh the mesh to be used for teleportation.
  44891. */
  44892. addFloorMesh(floorMesh: Mesh): void;
  44893. /**
  44894. * Removes a floor mesh from being used for teleportation.
  44895. * @param floorMesh the mesh to be removed.
  44896. */
  44897. removeFloorMesh(floorMesh: Mesh): void;
  44898. /**
  44899. * Enables interactions and teleportation using the VR controllers and gaze.
  44900. * @param vrTeleportationOptions options to modify teleportation behavior.
  44901. */
  44902. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44903. private _onNewGamepadConnected;
  44904. private _tryEnableInteractionOnController;
  44905. private _onNewGamepadDisconnected;
  44906. private _enableInteractionOnController;
  44907. private _checkTeleportWithRay;
  44908. private _checkRotate;
  44909. private _checkTeleportBackwards;
  44910. private _enableTeleportationOnController;
  44911. private _createTeleportationCircles;
  44912. private _displayTeleportationTarget;
  44913. private _hideTeleportationTarget;
  44914. private _rotateCamera;
  44915. private _moveTeleportationSelectorTo;
  44916. private _workingVector;
  44917. private _workingQuaternion;
  44918. private _workingMatrix;
  44919. /**
  44920. * Time Constant Teleportation Mode
  44921. */
  44922. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44923. /**
  44924. * Speed Constant Teleportation Mode
  44925. */
  44926. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44927. /**
  44928. * Teleports the users feet to the desired location
  44929. * @param location The location where the user's feet should be placed
  44930. */
  44931. teleportCamera(location: Vector3): void;
  44932. private _convertNormalToDirectionOfRay;
  44933. private _castRayAndSelectObject;
  44934. private _notifySelectedMeshUnselected;
  44935. /**
  44936. * Sets the color of the laser ray from the vr controllers.
  44937. * @param color new color for the ray.
  44938. */
  44939. changeLaserColor(color: Color3): void;
  44940. /**
  44941. * Sets the color of the ray from the vr headsets gaze.
  44942. * @param color new color for the ray.
  44943. */
  44944. changeGazeColor(color: Color3): void;
  44945. /**
  44946. * Exits VR and disposes of the vr experience helper
  44947. */
  44948. dispose(): void;
  44949. /**
  44950. * Gets the name of the VRExperienceHelper class
  44951. * @returns "VRExperienceHelper"
  44952. */
  44953. getClassName(): string;
  44954. }
  44955. }
  44956. declare module "babylonjs/Cameras/VR/index" {
  44957. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  44958. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  44959. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44960. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  44961. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  44962. export * from "babylonjs/Cameras/VR/webVRCamera";
  44963. }
  44964. declare module "babylonjs/Cameras/XR/index" {
  44965. export * from "babylonjs/Cameras/XR/webXRCamera";
  44966. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44967. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44968. export * from "babylonjs/Cameras/XR/webXRInput";
  44969. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44970. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44971. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44972. export * from "babylonjs/Cameras/XR/webXRController";
  44973. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44974. export * from "babylonjs/Cameras/XR/webXRTypes";
  44975. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44976. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44977. }
  44978. declare module "babylonjs/Cameras/RigModes/index" {
  44979. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44980. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44981. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44982. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44983. }
  44984. declare module "babylonjs/Cameras/index" {
  44985. export * from "babylonjs/Cameras/Inputs/index";
  44986. export * from "babylonjs/Cameras/cameraInputsManager";
  44987. export * from "babylonjs/Cameras/camera";
  44988. export * from "babylonjs/Cameras/targetCamera";
  44989. export * from "babylonjs/Cameras/freeCamera";
  44990. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44991. export * from "babylonjs/Cameras/touchCamera";
  44992. export * from "babylonjs/Cameras/arcRotateCamera";
  44993. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44994. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44995. export * from "babylonjs/Cameras/flyCamera";
  44996. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44997. export * from "babylonjs/Cameras/followCamera";
  44998. export * from "babylonjs/Cameras/followCameraInputsManager";
  44999. export * from "babylonjs/Cameras/gamepadCamera";
  45000. export * from "babylonjs/Cameras/Stereoscopic/index";
  45001. export * from "babylonjs/Cameras/universalCamera";
  45002. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45003. export * from "babylonjs/Cameras/VR/index";
  45004. export * from "babylonjs/Cameras/XR/index";
  45005. export * from "babylonjs/Cameras/RigModes/index";
  45006. }
  45007. declare module "babylonjs/Collisions/index" {
  45008. export * from "babylonjs/Collisions/collider";
  45009. export * from "babylonjs/Collisions/collisionCoordinator";
  45010. export * from "babylonjs/Collisions/pickingInfo";
  45011. export * from "babylonjs/Collisions/intersectionInfo";
  45012. export * from "babylonjs/Collisions/meshCollisionData";
  45013. }
  45014. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45015. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45016. import { Vector3 } from "babylonjs/Maths/math.vector";
  45017. import { Ray } from "babylonjs/Culling/ray";
  45018. import { Plane } from "babylonjs/Maths/math.plane";
  45019. /**
  45020. * Contains an array of blocks representing the octree
  45021. */
  45022. export interface IOctreeContainer<T> {
  45023. /**
  45024. * Blocks within the octree
  45025. */
  45026. blocks: Array<OctreeBlock<T>>;
  45027. }
  45028. /**
  45029. * Class used to store a cell in an octree
  45030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45031. */
  45032. export class OctreeBlock<T> {
  45033. /**
  45034. * Gets the content of the current block
  45035. */
  45036. entries: T[];
  45037. /**
  45038. * Gets the list of block children
  45039. */
  45040. blocks: Array<OctreeBlock<T>>;
  45041. private _depth;
  45042. private _maxDepth;
  45043. private _capacity;
  45044. private _minPoint;
  45045. private _maxPoint;
  45046. private _boundingVectors;
  45047. private _creationFunc;
  45048. /**
  45049. * Creates a new block
  45050. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45051. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45052. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45053. * @param depth defines the current depth of this block in the octree
  45054. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45055. * @param creationFunc defines a callback to call when an element is added to the block
  45056. */
  45057. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45058. /**
  45059. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45060. */
  45061. readonly capacity: number;
  45062. /**
  45063. * Gets the minimum vector (in world space) of the block's bounding box
  45064. */
  45065. readonly minPoint: Vector3;
  45066. /**
  45067. * Gets the maximum vector (in world space) of the block's bounding box
  45068. */
  45069. readonly maxPoint: Vector3;
  45070. /**
  45071. * Add a new element to this block
  45072. * @param entry defines the element to add
  45073. */
  45074. addEntry(entry: T): void;
  45075. /**
  45076. * Remove an element from this block
  45077. * @param entry defines the element to remove
  45078. */
  45079. removeEntry(entry: T): void;
  45080. /**
  45081. * Add an array of elements to this block
  45082. * @param entries defines the array of elements to add
  45083. */
  45084. addEntries(entries: T[]): void;
  45085. /**
  45086. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45087. * @param frustumPlanes defines the frustum planes to test
  45088. * @param selection defines the array to store current content if selection is positive
  45089. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45090. */
  45091. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45092. /**
  45093. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45094. * @param sphereCenter defines the bounding sphere center
  45095. * @param sphereRadius defines the bounding sphere radius
  45096. * @param selection defines the array to store current content if selection is positive
  45097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45098. */
  45099. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45100. /**
  45101. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45102. * @param ray defines the ray to test with
  45103. * @param selection defines the array to store current content if selection is positive
  45104. */
  45105. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45106. /**
  45107. * Subdivide the content into child blocks (this block will then be empty)
  45108. */
  45109. createInnerBlocks(): void;
  45110. /**
  45111. * @hidden
  45112. */
  45113. 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;
  45114. }
  45115. }
  45116. declare module "babylonjs/Culling/Octrees/octree" {
  45117. import { SmartArray } from "babylonjs/Misc/smartArray";
  45118. import { Vector3 } from "babylonjs/Maths/math.vector";
  45119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45121. import { Ray } from "babylonjs/Culling/ray";
  45122. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45123. import { Plane } from "babylonjs/Maths/math.plane";
  45124. /**
  45125. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45126. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45127. */
  45128. export class Octree<T> {
  45129. /** 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.) */
  45130. maxDepth: number;
  45131. /**
  45132. * Blocks within the octree containing objects
  45133. */
  45134. blocks: Array<OctreeBlock<T>>;
  45135. /**
  45136. * Content stored in the octree
  45137. */
  45138. dynamicContent: T[];
  45139. private _maxBlockCapacity;
  45140. private _selectionContent;
  45141. private _creationFunc;
  45142. /**
  45143. * Creates a octree
  45144. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45145. * @param creationFunc function to be used to instatiate the octree
  45146. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45147. * @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.)
  45148. */
  45149. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  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. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45154. * @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);
  45155. * @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);
  45156. * @param entries meshes to be added to the octree blocks
  45157. */
  45158. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45159. /**
  45160. * Adds a mesh to the octree
  45161. * @param entry Mesh to add to the octree
  45162. */
  45163. addMesh(entry: T): void;
  45164. /**
  45165. * Remove an element from the octree
  45166. * @param entry defines the element to remove
  45167. */
  45168. removeMesh(entry: T): void;
  45169. /**
  45170. * Selects an array of meshes within the frustum
  45171. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45172. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45173. * @returns array of meshes within the frustum
  45174. */
  45175. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45176. /**
  45177. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45178. * @param sphereCenter defines the bounding sphere center
  45179. * @param sphereRadius defines the bounding sphere radius
  45180. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45181. * @returns an array of objects that intersect the sphere
  45182. */
  45183. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45184. /**
  45185. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45186. * @param ray defines the ray to test with
  45187. * @returns array of intersected objects
  45188. */
  45189. intersectsRay(ray: Ray): SmartArray<T>;
  45190. /**
  45191. * Adds a mesh into the octree block if it intersects the block
  45192. */
  45193. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45194. /**
  45195. * Adds a submesh into the octree block if it intersects the block
  45196. */
  45197. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45198. }
  45199. }
  45200. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45201. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45202. import { Scene } from "babylonjs/scene";
  45203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45205. import { Ray } from "babylonjs/Culling/ray";
  45206. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45207. import { Collider } from "babylonjs/Collisions/collider";
  45208. module "babylonjs/scene" {
  45209. interface Scene {
  45210. /**
  45211. * @hidden
  45212. * Backing Filed
  45213. */
  45214. _selectionOctree: Octree<AbstractMesh>;
  45215. /**
  45216. * Gets the octree used to boost mesh selection (picking)
  45217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45218. */
  45219. selectionOctree: Octree<AbstractMesh>;
  45220. /**
  45221. * Creates or updates the octree used to boost selection (picking)
  45222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45223. * @param maxCapacity defines the maximum capacity per leaf
  45224. * @param maxDepth defines the maximum depth of the octree
  45225. * @returns an octree of AbstractMesh
  45226. */
  45227. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45228. }
  45229. }
  45230. module "babylonjs/Meshes/abstractMesh" {
  45231. interface AbstractMesh {
  45232. /**
  45233. * @hidden
  45234. * Backing Field
  45235. */
  45236. _submeshesOctree: Octree<SubMesh>;
  45237. /**
  45238. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45239. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45240. * @param maxCapacity defines the maximum size of each block (64 by default)
  45241. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45242. * @returns the new octree
  45243. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45244. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45245. */
  45246. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45247. }
  45248. }
  45249. /**
  45250. * Defines the octree scene component responsible to manage any octrees
  45251. * in a given scene.
  45252. */
  45253. export class OctreeSceneComponent {
  45254. /**
  45255. * The component name help to identify the component in the list of scene components.
  45256. */
  45257. readonly name: string;
  45258. /**
  45259. * The scene the component belongs to.
  45260. */
  45261. scene: Scene;
  45262. /**
  45263. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45264. */
  45265. readonly checksIsEnabled: boolean;
  45266. /**
  45267. * Creates a new instance of the component for the given scene
  45268. * @param scene Defines the scene to register the component in
  45269. */
  45270. constructor(scene: Scene);
  45271. /**
  45272. * Registers the component in a given scene
  45273. */
  45274. register(): void;
  45275. /**
  45276. * Return the list of active meshes
  45277. * @returns the list of active meshes
  45278. */
  45279. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45280. /**
  45281. * Return the list of active sub meshes
  45282. * @param mesh The mesh to get the candidates sub meshes from
  45283. * @returns the list of active sub meshes
  45284. */
  45285. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45286. private _tempRay;
  45287. /**
  45288. * Return the list of sub meshes intersecting with a given local ray
  45289. * @param mesh defines the mesh to find the submesh for
  45290. * @param localRay defines the ray in local space
  45291. * @returns the list of intersecting sub meshes
  45292. */
  45293. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45294. /**
  45295. * Return the list of sub meshes colliding with a collider
  45296. * @param mesh defines the mesh to find the submesh for
  45297. * @param collider defines the collider to evaluate the collision against
  45298. * @returns the list of colliding sub meshes
  45299. */
  45300. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45301. /**
  45302. * Rebuilds the elements related to this component in case of
  45303. * context lost for instance.
  45304. */
  45305. rebuild(): void;
  45306. /**
  45307. * Disposes the component and the associated ressources.
  45308. */
  45309. dispose(): void;
  45310. }
  45311. }
  45312. declare module "babylonjs/Culling/Octrees/index" {
  45313. export * from "babylonjs/Culling/Octrees/octree";
  45314. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45315. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45316. }
  45317. declare module "babylonjs/Culling/index" {
  45318. export * from "babylonjs/Culling/boundingBox";
  45319. export * from "babylonjs/Culling/boundingInfo";
  45320. export * from "babylonjs/Culling/boundingSphere";
  45321. export * from "babylonjs/Culling/Octrees/index";
  45322. export * from "babylonjs/Culling/ray";
  45323. }
  45324. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45325. import { IDisposable, Scene } from "babylonjs/scene";
  45326. import { Nullable } from "babylonjs/types";
  45327. import { Observable } from "babylonjs/Misc/observable";
  45328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45329. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45330. import { Camera } from "babylonjs/Cameras/camera";
  45331. /**
  45332. * Renders a layer on top of an existing scene
  45333. */
  45334. export class UtilityLayerRenderer implements IDisposable {
  45335. /** the original scene that will be rendered on top of */
  45336. originalScene: Scene;
  45337. private _pointerCaptures;
  45338. private _lastPointerEvents;
  45339. private static _DefaultUtilityLayer;
  45340. private static _DefaultKeepDepthUtilityLayer;
  45341. private _sharedGizmoLight;
  45342. private _renderCamera;
  45343. /**
  45344. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45345. * @returns the camera that is used when rendering the utility layer
  45346. */
  45347. getRenderCamera(): Nullable<Camera>;
  45348. /**
  45349. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45350. * @param cam the camera that should be used when rendering the utility layer
  45351. */
  45352. setRenderCamera(cam: Nullable<Camera>): void;
  45353. /**
  45354. * @hidden
  45355. * Light which used by gizmos to get light shading
  45356. */
  45357. _getSharedGizmoLight(): HemisphericLight;
  45358. /**
  45359. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45360. */
  45361. pickUtilitySceneFirst: boolean;
  45362. /**
  45363. * 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)
  45364. */
  45365. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45366. /**
  45367. * 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)
  45368. */
  45369. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45370. /**
  45371. * The scene that is rendered on top of the original scene
  45372. */
  45373. utilityLayerScene: Scene;
  45374. /**
  45375. * If the utility layer should automatically be rendered on top of existing scene
  45376. */
  45377. shouldRender: boolean;
  45378. /**
  45379. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45380. */
  45381. onlyCheckPointerDownEvents: boolean;
  45382. /**
  45383. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45384. */
  45385. processAllEvents: boolean;
  45386. /**
  45387. * Observable raised when the pointer move from the utility layer scene to the main scene
  45388. */
  45389. onPointerOutObservable: Observable<number>;
  45390. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45391. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45392. private _afterRenderObserver;
  45393. private _sceneDisposeObserver;
  45394. private _originalPointerObserver;
  45395. /**
  45396. * Instantiates a UtilityLayerRenderer
  45397. * @param originalScene the original scene that will be rendered on top of
  45398. * @param handleEvents boolean indicating if the utility layer should handle events
  45399. */
  45400. constructor(
  45401. /** the original scene that will be rendered on top of */
  45402. originalScene: Scene, handleEvents?: boolean);
  45403. private _notifyObservers;
  45404. /**
  45405. * Renders the utility layers scene on top of the original scene
  45406. */
  45407. render(): void;
  45408. /**
  45409. * Disposes of the renderer
  45410. */
  45411. dispose(): void;
  45412. private _updateCamera;
  45413. }
  45414. }
  45415. declare module "babylonjs/Gizmos/gizmo" {
  45416. import { Nullable } from "babylonjs/types";
  45417. import { IDisposable } from "babylonjs/scene";
  45418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45419. import { Mesh } from "babylonjs/Meshes/mesh";
  45420. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45421. /**
  45422. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45423. */
  45424. export class Gizmo implements IDisposable {
  45425. /** The utility layer the gizmo will be added to */
  45426. gizmoLayer: UtilityLayerRenderer;
  45427. /**
  45428. * The root mesh of the gizmo
  45429. */
  45430. _rootMesh: Mesh;
  45431. private _attachedMesh;
  45432. /**
  45433. * Ratio for the scale of the gizmo (Default: 1)
  45434. */
  45435. scaleRatio: number;
  45436. /**
  45437. * If a custom mesh has been set (Default: false)
  45438. */
  45439. protected _customMeshSet: boolean;
  45440. /**
  45441. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45442. * * When set, interactions will be enabled
  45443. */
  45444. attachedMesh: Nullable<AbstractMesh>;
  45445. /**
  45446. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45447. * @param mesh The mesh to replace the default mesh of the gizmo
  45448. */
  45449. setCustomMesh(mesh: Mesh): void;
  45450. /**
  45451. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45452. */
  45453. updateGizmoRotationToMatchAttachedMesh: boolean;
  45454. /**
  45455. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45456. */
  45457. updateGizmoPositionToMatchAttachedMesh: boolean;
  45458. /**
  45459. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45460. */
  45461. updateScale: boolean;
  45462. protected _interactionsEnabled: boolean;
  45463. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45464. private _beforeRenderObserver;
  45465. private _tempVector;
  45466. /**
  45467. * Creates a gizmo
  45468. * @param gizmoLayer The utility layer the gizmo will be added to
  45469. */
  45470. constructor(
  45471. /** The utility layer the gizmo will be added to */
  45472. gizmoLayer?: UtilityLayerRenderer);
  45473. /**
  45474. * Updates the gizmo to match the attached mesh's position/rotation
  45475. */
  45476. protected _update(): void;
  45477. /**
  45478. * Disposes of the gizmo
  45479. */
  45480. dispose(): void;
  45481. }
  45482. }
  45483. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45484. import { Observable } from "babylonjs/Misc/observable";
  45485. import { Nullable } from "babylonjs/types";
  45486. import { Vector3 } from "babylonjs/Maths/math.vector";
  45487. import { Color3 } from "babylonjs/Maths/math.color";
  45488. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45490. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45491. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45492. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45493. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45494. import { Scene } from "babylonjs/scene";
  45495. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45496. /**
  45497. * Single plane drag gizmo
  45498. */
  45499. export class PlaneDragGizmo extends Gizmo {
  45500. /**
  45501. * Drag behavior responsible for the gizmos dragging interactions
  45502. */
  45503. dragBehavior: PointerDragBehavior;
  45504. private _pointerObserver;
  45505. /**
  45506. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45507. */
  45508. snapDistance: number;
  45509. /**
  45510. * Event that fires each time the gizmo snaps to a new location.
  45511. * * snapDistance is the the change in distance
  45512. */
  45513. onSnapObservable: Observable<{
  45514. snapDistance: number;
  45515. }>;
  45516. private _plane;
  45517. private _coloredMaterial;
  45518. private _hoverMaterial;
  45519. private _isEnabled;
  45520. private _parent;
  45521. /** @hidden */
  45522. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45523. /** @hidden */
  45524. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45525. /**
  45526. * Creates a PlaneDragGizmo
  45527. * @param gizmoLayer The utility layer the gizmo will be added to
  45528. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45529. * @param color The color of the gizmo
  45530. */
  45531. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45532. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45533. /**
  45534. * If the gizmo is enabled
  45535. */
  45536. isEnabled: boolean;
  45537. /**
  45538. * Disposes of the gizmo
  45539. */
  45540. dispose(): void;
  45541. }
  45542. }
  45543. declare module "babylonjs/Gizmos/positionGizmo" {
  45544. import { Observable } from "babylonjs/Misc/observable";
  45545. import { Nullable } from "babylonjs/types";
  45546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45547. import { Mesh } from "babylonjs/Meshes/mesh";
  45548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45549. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45550. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45551. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45552. /**
  45553. * Gizmo that enables dragging a mesh along 3 axis
  45554. */
  45555. export class PositionGizmo extends Gizmo {
  45556. /**
  45557. * Internal gizmo used for interactions on the x axis
  45558. */
  45559. xGizmo: AxisDragGizmo;
  45560. /**
  45561. * Internal gizmo used for interactions on the y axis
  45562. */
  45563. yGizmo: AxisDragGizmo;
  45564. /**
  45565. * Internal gizmo used for interactions on the z axis
  45566. */
  45567. zGizmo: AxisDragGizmo;
  45568. /**
  45569. * Internal gizmo used for interactions on the yz plane
  45570. */
  45571. xPlaneGizmo: PlaneDragGizmo;
  45572. /**
  45573. * Internal gizmo used for interactions on the xz plane
  45574. */
  45575. yPlaneGizmo: PlaneDragGizmo;
  45576. /**
  45577. * Internal gizmo used for interactions on the xy plane
  45578. */
  45579. zPlaneGizmo: PlaneDragGizmo;
  45580. /**
  45581. * private variables
  45582. */
  45583. private _meshAttached;
  45584. private _updateGizmoRotationToMatchAttachedMesh;
  45585. private _snapDistance;
  45586. private _scaleRatio;
  45587. /** Fires an event when any of it's sub gizmos are dragged */
  45588. onDragStartObservable: Observable<unknown>;
  45589. /** Fires an event when any of it's sub gizmos are released from dragging */
  45590. onDragEndObservable: Observable<unknown>;
  45591. /**
  45592. * If set to true, planar drag is enabled
  45593. */
  45594. private _planarGizmoEnabled;
  45595. attachedMesh: Nullable<AbstractMesh>;
  45596. /**
  45597. * Creates a PositionGizmo
  45598. * @param gizmoLayer The utility layer the gizmo will be added to
  45599. */
  45600. constructor(gizmoLayer?: UtilityLayerRenderer);
  45601. /**
  45602. * If the planar drag gizmo is enabled
  45603. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45604. */
  45605. planarGizmoEnabled: boolean;
  45606. updateGizmoRotationToMatchAttachedMesh: boolean;
  45607. /**
  45608. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45609. */
  45610. snapDistance: number;
  45611. /**
  45612. * Ratio for the scale of the gizmo (Default: 1)
  45613. */
  45614. scaleRatio: number;
  45615. /**
  45616. * Disposes of the gizmo
  45617. */
  45618. dispose(): void;
  45619. /**
  45620. * CustomMeshes are not supported by this gizmo
  45621. * @param mesh The mesh to replace the default mesh of the gizmo
  45622. */
  45623. setCustomMesh(mesh: Mesh): void;
  45624. }
  45625. }
  45626. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45627. import { Observable } from "babylonjs/Misc/observable";
  45628. import { Nullable } from "babylonjs/types";
  45629. import { Vector3 } from "babylonjs/Maths/math.vector";
  45630. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45632. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45633. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45634. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45635. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45636. import { Scene } from "babylonjs/scene";
  45637. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45638. import { Color3 } from "babylonjs/Maths/math.color";
  45639. /**
  45640. * Single axis drag gizmo
  45641. */
  45642. export class AxisDragGizmo extends Gizmo {
  45643. /**
  45644. * Drag behavior responsible for the gizmos dragging interactions
  45645. */
  45646. dragBehavior: PointerDragBehavior;
  45647. private _pointerObserver;
  45648. /**
  45649. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45650. */
  45651. snapDistance: number;
  45652. /**
  45653. * Event that fires each time the gizmo snaps to a new location.
  45654. * * snapDistance is the the change in distance
  45655. */
  45656. onSnapObservable: Observable<{
  45657. snapDistance: number;
  45658. }>;
  45659. private _isEnabled;
  45660. private _parent;
  45661. private _arrow;
  45662. private _coloredMaterial;
  45663. private _hoverMaterial;
  45664. /** @hidden */
  45665. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45666. /** @hidden */
  45667. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45668. /**
  45669. * Creates an AxisDragGizmo
  45670. * @param gizmoLayer The utility layer the gizmo will be added to
  45671. * @param dragAxis The axis which the gizmo will be able to drag on
  45672. * @param color The color of the gizmo
  45673. */
  45674. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45675. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45676. /**
  45677. * If the gizmo is enabled
  45678. */
  45679. isEnabled: boolean;
  45680. /**
  45681. * Disposes of the gizmo
  45682. */
  45683. dispose(): void;
  45684. }
  45685. }
  45686. declare module "babylonjs/Debug/axesViewer" {
  45687. import { Vector3 } from "babylonjs/Maths/math.vector";
  45688. import { Nullable } from "babylonjs/types";
  45689. import { Scene } from "babylonjs/scene";
  45690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45691. /**
  45692. * The Axes viewer will show 3 axes in a specific point in space
  45693. */
  45694. export class AxesViewer {
  45695. private _xAxis;
  45696. private _yAxis;
  45697. private _zAxis;
  45698. private _scaleLinesFactor;
  45699. private _instanced;
  45700. /**
  45701. * Gets the hosting scene
  45702. */
  45703. scene: Scene;
  45704. /**
  45705. * Gets or sets a number used to scale line length
  45706. */
  45707. scaleLines: number;
  45708. /** Gets the node hierarchy used to render x-axis */
  45709. readonly xAxis: TransformNode;
  45710. /** Gets the node hierarchy used to render y-axis */
  45711. readonly yAxis: TransformNode;
  45712. /** Gets the node hierarchy used to render z-axis */
  45713. readonly zAxis: TransformNode;
  45714. /**
  45715. * Creates a new AxesViewer
  45716. * @param scene defines the hosting scene
  45717. * @param scaleLines defines a number used to scale line length (1 by default)
  45718. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45719. * @param xAxis defines the node hierarchy used to render the x-axis
  45720. * @param yAxis defines the node hierarchy used to render the y-axis
  45721. * @param zAxis defines the node hierarchy used to render the z-axis
  45722. */
  45723. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45724. /**
  45725. * Force the viewer to update
  45726. * @param position defines the position of the viewer
  45727. * @param xaxis defines the x axis of the viewer
  45728. * @param yaxis defines the y axis of the viewer
  45729. * @param zaxis defines the z axis of the viewer
  45730. */
  45731. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45732. /**
  45733. * Creates an instance of this axes viewer.
  45734. * @returns a new axes viewer with instanced meshes
  45735. */
  45736. createInstance(): AxesViewer;
  45737. /** Releases resources */
  45738. dispose(): void;
  45739. private static _SetRenderingGroupId;
  45740. }
  45741. }
  45742. declare module "babylonjs/Debug/boneAxesViewer" {
  45743. import { Nullable } from "babylonjs/types";
  45744. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45745. import { Vector3 } from "babylonjs/Maths/math.vector";
  45746. import { Mesh } from "babylonjs/Meshes/mesh";
  45747. import { Bone } from "babylonjs/Bones/bone";
  45748. import { Scene } from "babylonjs/scene";
  45749. /**
  45750. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45751. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45752. */
  45753. export class BoneAxesViewer extends AxesViewer {
  45754. /**
  45755. * Gets or sets the target mesh where to display the axes viewer
  45756. */
  45757. mesh: Nullable<Mesh>;
  45758. /**
  45759. * Gets or sets the target bone where to display the axes viewer
  45760. */
  45761. bone: Nullable<Bone>;
  45762. /** Gets current position */
  45763. pos: Vector3;
  45764. /** Gets direction of X axis */
  45765. xaxis: Vector3;
  45766. /** Gets direction of Y axis */
  45767. yaxis: Vector3;
  45768. /** Gets direction of Z axis */
  45769. zaxis: Vector3;
  45770. /**
  45771. * Creates a new BoneAxesViewer
  45772. * @param scene defines the hosting scene
  45773. * @param bone defines the target bone
  45774. * @param mesh defines the target mesh
  45775. * @param scaleLines defines a scaling factor for line length (1 by default)
  45776. */
  45777. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45778. /**
  45779. * Force the viewer to update
  45780. */
  45781. update(): void;
  45782. /** Releases resources */
  45783. dispose(): void;
  45784. }
  45785. }
  45786. declare module "babylonjs/Debug/debugLayer" {
  45787. import { Scene } from "babylonjs/scene";
  45788. /**
  45789. * Interface used to define scene explorer extensibility option
  45790. */
  45791. export interface IExplorerExtensibilityOption {
  45792. /**
  45793. * Define the option label
  45794. */
  45795. label: string;
  45796. /**
  45797. * Defines the action to execute on click
  45798. */
  45799. action: (entity: any) => void;
  45800. }
  45801. /**
  45802. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45803. */
  45804. export interface IExplorerExtensibilityGroup {
  45805. /**
  45806. * Defines a predicate to test if a given type mut be extended
  45807. */
  45808. predicate: (entity: any) => boolean;
  45809. /**
  45810. * Gets the list of options added to a type
  45811. */
  45812. entries: IExplorerExtensibilityOption[];
  45813. }
  45814. /**
  45815. * Interface used to define the options to use to create the Inspector
  45816. */
  45817. export interface IInspectorOptions {
  45818. /**
  45819. * Display in overlay mode (default: false)
  45820. */
  45821. overlay?: boolean;
  45822. /**
  45823. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45824. */
  45825. globalRoot?: HTMLElement;
  45826. /**
  45827. * Display the Scene explorer
  45828. */
  45829. showExplorer?: boolean;
  45830. /**
  45831. * Display the property inspector
  45832. */
  45833. showInspector?: boolean;
  45834. /**
  45835. * Display in embed mode (both panes on the right)
  45836. */
  45837. embedMode?: boolean;
  45838. /**
  45839. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45840. */
  45841. handleResize?: boolean;
  45842. /**
  45843. * Allow the panes to popup (default: true)
  45844. */
  45845. enablePopup?: boolean;
  45846. /**
  45847. * Allow the panes to be closed by users (default: true)
  45848. */
  45849. enableClose?: boolean;
  45850. /**
  45851. * Optional list of extensibility entries
  45852. */
  45853. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45854. /**
  45855. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45856. */
  45857. inspectorURL?: string;
  45858. }
  45859. module "babylonjs/scene" {
  45860. interface Scene {
  45861. /**
  45862. * @hidden
  45863. * Backing field
  45864. */
  45865. _debugLayer: DebugLayer;
  45866. /**
  45867. * Gets the debug layer (aka Inspector) associated with the scene
  45868. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45869. */
  45870. debugLayer: DebugLayer;
  45871. }
  45872. }
  45873. /**
  45874. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45875. * what is happening in your scene
  45876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45877. */
  45878. export class DebugLayer {
  45879. /**
  45880. * Define the url to get the inspector script from.
  45881. * By default it uses the babylonjs CDN.
  45882. * @ignoreNaming
  45883. */
  45884. static InspectorURL: string;
  45885. private _scene;
  45886. private BJSINSPECTOR;
  45887. private _onPropertyChangedObservable?;
  45888. /**
  45889. * Observable triggered when a property is changed through the inspector.
  45890. */
  45891. readonly onPropertyChangedObservable: any;
  45892. /**
  45893. * Instantiates a new debug layer.
  45894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45895. * what is happening in your scene
  45896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45897. * @param scene Defines the scene to inspect
  45898. */
  45899. constructor(scene: Scene);
  45900. /** Creates the inspector window. */
  45901. private _createInspector;
  45902. /**
  45903. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45904. * @param entity defines the entity to select
  45905. * @param lineContainerTitle defines the specific block to highlight
  45906. */
  45907. select(entity: any, lineContainerTitle?: string): void;
  45908. /** Get the inspector from bundle or global */
  45909. private _getGlobalInspector;
  45910. /**
  45911. * Get if the inspector is visible or not.
  45912. * @returns true if visible otherwise, false
  45913. */
  45914. isVisible(): boolean;
  45915. /**
  45916. * Hide the inspector and close its window.
  45917. */
  45918. hide(): void;
  45919. /**
  45920. * Launch the debugLayer.
  45921. * @param config Define the configuration of the inspector
  45922. * @return a promise fulfilled when the debug layer is visible
  45923. */
  45924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45925. }
  45926. }
  45927. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45928. import { Nullable } from "babylonjs/types";
  45929. import { Scene } from "babylonjs/scene";
  45930. import { Vector4 } from "babylonjs/Maths/math.vector";
  45931. import { Color4 } from "babylonjs/Maths/math.color";
  45932. import { Mesh } from "babylonjs/Meshes/mesh";
  45933. /**
  45934. * Class containing static functions to help procedurally build meshes
  45935. */
  45936. export class BoxBuilder {
  45937. /**
  45938. * Creates a box mesh
  45939. * * The parameter `size` sets the size (float) of each box side (default 1)
  45940. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45941. * * 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)
  45942. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  45943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45946. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45947. * @param name defines the name of the mesh
  45948. * @param options defines the options used to create the mesh
  45949. * @param scene defines the hosting scene
  45950. * @returns the box mesh
  45951. */
  45952. static CreateBox(name: string, options: {
  45953. size?: number;
  45954. width?: number;
  45955. height?: number;
  45956. depth?: number;
  45957. faceUV?: Vector4[];
  45958. faceColors?: Color4[];
  45959. sideOrientation?: number;
  45960. frontUVs?: Vector4;
  45961. backUVs?: Vector4;
  45962. wrap?: boolean;
  45963. topBaseAt?: number;
  45964. bottomBaseAt?: number;
  45965. updatable?: boolean;
  45966. }, scene?: Nullable<Scene>): Mesh;
  45967. }
  45968. }
  45969. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45970. import { Vector4 } from "babylonjs/Maths/math.vector";
  45971. import { Mesh } from "babylonjs/Meshes/mesh";
  45972. import { Scene } from "babylonjs/scene";
  45973. import { Nullable } from "babylonjs/types";
  45974. /**
  45975. * Class containing static functions to help procedurally build meshes
  45976. */
  45977. export class SphereBuilder {
  45978. /**
  45979. * Creates a sphere mesh
  45980. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45981. * * 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`)
  45982. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45983. * * 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
  45984. * * 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)
  45985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45988. * @param name defines the name of the mesh
  45989. * @param options defines the options used to create the mesh
  45990. * @param scene defines the hosting scene
  45991. * @returns the sphere mesh
  45992. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45993. */
  45994. static CreateSphere(name: string, options: {
  45995. segments?: number;
  45996. diameter?: number;
  45997. diameterX?: number;
  45998. diameterY?: number;
  45999. diameterZ?: number;
  46000. arc?: number;
  46001. slice?: number;
  46002. sideOrientation?: number;
  46003. frontUVs?: Vector4;
  46004. backUVs?: Vector4;
  46005. updatable?: boolean;
  46006. }, scene?: Nullable<Scene>): Mesh;
  46007. }
  46008. }
  46009. declare module "babylonjs/Debug/physicsViewer" {
  46010. import { Nullable } from "babylonjs/types";
  46011. import { Scene } from "babylonjs/scene";
  46012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46013. import { Mesh } from "babylonjs/Meshes/mesh";
  46014. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46015. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46016. /**
  46017. * Used to show the physics impostor around the specific mesh
  46018. */
  46019. export class PhysicsViewer {
  46020. /** @hidden */
  46021. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46022. /** @hidden */
  46023. protected _meshes: Array<Nullable<AbstractMesh>>;
  46024. /** @hidden */
  46025. protected _scene: Nullable<Scene>;
  46026. /** @hidden */
  46027. protected _numMeshes: number;
  46028. /** @hidden */
  46029. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46030. private _renderFunction;
  46031. private _utilityLayer;
  46032. private _debugBoxMesh;
  46033. private _debugSphereMesh;
  46034. private _debugCylinderMesh;
  46035. private _debugMaterial;
  46036. private _debugMeshMeshes;
  46037. /**
  46038. * Creates a new PhysicsViewer
  46039. * @param scene defines the hosting scene
  46040. */
  46041. constructor(scene: Scene);
  46042. /** @hidden */
  46043. protected _updateDebugMeshes(): void;
  46044. /**
  46045. * Renders a specified physic impostor
  46046. * @param impostor defines the impostor to render
  46047. * @param targetMesh defines the mesh represented by the impostor
  46048. * @returns the new debug mesh used to render the impostor
  46049. */
  46050. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46051. /**
  46052. * Hides a specified physic impostor
  46053. * @param impostor defines the impostor to hide
  46054. */
  46055. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46056. private _getDebugMaterial;
  46057. private _getDebugBoxMesh;
  46058. private _getDebugSphereMesh;
  46059. private _getDebugCylinderMesh;
  46060. private _getDebugMeshMesh;
  46061. private _getDebugMesh;
  46062. /** Releases all resources */
  46063. dispose(): void;
  46064. }
  46065. }
  46066. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46067. import { Vector3 } from "babylonjs/Maths/math.vector";
  46068. import { Color4 } from "babylonjs/Maths/math.color";
  46069. import { Nullable } from "babylonjs/types";
  46070. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46071. import { Scene } from "babylonjs/scene";
  46072. /**
  46073. * Class containing static functions to help procedurally build meshes
  46074. */
  46075. export class LinesBuilder {
  46076. /**
  46077. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46078. * * 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
  46079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46080. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46081. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46082. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46083. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46084. * * 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
  46085. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46088. * @param name defines the name of the new line system
  46089. * @param options defines the options used to create the line system
  46090. * @param scene defines the hosting scene
  46091. * @returns a new line system mesh
  46092. */
  46093. static CreateLineSystem(name: string, options: {
  46094. lines: Vector3[][];
  46095. updatable?: boolean;
  46096. instance?: Nullable<LinesMesh>;
  46097. colors?: Nullable<Color4[][]>;
  46098. useVertexAlpha?: boolean;
  46099. }, scene: Nullable<Scene>): LinesMesh;
  46100. /**
  46101. * Creates a line mesh
  46102. * 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
  46103. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46104. * * The parameter `points` is an array successive Vector3
  46105. * * 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
  46106. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46107. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46108. * * When updating an instance, remember that only point positions can change, not the number of points
  46109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46111. * @param name defines the name of the new line system
  46112. * @param options defines the options used to create the line system
  46113. * @param scene defines the hosting scene
  46114. * @returns a new line mesh
  46115. */
  46116. static CreateLines(name: string, options: {
  46117. points: Vector3[];
  46118. updatable?: boolean;
  46119. instance?: Nullable<LinesMesh>;
  46120. colors?: Color4[];
  46121. useVertexAlpha?: boolean;
  46122. }, scene?: Nullable<Scene>): LinesMesh;
  46123. /**
  46124. * Creates a dashed line mesh
  46125. * * 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
  46126. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46127. * * The parameter `points` is an array successive Vector3
  46128. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46129. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46130. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46131. * * 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
  46132. * * When updating an instance, remember that only point positions can change, not the number of points
  46133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46134. * @param name defines the name of the mesh
  46135. * @param options defines the options used to create the mesh
  46136. * @param scene defines the hosting scene
  46137. * @returns the dashed line mesh
  46138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46139. */
  46140. static CreateDashedLines(name: string, options: {
  46141. points: Vector3[];
  46142. dashSize?: number;
  46143. gapSize?: number;
  46144. dashNb?: number;
  46145. updatable?: boolean;
  46146. instance?: LinesMesh;
  46147. }, scene?: Nullable<Scene>): LinesMesh;
  46148. }
  46149. }
  46150. declare module "babylonjs/Debug/rayHelper" {
  46151. import { Nullable } from "babylonjs/types";
  46152. import { Ray } from "babylonjs/Culling/ray";
  46153. import { Vector3 } from "babylonjs/Maths/math.vector";
  46154. import { Color3 } from "babylonjs/Maths/math.color";
  46155. import { Scene } from "babylonjs/scene";
  46156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46157. import "babylonjs/Meshes/Builders/linesBuilder";
  46158. /**
  46159. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46160. * in order to better appreciate the issue one might have.
  46161. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46162. */
  46163. export class RayHelper {
  46164. /**
  46165. * Defines the ray we are currently tryin to visualize.
  46166. */
  46167. ray: Nullable<Ray>;
  46168. private _renderPoints;
  46169. private _renderLine;
  46170. private _renderFunction;
  46171. private _scene;
  46172. private _updateToMeshFunction;
  46173. private _attachedToMesh;
  46174. private _meshSpaceDirection;
  46175. private _meshSpaceOrigin;
  46176. /**
  46177. * Helper function to create a colored helper in a scene in one line.
  46178. * @param ray Defines the ray we are currently tryin to visualize
  46179. * @param scene Defines the scene the ray is used in
  46180. * @param color Defines the color we want to see the ray in
  46181. * @returns The newly created ray helper.
  46182. */
  46183. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46184. /**
  46185. * Instantiate a new ray helper.
  46186. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46187. * in order to better appreciate the issue one might have.
  46188. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46189. * @param ray Defines the ray we are currently tryin to visualize
  46190. */
  46191. constructor(ray: Ray);
  46192. /**
  46193. * Shows the ray we are willing to debug.
  46194. * @param scene Defines the scene the ray needs to be rendered in
  46195. * @param color Defines the color the ray needs to be rendered in
  46196. */
  46197. show(scene: Scene, color?: Color3): void;
  46198. /**
  46199. * Hides the ray we are debugging.
  46200. */
  46201. hide(): void;
  46202. private _render;
  46203. /**
  46204. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46205. * @param mesh Defines the mesh we want the helper attached to
  46206. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46207. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46208. * @param length Defines the length of the ray
  46209. */
  46210. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46211. /**
  46212. * Detach the ray helper from the mesh it has previously been attached to.
  46213. */
  46214. detachFromMesh(): void;
  46215. private _updateToMesh;
  46216. /**
  46217. * Dispose the helper and release its associated resources.
  46218. */
  46219. dispose(): void;
  46220. }
  46221. }
  46222. declare module "babylonjs/Debug/skeletonViewer" {
  46223. import { Color3 } from "babylonjs/Maths/math.color";
  46224. import { Scene } from "babylonjs/scene";
  46225. import { Nullable } from "babylonjs/types";
  46226. import { Skeleton } from "babylonjs/Bones/skeleton";
  46227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46228. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46229. /**
  46230. * Class used to render a debug view of a given skeleton
  46231. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46232. */
  46233. export class SkeletonViewer {
  46234. /** defines the skeleton to render */
  46235. skeleton: Skeleton;
  46236. /** defines the mesh attached to the skeleton */
  46237. mesh: AbstractMesh;
  46238. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46239. autoUpdateBonesMatrices: boolean;
  46240. /** defines the rendering group id to use with the viewer */
  46241. renderingGroupId: number;
  46242. /** Gets or sets the color used to render the skeleton */
  46243. color: Color3;
  46244. private _scene;
  46245. private _debugLines;
  46246. private _debugMesh;
  46247. private _isEnabled;
  46248. private _renderFunction;
  46249. private _utilityLayer;
  46250. /**
  46251. * Returns the mesh used to render the bones
  46252. */
  46253. readonly debugMesh: Nullable<LinesMesh>;
  46254. /**
  46255. * Creates a new SkeletonViewer
  46256. * @param skeleton defines the skeleton to render
  46257. * @param mesh defines the mesh attached to the skeleton
  46258. * @param scene defines the hosting scene
  46259. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46260. * @param renderingGroupId defines the rendering group id to use with the viewer
  46261. */
  46262. constructor(
  46263. /** defines the skeleton to render */
  46264. skeleton: Skeleton,
  46265. /** defines the mesh attached to the skeleton */
  46266. mesh: AbstractMesh, scene: Scene,
  46267. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46268. autoUpdateBonesMatrices?: boolean,
  46269. /** defines the rendering group id to use with the viewer */
  46270. renderingGroupId?: number);
  46271. /** Gets or sets a boolean indicating if the viewer is enabled */
  46272. isEnabled: boolean;
  46273. private _getBonePosition;
  46274. private _getLinesForBonesWithLength;
  46275. private _getLinesForBonesNoLength;
  46276. /** Update the viewer to sync with current skeleton state */
  46277. update(): void;
  46278. /** Release associated resources */
  46279. dispose(): void;
  46280. }
  46281. }
  46282. declare module "babylonjs/Debug/index" {
  46283. export * from "babylonjs/Debug/axesViewer";
  46284. export * from "babylonjs/Debug/boneAxesViewer";
  46285. export * from "babylonjs/Debug/debugLayer";
  46286. export * from "babylonjs/Debug/physicsViewer";
  46287. export * from "babylonjs/Debug/rayHelper";
  46288. export * from "babylonjs/Debug/skeletonViewer";
  46289. }
  46290. declare module "babylonjs/Engines/nullEngine" {
  46291. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46292. import { Scene } from "babylonjs/scene";
  46293. import { Engine } from "babylonjs/Engines/engine";
  46294. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46295. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46297. import { Effect } from "babylonjs/Materials/effect";
  46298. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46299. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46300. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46301. /**
  46302. * Options to create the null engine
  46303. */
  46304. export class NullEngineOptions {
  46305. /**
  46306. * Render width (Default: 512)
  46307. */
  46308. renderWidth: number;
  46309. /**
  46310. * Render height (Default: 256)
  46311. */
  46312. renderHeight: number;
  46313. /**
  46314. * Texture size (Default: 512)
  46315. */
  46316. textureSize: number;
  46317. /**
  46318. * If delta time between frames should be constant
  46319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46320. */
  46321. deterministicLockstep: boolean;
  46322. /**
  46323. * Maximum about of steps between frames (Default: 4)
  46324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46325. */
  46326. lockstepMaxSteps: number;
  46327. }
  46328. /**
  46329. * The null engine class provides support for headless version of babylon.js.
  46330. * This can be used in server side scenario or for testing purposes
  46331. */
  46332. export class NullEngine extends Engine {
  46333. private _options;
  46334. /**
  46335. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46336. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46337. * @returns true if engine is in deterministic lock step mode
  46338. */
  46339. isDeterministicLockStep(): boolean;
  46340. /**
  46341. * Gets the max steps when engine is running in deterministic lock step
  46342. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46343. * @returns the max steps
  46344. */
  46345. getLockstepMaxSteps(): number;
  46346. /**
  46347. * Gets the current hardware scaling level.
  46348. * By default the hardware scaling level is computed from the window device ratio.
  46349. * 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.
  46350. * @returns a number indicating the current hardware scaling level
  46351. */
  46352. getHardwareScalingLevel(): number;
  46353. constructor(options?: NullEngineOptions);
  46354. /**
  46355. * Creates a vertex buffer
  46356. * @param vertices the data for the vertex buffer
  46357. * @returns the new WebGL static buffer
  46358. */
  46359. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46360. /**
  46361. * Creates a new index buffer
  46362. * @param indices defines the content of the index buffer
  46363. * @param updatable defines if the index buffer must be updatable
  46364. * @returns a new webGL buffer
  46365. */
  46366. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46367. /**
  46368. * Clear the current render buffer or the current render target (if any is set up)
  46369. * @param color defines the color to use
  46370. * @param backBuffer defines if the back buffer must be cleared
  46371. * @param depth defines if the depth buffer must be cleared
  46372. * @param stencil defines if the stencil buffer must be cleared
  46373. */
  46374. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46375. /**
  46376. * Gets the current render width
  46377. * @param useScreen defines if screen size must be used (or the current render target if any)
  46378. * @returns a number defining the current render width
  46379. */
  46380. getRenderWidth(useScreen?: boolean): number;
  46381. /**
  46382. * Gets the current render height
  46383. * @param useScreen defines if screen size must be used (or the current render target if any)
  46384. * @returns a number defining the current render height
  46385. */
  46386. getRenderHeight(useScreen?: boolean): number;
  46387. /**
  46388. * Set the WebGL's viewport
  46389. * @param viewport defines the viewport element to be used
  46390. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46391. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46392. */
  46393. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46394. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46395. /**
  46396. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46397. * @param pipelineContext defines the pipeline context to use
  46398. * @param uniformsNames defines the list of uniform names
  46399. * @returns an array of webGL uniform locations
  46400. */
  46401. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46402. /**
  46403. * Gets the lsit of active attributes for a given webGL program
  46404. * @param pipelineContext defines the pipeline context to use
  46405. * @param attributesNames defines the list of attribute names to get
  46406. * @returns an array of indices indicating the offset of each attribute
  46407. */
  46408. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46409. /**
  46410. * Binds an effect to the webGL context
  46411. * @param effect defines the effect to bind
  46412. */
  46413. bindSamplers(effect: Effect): void;
  46414. /**
  46415. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46416. * @param effect defines the effect to activate
  46417. */
  46418. enableEffect(effect: Effect): void;
  46419. /**
  46420. * Set various states to the webGL context
  46421. * @param culling defines backface culling state
  46422. * @param zOffset defines the value to apply to zOffset (0 by default)
  46423. * @param force defines if states must be applied even if cache is up to date
  46424. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46425. */
  46426. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46427. /**
  46428. * Set the value of an uniform to an array of int32
  46429. * @param uniform defines the webGL uniform location where to store the value
  46430. * @param array defines the array of int32 to store
  46431. */
  46432. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46433. /**
  46434. * Set the value of an uniform to an array of int32 (stored as vec2)
  46435. * @param uniform defines the webGL uniform location where to store the value
  46436. * @param array defines the array of int32 to store
  46437. */
  46438. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46439. /**
  46440. * Set the value of an uniform to an array of int32 (stored as vec3)
  46441. * @param uniform defines the webGL uniform location where to store the value
  46442. * @param array defines the array of int32 to store
  46443. */
  46444. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46445. /**
  46446. * Set the value of an uniform to an array of int32 (stored as vec4)
  46447. * @param uniform defines the webGL uniform location where to store the value
  46448. * @param array defines the array of int32 to store
  46449. */
  46450. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46451. /**
  46452. * Set the value of an uniform to an array of float32
  46453. * @param uniform defines the webGL uniform location where to store the value
  46454. * @param array defines the array of float32 to store
  46455. */
  46456. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46457. /**
  46458. * Set the value of an uniform to an array of float32 (stored as vec2)
  46459. * @param uniform defines the webGL uniform location where to store the value
  46460. * @param array defines the array of float32 to store
  46461. */
  46462. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46463. /**
  46464. * Set the value of an uniform to an array of float32 (stored as vec3)
  46465. * @param uniform defines the webGL uniform location where to store the value
  46466. * @param array defines the array of float32 to store
  46467. */
  46468. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46469. /**
  46470. * Set the value of an uniform to an array of float32 (stored as vec4)
  46471. * @param uniform defines the webGL uniform location where to store the value
  46472. * @param array defines the array of float32 to store
  46473. */
  46474. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46475. /**
  46476. * Set the value of an uniform to an array of number
  46477. * @param uniform defines the webGL uniform location where to store the value
  46478. * @param array defines the array of number to store
  46479. */
  46480. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46481. /**
  46482. * Set the value of an uniform to an array of number (stored as vec2)
  46483. * @param uniform defines the webGL uniform location where to store the value
  46484. * @param array defines the array of number to store
  46485. */
  46486. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46487. /**
  46488. * Set the value of an uniform to an array of number (stored as vec3)
  46489. * @param uniform defines the webGL uniform location where to store the value
  46490. * @param array defines the array of number to store
  46491. */
  46492. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46493. /**
  46494. * Set the value of an uniform to an array of number (stored as vec4)
  46495. * @param uniform defines the webGL uniform location where to store the value
  46496. * @param array defines the array of number to store
  46497. */
  46498. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46499. /**
  46500. * Set the value of an uniform to an array of float32 (stored as matrices)
  46501. * @param uniform defines the webGL uniform location where to store the value
  46502. * @param matrices defines the array of float32 to store
  46503. */
  46504. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46505. /**
  46506. * Set the value of an uniform to a matrix (3x3)
  46507. * @param uniform defines the webGL uniform location where to store the value
  46508. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46509. */
  46510. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46511. /**
  46512. * Set the value of an uniform to a matrix (2x2)
  46513. * @param uniform defines the webGL uniform location where to store the value
  46514. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46515. */
  46516. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46517. /**
  46518. * Set the value of an uniform to a number (float)
  46519. * @param uniform defines the webGL uniform location where to store the value
  46520. * @param value defines the float number to store
  46521. */
  46522. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46523. /**
  46524. * Set the value of an uniform to a vec2
  46525. * @param uniform defines the webGL uniform location where to store the value
  46526. * @param x defines the 1st component of the value
  46527. * @param y defines the 2nd component of the value
  46528. */
  46529. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46530. /**
  46531. * Set the value of an uniform to a vec3
  46532. * @param uniform defines the webGL uniform location where to store the value
  46533. * @param x defines the 1st component of the value
  46534. * @param y defines the 2nd component of the value
  46535. * @param z defines the 3rd component of the value
  46536. */
  46537. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46538. /**
  46539. * Set the value of an uniform to a boolean
  46540. * @param uniform defines the webGL uniform location where to store the value
  46541. * @param bool defines the boolean to store
  46542. */
  46543. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46544. /**
  46545. * Set the value of an uniform to a vec4
  46546. * @param uniform defines the webGL uniform location where to store the value
  46547. * @param x defines the 1st component of the value
  46548. * @param y defines the 2nd component of the value
  46549. * @param z defines the 3rd component of the value
  46550. * @param w defines the 4th component of the value
  46551. */
  46552. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46553. /**
  46554. * Sets the current alpha mode
  46555. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46556. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46558. */
  46559. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46560. /**
  46561. * Bind webGl buffers directly to the webGL context
  46562. * @param vertexBuffers defines the vertex buffer to bind
  46563. * @param indexBuffer defines the index buffer to bind
  46564. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46565. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46566. * @param effect defines the effect associated with the vertex buffer
  46567. */
  46568. bindBuffers(vertexBuffers: {
  46569. [key: string]: VertexBuffer;
  46570. }, indexBuffer: DataBuffer, effect: Effect): void;
  46571. /**
  46572. * Force the entire cache to be cleared
  46573. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46574. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46575. */
  46576. wipeCaches(bruteForce?: boolean): void;
  46577. /**
  46578. * Send a draw order
  46579. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46580. * @param indexStart defines the starting index
  46581. * @param indexCount defines the number of index to draw
  46582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46583. */
  46584. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46585. /**
  46586. * Draw a list of indexed primitives
  46587. * @param fillMode defines the primitive to use
  46588. * @param indexStart defines the starting index
  46589. * @param indexCount defines the number of index to draw
  46590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46591. */
  46592. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46593. /**
  46594. * Draw a list of unindexed primitives
  46595. * @param fillMode defines the primitive to use
  46596. * @param verticesStart defines the index of first vertex to draw
  46597. * @param verticesCount defines the count of vertices to draw
  46598. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46599. */
  46600. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46601. /** @hidden */
  46602. _createTexture(): WebGLTexture;
  46603. /** @hidden */
  46604. _releaseTexture(texture: InternalTexture): void;
  46605. /**
  46606. * Usually called from Texture.ts.
  46607. * Passed information to create a WebGLTexture
  46608. * @param urlArg defines a value which contains one of the following:
  46609. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46610. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46611. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46613. * @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)
  46614. * @param scene needed for loading to the correct scene
  46615. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46616. * @param onLoad optional callback to be called upon successful completion
  46617. * @param onError optional callback to be called upon failure
  46618. * @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
  46619. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46620. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46621. * @param forcedExtension defines the extension to use to pick the right loader
  46622. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46623. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46624. */
  46625. 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;
  46626. /**
  46627. * Creates a new render target texture
  46628. * @param size defines the size of the texture
  46629. * @param options defines the options used to create the texture
  46630. * @returns a new render target texture stored in an InternalTexture
  46631. */
  46632. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46633. /**
  46634. * Update the sampling mode of a given texture
  46635. * @param samplingMode defines the required sampling mode
  46636. * @param texture defines the texture to update
  46637. */
  46638. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46639. /**
  46640. * Binds the frame buffer to the specified texture.
  46641. * @param texture The texture to render to or null for the default canvas
  46642. * @param faceIndex The face of the texture to render to in case of cube texture
  46643. * @param requiredWidth The width of the target to render to
  46644. * @param requiredHeight The height of the target to render to
  46645. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46646. * @param depthStencilTexture The depth stencil texture to use to render
  46647. * @param lodLevel defines le lod level to bind to the frame buffer
  46648. */
  46649. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46650. /**
  46651. * Unbind the current render target texture from the webGL context
  46652. * @param texture defines the render target texture to unbind
  46653. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46654. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46655. */
  46656. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46657. /**
  46658. * Creates a dynamic vertex buffer
  46659. * @param vertices the data for the dynamic vertex buffer
  46660. * @returns the new WebGL dynamic buffer
  46661. */
  46662. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46663. /**
  46664. * Update the content of a dynamic texture
  46665. * @param texture defines the texture to update
  46666. * @param canvas defines the canvas containing the source
  46667. * @param invertY defines if data must be stored with Y axis inverted
  46668. * @param premulAlpha defines if alpha is stored as premultiplied
  46669. * @param format defines the format of the data
  46670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46671. */
  46672. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46673. /**
  46674. * Gets a boolean indicating if all created effects are ready
  46675. * @returns true if all effects are ready
  46676. */
  46677. areAllEffectsReady(): boolean;
  46678. /**
  46679. * @hidden
  46680. * Get the current error code of the webGL context
  46681. * @returns the error code
  46682. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46683. */
  46684. getError(): number;
  46685. /** @hidden */
  46686. _getUnpackAlignement(): number;
  46687. /** @hidden */
  46688. _unpackFlipY(value: boolean): void;
  46689. /**
  46690. * Update a dynamic index buffer
  46691. * @param indexBuffer defines the target index buffer
  46692. * @param indices defines the data to update
  46693. * @param offset defines the offset in the target index buffer where update should start
  46694. */
  46695. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46696. /**
  46697. * Updates a dynamic vertex buffer.
  46698. * @param vertexBuffer the vertex buffer to update
  46699. * @param vertices the data used to update the vertex buffer
  46700. * @param byteOffset the byte offset of the data (optional)
  46701. * @param byteLength the byte length of the data (optional)
  46702. */
  46703. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46704. /** @hidden */
  46705. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46706. /** @hidden */
  46707. _bindTexture(channel: number, texture: InternalTexture): void;
  46708. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46709. /**
  46710. * 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
  46711. */
  46712. releaseEffects(): void;
  46713. displayLoadingUI(): void;
  46714. hideLoadingUI(): void;
  46715. /** @hidden */
  46716. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46717. /** @hidden */
  46718. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46719. /** @hidden */
  46720. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46721. /** @hidden */
  46722. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46723. }
  46724. }
  46725. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46726. import { Nullable, int } from "babylonjs/types";
  46727. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46728. /** @hidden */
  46729. export class _OcclusionDataStorage {
  46730. /** @hidden */
  46731. occlusionInternalRetryCounter: number;
  46732. /** @hidden */
  46733. isOcclusionQueryInProgress: boolean;
  46734. /** @hidden */
  46735. isOccluded: boolean;
  46736. /** @hidden */
  46737. occlusionRetryCount: number;
  46738. /** @hidden */
  46739. occlusionType: number;
  46740. /** @hidden */
  46741. occlusionQueryAlgorithmType: number;
  46742. }
  46743. module "babylonjs/Engines/engine" {
  46744. interface Engine {
  46745. /**
  46746. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46747. * @return the new query
  46748. */
  46749. createQuery(): WebGLQuery;
  46750. /**
  46751. * Delete and release a webGL query
  46752. * @param query defines the query to delete
  46753. * @return the current engine
  46754. */
  46755. deleteQuery(query: WebGLQuery): Engine;
  46756. /**
  46757. * Check if a given query has resolved and got its value
  46758. * @param query defines the query to check
  46759. * @returns true if the query got its value
  46760. */
  46761. isQueryResultAvailable(query: WebGLQuery): boolean;
  46762. /**
  46763. * Gets the value of a given query
  46764. * @param query defines the query to check
  46765. * @returns the value of the query
  46766. */
  46767. getQueryResult(query: WebGLQuery): number;
  46768. /**
  46769. * Initiates an occlusion query
  46770. * @param algorithmType defines the algorithm to use
  46771. * @param query defines the query to use
  46772. * @returns the current engine
  46773. * @see http://doc.babylonjs.com/features/occlusionquery
  46774. */
  46775. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46776. /**
  46777. * Ends an occlusion query
  46778. * @see http://doc.babylonjs.com/features/occlusionquery
  46779. * @param algorithmType defines the algorithm to use
  46780. * @returns the current engine
  46781. */
  46782. endOcclusionQuery(algorithmType: number): Engine;
  46783. /**
  46784. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46785. * Please note that only one query can be issued at a time
  46786. * @returns a time token used to track the time span
  46787. */
  46788. startTimeQuery(): Nullable<_TimeToken>;
  46789. /**
  46790. * Ends a time query
  46791. * @param token defines the token used to measure the time span
  46792. * @returns the time spent (in ns)
  46793. */
  46794. endTimeQuery(token: _TimeToken): int;
  46795. /** @hidden */
  46796. _currentNonTimestampToken: Nullable<_TimeToken>;
  46797. /** @hidden */
  46798. _createTimeQuery(): WebGLQuery;
  46799. /** @hidden */
  46800. _deleteTimeQuery(query: WebGLQuery): void;
  46801. /** @hidden */
  46802. _getGlAlgorithmType(algorithmType: number): number;
  46803. /** @hidden */
  46804. _getTimeQueryResult(query: WebGLQuery): any;
  46805. /** @hidden */
  46806. _getTimeQueryAvailability(query: WebGLQuery): any;
  46807. }
  46808. }
  46809. module "babylonjs/Meshes/abstractMesh" {
  46810. interface AbstractMesh {
  46811. /**
  46812. * Backing filed
  46813. * @hidden
  46814. */
  46815. __occlusionDataStorage: _OcclusionDataStorage;
  46816. /**
  46817. * Access property
  46818. * @hidden
  46819. */
  46820. _occlusionDataStorage: _OcclusionDataStorage;
  46821. /**
  46822. * 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.
  46823. * The default value is -1 which means don't break the query and wait till the result
  46824. * @see http://doc.babylonjs.com/features/occlusionquery
  46825. */
  46826. occlusionRetryCount: number;
  46827. /**
  46828. * 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:
  46829. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46830. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46831. * * 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.
  46832. * @see http://doc.babylonjs.com/features/occlusionquery
  46833. */
  46834. occlusionType: number;
  46835. /**
  46836. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46837. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46838. * * 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.
  46839. * @see http://doc.babylonjs.com/features/occlusionquery
  46840. */
  46841. occlusionQueryAlgorithmType: number;
  46842. /**
  46843. * 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
  46844. * @see http://doc.babylonjs.com/features/occlusionquery
  46845. */
  46846. isOccluded: boolean;
  46847. /**
  46848. * Flag to check the progress status of the query
  46849. * @see http://doc.babylonjs.com/features/occlusionquery
  46850. */
  46851. isOcclusionQueryInProgress: boolean;
  46852. }
  46853. }
  46854. }
  46855. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46856. import { Nullable } from "babylonjs/types";
  46857. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46858. /** @hidden */
  46859. export var _forceTransformFeedbackToBundle: boolean;
  46860. module "babylonjs/Engines/engine" {
  46861. interface Engine {
  46862. /**
  46863. * Creates a webGL transform feedback object
  46864. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46865. * @returns the webGL transform feedback object
  46866. */
  46867. createTransformFeedback(): WebGLTransformFeedback;
  46868. /**
  46869. * Delete a webGL transform feedback object
  46870. * @param value defines the webGL transform feedback object to delete
  46871. */
  46872. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46873. /**
  46874. * Bind a webGL transform feedback object to the webgl context
  46875. * @param value defines the webGL transform feedback object to bind
  46876. */
  46877. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46878. /**
  46879. * Begins a transform feedback operation
  46880. * @param usePoints defines if points or triangles must be used
  46881. */
  46882. beginTransformFeedback(usePoints: boolean): void;
  46883. /**
  46884. * Ends a transform feedback operation
  46885. */
  46886. endTransformFeedback(): void;
  46887. /**
  46888. * Specify the varyings to use with transform feedback
  46889. * @param program defines the associated webGL program
  46890. * @param value defines the list of strings representing the varying names
  46891. */
  46892. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46893. /**
  46894. * Bind a webGL buffer for a transform feedback operation
  46895. * @param value defines the webGL buffer to bind
  46896. */
  46897. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46898. }
  46899. }
  46900. }
  46901. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46902. import { Scene } from "babylonjs/scene";
  46903. import { Engine } from "babylonjs/Engines/engine";
  46904. import { Texture } from "babylonjs/Materials/Textures/texture";
  46905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46906. import "babylonjs/Engines/Extensions/engine.multiRender";
  46907. /**
  46908. * Creation options of the multi render target texture.
  46909. */
  46910. export interface IMultiRenderTargetOptions {
  46911. /**
  46912. * Define if the texture needs to create mip maps after render.
  46913. */
  46914. generateMipMaps?: boolean;
  46915. /**
  46916. * Define the types of all the draw buffers we want to create
  46917. */
  46918. types?: number[];
  46919. /**
  46920. * Define the sampling modes of all the draw buffers we want to create
  46921. */
  46922. samplingModes?: number[];
  46923. /**
  46924. * Define if a depth buffer is required
  46925. */
  46926. generateDepthBuffer?: boolean;
  46927. /**
  46928. * Define if a stencil buffer is required
  46929. */
  46930. generateStencilBuffer?: boolean;
  46931. /**
  46932. * Define if a depth texture is required instead of a depth buffer
  46933. */
  46934. generateDepthTexture?: boolean;
  46935. /**
  46936. * Define the number of desired draw buffers
  46937. */
  46938. textureCount?: number;
  46939. /**
  46940. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46941. */
  46942. doNotChangeAspectRatio?: boolean;
  46943. /**
  46944. * Define the default type of the buffers we are creating
  46945. */
  46946. defaultType?: number;
  46947. }
  46948. /**
  46949. * A multi render target, like a render target provides the ability to render to a texture.
  46950. * Unlike the render target, it can render to several draw buffers in one draw.
  46951. * This is specially interesting in deferred rendering or for any effects requiring more than
  46952. * just one color from a single pass.
  46953. */
  46954. export class MultiRenderTarget extends RenderTargetTexture {
  46955. private _internalTextures;
  46956. private _textures;
  46957. private _multiRenderTargetOptions;
  46958. /**
  46959. * Get if draw buffers are currently supported by the used hardware and browser.
  46960. */
  46961. readonly isSupported: boolean;
  46962. /**
  46963. * Get the list of textures generated by the multi render target.
  46964. */
  46965. readonly textures: Texture[];
  46966. /**
  46967. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46968. */
  46969. readonly depthTexture: Texture;
  46970. /**
  46971. * Set the wrapping mode on U of all the textures we are rendering to.
  46972. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46973. */
  46974. wrapU: number;
  46975. /**
  46976. * Set the wrapping mode on V of all the textures we are rendering to.
  46977. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46978. */
  46979. wrapV: number;
  46980. /**
  46981. * Instantiate a new multi render target texture.
  46982. * A multi render target, like a render target provides the ability to render to a texture.
  46983. * Unlike the render target, it can render to several draw buffers in one draw.
  46984. * This is specially interesting in deferred rendering or for any effects requiring more than
  46985. * just one color from a single pass.
  46986. * @param name Define the name of the texture
  46987. * @param size Define the size of the buffers to render to
  46988. * @param count Define the number of target we are rendering into
  46989. * @param scene Define the scene the texture belongs to
  46990. * @param options Define the options used to create the multi render target
  46991. */
  46992. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46993. /** @hidden */
  46994. _rebuild(): void;
  46995. private _createInternalTextures;
  46996. private _createTextures;
  46997. /**
  46998. * Define the number of samples used if MSAA is enabled.
  46999. */
  47000. samples: number;
  47001. /**
  47002. * Resize all the textures in the multi render target.
  47003. * Be carrefull as it will recreate all the data in the new texture.
  47004. * @param size Define the new size
  47005. */
  47006. resize(size: any): void;
  47007. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47008. /**
  47009. * Dispose the render targets and their associated resources
  47010. */
  47011. dispose(): void;
  47012. /**
  47013. * Release all the underlying texture used as draw buffers.
  47014. */
  47015. releaseInternalTextures(): void;
  47016. }
  47017. }
  47018. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47019. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47020. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47021. import { Nullable } from "babylonjs/types";
  47022. module "babylonjs/Engines/thinEngine" {
  47023. interface ThinEngine {
  47024. /**
  47025. * Unbind a list of render target textures from the webGL context
  47026. * This is used only when drawBuffer extension or webGL2 are active
  47027. * @param textures defines the render target textures to unbind
  47028. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47029. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47030. */
  47031. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47032. /**
  47033. * Create a multi render target texture
  47034. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47035. * @param size defines the size of the texture
  47036. * @param options defines the creation options
  47037. * @returns the cube texture as an InternalTexture
  47038. */
  47039. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47040. /**
  47041. * Update the sample count for a given multiple render target texture
  47042. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47043. * @param textures defines the textures to update
  47044. * @param samples defines the sample count to set
  47045. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47046. */
  47047. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47048. }
  47049. }
  47050. }
  47051. declare module "babylonjs/Engines/Extensions/engine.views" {
  47052. import { Camera } from "babylonjs/Cameras/camera";
  47053. import { Nullable } from "babylonjs/types";
  47054. /**
  47055. * Class used to define an additional view for the engine
  47056. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47057. */
  47058. export class EngineView {
  47059. /** Defines the canvas where to render the view */
  47060. target: HTMLCanvasElement;
  47061. /** Defines an optional camera used to render the view (will use active camera else) */
  47062. camera?: Camera;
  47063. }
  47064. module "babylonjs/Engines/engine" {
  47065. interface Engine {
  47066. /**
  47067. * Gets or sets the HTML element to use for attaching events
  47068. */
  47069. inputElement: Nullable<HTMLElement>;
  47070. /**
  47071. * Gets the current engine view
  47072. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47073. */
  47074. activeView: Nullable<EngineView>;
  47075. /** Gets or sets the list of views */
  47076. views: EngineView[];
  47077. /**
  47078. * Register a new child canvas
  47079. * @param canvas defines the canvas to register
  47080. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47081. * @returns the associated view
  47082. */
  47083. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47084. /**
  47085. * Remove a registered child canvas
  47086. * @param canvas defines the canvas to remove
  47087. * @returns the current engine
  47088. */
  47089. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47090. }
  47091. }
  47092. }
  47093. declare module "babylonjs/Engines/Extensions/index" {
  47094. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47095. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47096. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47097. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47098. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47099. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47100. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47101. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47102. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47103. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47104. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47105. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47106. export * from "babylonjs/Engines/Extensions/engine.views";
  47107. }
  47108. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47109. import { Nullable } from "babylonjs/types";
  47110. /**
  47111. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47112. */
  47113. export interface CubeMapInfo {
  47114. /**
  47115. * The pixel array for the front face.
  47116. * This is stored in format, left to right, up to down format.
  47117. */
  47118. front: Nullable<ArrayBufferView>;
  47119. /**
  47120. * The pixel array for the back face.
  47121. * This is stored in format, left to right, up to down format.
  47122. */
  47123. back: Nullable<ArrayBufferView>;
  47124. /**
  47125. * The pixel array for the left face.
  47126. * This is stored in format, left to right, up to down format.
  47127. */
  47128. left: Nullable<ArrayBufferView>;
  47129. /**
  47130. * The pixel array for the right face.
  47131. * This is stored in format, left to right, up to down format.
  47132. */
  47133. right: Nullable<ArrayBufferView>;
  47134. /**
  47135. * The pixel array for the up face.
  47136. * This is stored in format, left to right, up to down format.
  47137. */
  47138. up: Nullable<ArrayBufferView>;
  47139. /**
  47140. * The pixel array for the down face.
  47141. * This is stored in format, left to right, up to down format.
  47142. */
  47143. down: Nullable<ArrayBufferView>;
  47144. /**
  47145. * The size of the cubemap stored.
  47146. *
  47147. * Each faces will be size * size pixels.
  47148. */
  47149. size: number;
  47150. /**
  47151. * The format of the texture.
  47152. *
  47153. * RGBA, RGB.
  47154. */
  47155. format: number;
  47156. /**
  47157. * The type of the texture data.
  47158. *
  47159. * UNSIGNED_INT, FLOAT.
  47160. */
  47161. type: number;
  47162. /**
  47163. * Specifies whether the texture is in gamma space.
  47164. */
  47165. gammaSpace: boolean;
  47166. }
  47167. /**
  47168. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47169. */
  47170. export class PanoramaToCubeMapTools {
  47171. private static FACE_FRONT;
  47172. private static FACE_BACK;
  47173. private static FACE_RIGHT;
  47174. private static FACE_LEFT;
  47175. private static FACE_DOWN;
  47176. private static FACE_UP;
  47177. /**
  47178. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47179. *
  47180. * @param float32Array The source data.
  47181. * @param inputWidth The width of the input panorama.
  47182. * @param inputHeight The height of the input panorama.
  47183. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47184. * @return The cubemap data
  47185. */
  47186. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47187. private static CreateCubemapTexture;
  47188. private static CalcProjectionSpherical;
  47189. }
  47190. }
  47191. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47192. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47194. import { Nullable } from "babylonjs/types";
  47195. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47196. /**
  47197. * Helper class dealing with the extraction of spherical polynomial dataArray
  47198. * from a cube map.
  47199. */
  47200. export class CubeMapToSphericalPolynomialTools {
  47201. private static FileFaces;
  47202. /**
  47203. * Converts a texture to the according Spherical Polynomial data.
  47204. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47205. *
  47206. * @param texture The texture to extract the information from.
  47207. * @return The Spherical Polynomial data.
  47208. */
  47209. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47210. /**
  47211. * Converts a cubemap to the according Spherical Polynomial data.
  47212. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47213. *
  47214. * @param cubeInfo The Cube map to extract the information from.
  47215. * @return The Spherical Polynomial data.
  47216. */
  47217. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47218. }
  47219. }
  47220. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47221. import { Nullable } from "babylonjs/types";
  47222. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47223. module "babylonjs/Materials/Textures/baseTexture" {
  47224. interface BaseTexture {
  47225. /**
  47226. * Get the polynomial representation of the texture data.
  47227. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47228. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47229. */
  47230. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47231. }
  47232. }
  47233. }
  47234. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47235. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47236. /** @hidden */
  47237. export var rgbdEncodePixelShader: {
  47238. name: string;
  47239. shader: string;
  47240. };
  47241. }
  47242. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47243. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47244. /** @hidden */
  47245. export var rgbdDecodePixelShader: {
  47246. name: string;
  47247. shader: string;
  47248. };
  47249. }
  47250. declare module "babylonjs/Misc/environmentTextureTools" {
  47251. import { Nullable } from "babylonjs/types";
  47252. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47253. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47254. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47255. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47256. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47257. import "babylonjs/Shaders/rgbdEncode.fragment";
  47258. import "babylonjs/Shaders/rgbdDecode.fragment";
  47259. /**
  47260. * Raw texture data and descriptor sufficient for WebGL texture upload
  47261. */
  47262. export interface EnvironmentTextureInfo {
  47263. /**
  47264. * Version of the environment map
  47265. */
  47266. version: number;
  47267. /**
  47268. * Width of image
  47269. */
  47270. width: number;
  47271. /**
  47272. * Irradiance information stored in the file.
  47273. */
  47274. irradiance: any;
  47275. /**
  47276. * Specular information stored in the file.
  47277. */
  47278. specular: any;
  47279. }
  47280. /**
  47281. * Defines One Image in the file. It requires only the position in the file
  47282. * as well as the length.
  47283. */
  47284. interface BufferImageData {
  47285. /**
  47286. * Length of the image data.
  47287. */
  47288. length: number;
  47289. /**
  47290. * Position of the data from the null terminator delimiting the end of the JSON.
  47291. */
  47292. position: number;
  47293. }
  47294. /**
  47295. * Defines the specular data enclosed in the file.
  47296. * This corresponds to the version 1 of the data.
  47297. */
  47298. export interface EnvironmentTextureSpecularInfoV1 {
  47299. /**
  47300. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47301. */
  47302. specularDataPosition?: number;
  47303. /**
  47304. * This contains all the images data needed to reconstruct the cubemap.
  47305. */
  47306. mipmaps: Array<BufferImageData>;
  47307. /**
  47308. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47309. */
  47310. lodGenerationScale: number;
  47311. }
  47312. /**
  47313. * Sets of helpers addressing the serialization and deserialization of environment texture
  47314. * stored in a BabylonJS env file.
  47315. * Those files are usually stored as .env files.
  47316. */
  47317. export class EnvironmentTextureTools {
  47318. /**
  47319. * Magic number identifying the env file.
  47320. */
  47321. private static _MagicBytes;
  47322. /**
  47323. * Gets the environment info from an env file.
  47324. * @param data The array buffer containing the .env bytes.
  47325. * @returns the environment file info (the json header) if successfully parsed.
  47326. */
  47327. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47328. /**
  47329. * Creates an environment texture from a loaded cube texture.
  47330. * @param texture defines the cube texture to convert in env file
  47331. * @return a promise containing the environment data if succesfull.
  47332. */
  47333. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47334. /**
  47335. * Creates a JSON representation of the spherical data.
  47336. * @param texture defines the texture containing the polynomials
  47337. * @return the JSON representation of the spherical info
  47338. */
  47339. private static _CreateEnvTextureIrradiance;
  47340. /**
  47341. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47342. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47343. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47344. * @return the views described by info providing access to the underlying buffer
  47345. */
  47346. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47347. /**
  47348. * Uploads the texture info contained in the env file to the GPU.
  47349. * @param texture defines the internal texture to upload to
  47350. * @param arrayBuffer defines the buffer cotaining the data to load
  47351. * @param info defines the texture info retrieved through the GetEnvInfo method
  47352. * @returns a promise
  47353. */
  47354. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47355. private static _OnImageReadyAsync;
  47356. /**
  47357. * Uploads the levels of image data to the GPU.
  47358. * @param texture defines the internal texture to upload to
  47359. * @param imageData defines the array buffer views of image data [mipmap][face]
  47360. * @returns a promise
  47361. */
  47362. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47363. /**
  47364. * Uploads spherical polynomials information to the texture.
  47365. * @param texture defines the texture we are trying to upload the information to
  47366. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47367. */
  47368. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47369. /** @hidden */
  47370. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47371. }
  47372. }
  47373. declare module "babylonjs/Maths/math.vertexFormat" {
  47374. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47375. /**
  47376. * Contains position and normal vectors for a vertex
  47377. */
  47378. export class PositionNormalVertex {
  47379. /** the position of the vertex (defaut: 0,0,0) */
  47380. position: Vector3;
  47381. /** the normal of the vertex (defaut: 0,1,0) */
  47382. normal: Vector3;
  47383. /**
  47384. * Creates a PositionNormalVertex
  47385. * @param position the position of the vertex (defaut: 0,0,0)
  47386. * @param normal the normal of the vertex (defaut: 0,1,0)
  47387. */
  47388. constructor(
  47389. /** the position of the vertex (defaut: 0,0,0) */
  47390. position?: Vector3,
  47391. /** the normal of the vertex (defaut: 0,1,0) */
  47392. normal?: Vector3);
  47393. /**
  47394. * Clones the PositionNormalVertex
  47395. * @returns the cloned PositionNormalVertex
  47396. */
  47397. clone(): PositionNormalVertex;
  47398. }
  47399. /**
  47400. * Contains position, normal and uv vectors for a vertex
  47401. */
  47402. export class PositionNormalTextureVertex {
  47403. /** the position of the vertex (defaut: 0,0,0) */
  47404. position: Vector3;
  47405. /** the normal of the vertex (defaut: 0,1,0) */
  47406. normal: Vector3;
  47407. /** the uv of the vertex (default: 0,0) */
  47408. uv: Vector2;
  47409. /**
  47410. * Creates a PositionNormalTextureVertex
  47411. * @param position the position of the vertex (defaut: 0,0,0)
  47412. * @param normal the normal of the vertex (defaut: 0,1,0)
  47413. * @param uv the uv of the vertex (default: 0,0)
  47414. */
  47415. constructor(
  47416. /** the position of the vertex (defaut: 0,0,0) */
  47417. position?: Vector3,
  47418. /** the normal of the vertex (defaut: 0,1,0) */
  47419. normal?: Vector3,
  47420. /** the uv of the vertex (default: 0,0) */
  47421. uv?: Vector2);
  47422. /**
  47423. * Clones the PositionNormalTextureVertex
  47424. * @returns the cloned PositionNormalTextureVertex
  47425. */
  47426. clone(): PositionNormalTextureVertex;
  47427. }
  47428. }
  47429. declare module "babylonjs/Maths/math" {
  47430. export * from "babylonjs/Maths/math.axis";
  47431. export * from "babylonjs/Maths/math.color";
  47432. export * from "babylonjs/Maths/math.constants";
  47433. export * from "babylonjs/Maths/math.frustum";
  47434. export * from "babylonjs/Maths/math.path";
  47435. export * from "babylonjs/Maths/math.plane";
  47436. export * from "babylonjs/Maths/math.size";
  47437. export * from "babylonjs/Maths/math.vector";
  47438. export * from "babylonjs/Maths/math.vertexFormat";
  47439. export * from "babylonjs/Maths/math.viewport";
  47440. }
  47441. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47442. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47443. /** @hidden */
  47444. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47445. private _genericAttributeLocation;
  47446. private _varyingLocationCount;
  47447. private _varyingLocationMap;
  47448. private _replacements;
  47449. private _textureCount;
  47450. private _uniforms;
  47451. lineProcessor(line: string): string;
  47452. attributeProcessor(attribute: string): string;
  47453. varyingProcessor(varying: string, isFragment: boolean): string;
  47454. uniformProcessor(uniform: string): string;
  47455. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47456. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47457. }
  47458. }
  47459. declare module "babylonjs/Engines/nativeEngine" {
  47460. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47461. import { Engine } from "babylonjs/Engines/engine";
  47462. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47465. import { Effect } from "babylonjs/Materials/effect";
  47466. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47467. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47468. import { IColor4Like } from "babylonjs/Maths/math.like";
  47469. import { Scene } from "babylonjs/scene";
  47470. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47471. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47472. /**
  47473. * Container for accessors for natively-stored mesh data buffers.
  47474. */
  47475. class NativeDataBuffer extends DataBuffer {
  47476. /**
  47477. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47478. */
  47479. nativeIndexBuffer?: any;
  47480. /**
  47481. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47482. */
  47483. nativeVertexBuffer?: any;
  47484. }
  47485. /** @hidden */
  47486. class NativeTexture extends InternalTexture {
  47487. getInternalTexture(): InternalTexture;
  47488. getViewCount(): number;
  47489. }
  47490. /** @hidden */
  47491. export class NativeEngine extends Engine {
  47492. private readonly _native;
  47493. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47494. private readonly INVALID_HANDLE;
  47495. getHardwareScalingLevel(): number;
  47496. constructor();
  47497. /**
  47498. * Can be used to override the current requestAnimationFrame requester.
  47499. * @hidden
  47500. */
  47501. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47502. /**
  47503. * Override default engine behavior.
  47504. * @param color
  47505. * @param backBuffer
  47506. * @param depth
  47507. * @param stencil
  47508. */
  47509. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47510. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47511. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47512. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47513. recordVertexArrayObject(vertexBuffers: {
  47514. [key: string]: VertexBuffer;
  47515. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47516. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47517. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47518. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47519. /**
  47520. * Draw a list of indexed primitives
  47521. * @param fillMode defines the primitive to use
  47522. * @param indexStart defines the starting index
  47523. * @param indexCount defines the number of index to draw
  47524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47525. */
  47526. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47527. /**
  47528. * Draw a list of unindexed primitives
  47529. * @param fillMode defines the primitive to use
  47530. * @param verticesStart defines the index of first vertex to draw
  47531. * @param verticesCount defines the count of vertices to draw
  47532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47533. */
  47534. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47535. createPipelineContext(): IPipelineContext;
  47536. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47537. /** @hidden */
  47538. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47539. /** @hidden */
  47540. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47541. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47542. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47543. protected _setProgram(program: WebGLProgram): void;
  47544. _releaseEffect(effect: Effect): void;
  47545. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47546. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47547. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47548. bindSamplers(effect: Effect): void;
  47549. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47550. getRenderWidth(useScreen?: boolean): number;
  47551. getRenderHeight(useScreen?: boolean): number;
  47552. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47553. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47554. /**
  47555. * Set the z offset to apply to current rendering
  47556. * @param value defines the offset to apply
  47557. */
  47558. setZOffset(value: number): void;
  47559. /**
  47560. * Gets the current value of the zOffset
  47561. * @returns the current zOffset state
  47562. */
  47563. getZOffset(): number;
  47564. /**
  47565. * Enable or disable depth buffering
  47566. * @param enable defines the state to set
  47567. */
  47568. setDepthBuffer(enable: boolean): void;
  47569. /**
  47570. * Gets a boolean indicating if depth writing is enabled
  47571. * @returns the current depth writing state
  47572. */
  47573. getDepthWrite(): boolean;
  47574. /**
  47575. * Enable or disable depth writing
  47576. * @param enable defines the state to set
  47577. */
  47578. setDepthWrite(enable: boolean): void;
  47579. /**
  47580. * Enable or disable color writing
  47581. * @param enable defines the state to set
  47582. */
  47583. setColorWrite(enable: boolean): void;
  47584. /**
  47585. * Gets a boolean indicating if color writing is enabled
  47586. * @returns the current color writing state
  47587. */
  47588. getColorWrite(): boolean;
  47589. /**
  47590. * Sets alpha constants used by some alpha blending modes
  47591. * @param r defines the red component
  47592. * @param g defines the green component
  47593. * @param b defines the blue component
  47594. * @param a defines the alpha component
  47595. */
  47596. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47597. /**
  47598. * Sets the current alpha mode
  47599. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47600. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47601. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47602. */
  47603. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47604. /**
  47605. * Gets the current alpha mode
  47606. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47607. * @returns the current alpha mode
  47608. */
  47609. getAlphaMode(): number;
  47610. setInt(uniform: WebGLUniformLocation, int: number): void;
  47611. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47612. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47613. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47614. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47615. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47616. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47617. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47618. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47619. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47620. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47621. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47622. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47623. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47624. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47625. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47626. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47627. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47628. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47629. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47630. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47631. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47632. wipeCaches(bruteForce?: boolean): void;
  47633. _createTexture(): WebGLTexture;
  47634. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47635. /**
  47636. * Usually called from BABYLON.Texture.ts.
  47637. * Passed information to create a WebGLTexture
  47638. * @param urlArg defines a value which contains one of the following:
  47639. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47640. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47641. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47642. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47643. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47644. * @param scene needed for loading to the correct scene
  47645. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47646. * @param onLoad optional callback to be called upon successful completion
  47647. * @param onError optional callback to be called upon failure
  47648. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47649. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47650. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47651. * @param forcedExtension defines the extension to use to pick the right loader
  47652. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47653. */
  47654. 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;
  47655. /**
  47656. * Creates a cube texture
  47657. * @param rootUrl defines the url where the files to load is located
  47658. * @param scene defines the current scene
  47659. * @param files defines the list of files to load (1 per face)
  47660. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47661. * @param onLoad defines an optional callback raised when the texture is loaded
  47662. * @param onError defines an optional callback raised if there is an issue to load the texture
  47663. * @param format defines the format of the data
  47664. * @param forcedExtension defines the extension to use to pick the right loader
  47665. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47666. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47667. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47668. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47669. * @returns the cube texture as an InternalTexture
  47670. */
  47671. 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;
  47672. private _getSamplingFilter;
  47673. private static _GetNativeTextureFormat;
  47674. createRenderTargetTexture(size: number | {
  47675. width: number;
  47676. height: number;
  47677. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47678. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47679. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47680. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47681. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47682. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47683. /**
  47684. * Updates a dynamic vertex buffer.
  47685. * @param vertexBuffer the vertex buffer to update
  47686. * @param data the data used to update the vertex buffer
  47687. * @param byteOffset the byte offset of the data (optional)
  47688. * @param byteLength the byte length of the data (optional)
  47689. */
  47690. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47691. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47692. private _updateAnisotropicLevel;
  47693. private _getAddressMode;
  47694. /** @hidden */
  47695. _bindTexture(channel: number, texture: InternalTexture): void;
  47696. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47697. releaseEffects(): void;
  47698. /** @hidden */
  47699. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47700. /** @hidden */
  47701. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47702. /** @hidden */
  47703. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47704. /** @hidden */
  47705. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47706. }
  47707. }
  47708. declare module "babylonjs/Engines/index" {
  47709. export * from "babylonjs/Engines/constants";
  47710. export * from "babylonjs/Engines/engineCapabilities";
  47711. export * from "babylonjs/Engines/instancingAttributeInfo";
  47712. export * from "babylonjs/Engines/thinEngine";
  47713. export * from "babylonjs/Engines/engine";
  47714. export * from "babylonjs/Engines/engineStore";
  47715. export * from "babylonjs/Engines/nullEngine";
  47716. export * from "babylonjs/Engines/Extensions/index";
  47717. export * from "babylonjs/Engines/IPipelineContext";
  47718. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47719. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47720. export * from "babylonjs/Engines/nativeEngine";
  47721. }
  47722. declare module "babylonjs/Events/clipboardEvents" {
  47723. /**
  47724. * Gather the list of clipboard event types as constants.
  47725. */
  47726. export class ClipboardEventTypes {
  47727. /**
  47728. * The clipboard event is fired when a copy command is active (pressed).
  47729. */
  47730. static readonly COPY: number;
  47731. /**
  47732. * The clipboard event is fired when a cut command is active (pressed).
  47733. */
  47734. static readonly CUT: number;
  47735. /**
  47736. * The clipboard event is fired when a paste command is active (pressed).
  47737. */
  47738. static readonly PASTE: number;
  47739. }
  47740. /**
  47741. * This class is used to store clipboard related info for the onClipboardObservable event.
  47742. */
  47743. export class ClipboardInfo {
  47744. /**
  47745. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47746. */
  47747. type: number;
  47748. /**
  47749. * Defines the related dom event
  47750. */
  47751. event: ClipboardEvent;
  47752. /**
  47753. *Creates an instance of ClipboardInfo.
  47754. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47755. * @param event Defines the related dom event
  47756. */
  47757. constructor(
  47758. /**
  47759. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47760. */
  47761. type: number,
  47762. /**
  47763. * Defines the related dom event
  47764. */
  47765. event: ClipboardEvent);
  47766. /**
  47767. * Get the clipboard event's type from the keycode.
  47768. * @param keyCode Defines the keyCode for the current keyboard event.
  47769. * @return {number}
  47770. */
  47771. static GetTypeFromCharacter(keyCode: number): number;
  47772. }
  47773. }
  47774. declare module "babylonjs/Events/index" {
  47775. export * from "babylonjs/Events/keyboardEvents";
  47776. export * from "babylonjs/Events/pointerEvents";
  47777. export * from "babylonjs/Events/clipboardEvents";
  47778. }
  47779. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47780. import { Scene } from "babylonjs/scene";
  47781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47782. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47783. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47784. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47785. /**
  47786. * Google Daydream controller
  47787. */
  47788. export class DaydreamController extends WebVRController {
  47789. /**
  47790. * Base Url for the controller model.
  47791. */
  47792. static MODEL_BASE_URL: string;
  47793. /**
  47794. * File name for the controller model.
  47795. */
  47796. static MODEL_FILENAME: string;
  47797. /**
  47798. * Gamepad Id prefix used to identify Daydream Controller.
  47799. */
  47800. static readonly GAMEPAD_ID_PREFIX: string;
  47801. /**
  47802. * Creates a new DaydreamController from a gamepad
  47803. * @param vrGamepad the gamepad that the controller should be created from
  47804. */
  47805. constructor(vrGamepad: any);
  47806. /**
  47807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47808. * @param scene scene in which to add meshes
  47809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47810. */
  47811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47812. /**
  47813. * Called once for each button that changed state since the last frame
  47814. * @param buttonIdx Which button index changed
  47815. * @param state New state of the button
  47816. * @param changes Which properties on the state changed since last frame
  47817. */
  47818. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47819. }
  47820. }
  47821. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47822. import { Scene } from "babylonjs/scene";
  47823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47824. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47825. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47826. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47827. /**
  47828. * Gear VR Controller
  47829. */
  47830. export class GearVRController extends WebVRController {
  47831. /**
  47832. * Base Url for the controller model.
  47833. */
  47834. static MODEL_BASE_URL: string;
  47835. /**
  47836. * File name for the controller model.
  47837. */
  47838. static MODEL_FILENAME: string;
  47839. /**
  47840. * Gamepad Id prefix used to identify this controller.
  47841. */
  47842. static readonly GAMEPAD_ID_PREFIX: string;
  47843. private readonly _buttonIndexToObservableNameMap;
  47844. /**
  47845. * Creates a new GearVRController from a gamepad
  47846. * @param vrGamepad the gamepad that the controller should be created from
  47847. */
  47848. constructor(vrGamepad: any);
  47849. /**
  47850. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47851. * @param scene scene in which to add meshes
  47852. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47853. */
  47854. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47855. /**
  47856. * Called once for each button that changed state since the last frame
  47857. * @param buttonIdx Which button index changed
  47858. * @param state New state of the button
  47859. * @param changes Which properties on the state changed since last frame
  47860. */
  47861. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47862. }
  47863. }
  47864. declare module "babylonjs/Gamepads/Controllers/index" {
  47865. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47866. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47867. export * from "babylonjs/Gamepads/Controllers/genericController";
  47868. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47869. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47870. export * from "babylonjs/Gamepads/Controllers/viveController";
  47871. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47872. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47873. }
  47874. declare module "babylonjs/Gamepads/index" {
  47875. export * from "babylonjs/Gamepads/Controllers/index";
  47876. export * from "babylonjs/Gamepads/gamepad";
  47877. export * from "babylonjs/Gamepads/gamepadManager";
  47878. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47879. export * from "babylonjs/Gamepads/xboxGamepad";
  47880. export * from "babylonjs/Gamepads/dualShockGamepad";
  47881. }
  47882. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47883. import { Scene } from "babylonjs/scene";
  47884. import { Vector4 } from "babylonjs/Maths/math.vector";
  47885. import { Color4 } from "babylonjs/Maths/math.color";
  47886. import { Mesh } from "babylonjs/Meshes/mesh";
  47887. import { Nullable } from "babylonjs/types";
  47888. /**
  47889. * Class containing static functions to help procedurally build meshes
  47890. */
  47891. export class PolyhedronBuilder {
  47892. /**
  47893. * Creates a polyhedron mesh
  47894. * * 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
  47895. * * The parameter `size` (positive float, default 1) sets the polygon size
  47896. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47897. * * 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`
  47898. * * 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
  47899. * * 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)`)
  47900. * * 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
  47901. * * 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
  47902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47905. * @param name defines the name of the mesh
  47906. * @param options defines the options used to create the mesh
  47907. * @param scene defines the hosting scene
  47908. * @returns the polyhedron mesh
  47909. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47910. */
  47911. static CreatePolyhedron(name: string, options: {
  47912. type?: number;
  47913. size?: number;
  47914. sizeX?: number;
  47915. sizeY?: number;
  47916. sizeZ?: number;
  47917. custom?: any;
  47918. faceUV?: Vector4[];
  47919. faceColors?: Color4[];
  47920. flat?: boolean;
  47921. updatable?: boolean;
  47922. sideOrientation?: number;
  47923. frontUVs?: Vector4;
  47924. backUVs?: Vector4;
  47925. }, scene?: Nullable<Scene>): Mesh;
  47926. }
  47927. }
  47928. declare module "babylonjs/Gizmos/scaleGizmo" {
  47929. import { Observable } from "babylonjs/Misc/observable";
  47930. import { Nullable } from "babylonjs/types";
  47931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47933. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47935. /**
  47936. * Gizmo that enables scaling a mesh along 3 axis
  47937. */
  47938. export class ScaleGizmo extends Gizmo {
  47939. /**
  47940. * Internal gizmo used for interactions on the x axis
  47941. */
  47942. xGizmo: AxisScaleGizmo;
  47943. /**
  47944. * Internal gizmo used for interactions on the y axis
  47945. */
  47946. yGizmo: AxisScaleGizmo;
  47947. /**
  47948. * Internal gizmo used for interactions on the z axis
  47949. */
  47950. zGizmo: AxisScaleGizmo;
  47951. /**
  47952. * Internal gizmo used to scale all axis equally
  47953. */
  47954. uniformScaleGizmo: AxisScaleGizmo;
  47955. private _meshAttached;
  47956. private _updateGizmoRotationToMatchAttachedMesh;
  47957. private _snapDistance;
  47958. private _scaleRatio;
  47959. private _uniformScalingMesh;
  47960. private _octahedron;
  47961. private _sensitivity;
  47962. /** Fires an event when any of it's sub gizmos are dragged */
  47963. onDragStartObservable: Observable<unknown>;
  47964. /** Fires an event when any of it's sub gizmos are released from dragging */
  47965. onDragEndObservable: Observable<unknown>;
  47966. attachedMesh: Nullable<AbstractMesh>;
  47967. /**
  47968. * Creates a ScaleGizmo
  47969. * @param gizmoLayer The utility layer the gizmo will be added to
  47970. */
  47971. constructor(gizmoLayer?: UtilityLayerRenderer);
  47972. updateGizmoRotationToMatchAttachedMesh: boolean;
  47973. /**
  47974. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47975. */
  47976. snapDistance: number;
  47977. /**
  47978. * Ratio for the scale of the gizmo (Default: 1)
  47979. */
  47980. scaleRatio: number;
  47981. /**
  47982. * Sensitivity factor for dragging (Default: 1)
  47983. */
  47984. sensitivity: number;
  47985. /**
  47986. * Disposes of the gizmo
  47987. */
  47988. dispose(): void;
  47989. }
  47990. }
  47991. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47992. import { Observable } from "babylonjs/Misc/observable";
  47993. import { Nullable } from "babylonjs/types";
  47994. import { Vector3 } from "babylonjs/Maths/math.vector";
  47995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47996. import { Mesh } from "babylonjs/Meshes/mesh";
  47997. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47999. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48000. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48001. import { Color3 } from "babylonjs/Maths/math.color";
  48002. /**
  48003. * Single axis scale gizmo
  48004. */
  48005. export class AxisScaleGizmo extends Gizmo {
  48006. /**
  48007. * Drag behavior responsible for the gizmos dragging interactions
  48008. */
  48009. dragBehavior: PointerDragBehavior;
  48010. private _pointerObserver;
  48011. /**
  48012. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48013. */
  48014. snapDistance: number;
  48015. /**
  48016. * Event that fires each time the gizmo snaps to a new location.
  48017. * * snapDistance is the the change in distance
  48018. */
  48019. onSnapObservable: Observable<{
  48020. snapDistance: number;
  48021. }>;
  48022. /**
  48023. * If the scaling operation should be done on all axis (default: false)
  48024. */
  48025. uniformScaling: boolean;
  48026. /**
  48027. * Custom sensitivity value for the drag strength
  48028. */
  48029. sensitivity: number;
  48030. private _isEnabled;
  48031. private _parent;
  48032. private _arrow;
  48033. private _coloredMaterial;
  48034. private _hoverMaterial;
  48035. /**
  48036. * Creates an AxisScaleGizmo
  48037. * @param gizmoLayer The utility layer the gizmo will be added to
  48038. * @param dragAxis The axis which the gizmo will be able to scale on
  48039. * @param color The color of the gizmo
  48040. */
  48041. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48042. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48043. /**
  48044. * If the gizmo is enabled
  48045. */
  48046. isEnabled: boolean;
  48047. /**
  48048. * Disposes of the gizmo
  48049. */
  48050. dispose(): void;
  48051. /**
  48052. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48053. * @param mesh The mesh to replace the default mesh of the gizmo
  48054. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48055. */
  48056. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48057. }
  48058. }
  48059. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48060. import { Observable } from "babylonjs/Misc/observable";
  48061. import { Nullable } from "babylonjs/types";
  48062. import { Vector3 } from "babylonjs/Maths/math.vector";
  48063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48064. import { Mesh } from "babylonjs/Meshes/mesh";
  48065. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48066. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48067. import { Color3 } from "babylonjs/Maths/math.color";
  48068. import "babylonjs/Meshes/Builders/boxBuilder";
  48069. /**
  48070. * Bounding box gizmo
  48071. */
  48072. export class BoundingBoxGizmo extends Gizmo {
  48073. private _lineBoundingBox;
  48074. private _rotateSpheresParent;
  48075. private _scaleBoxesParent;
  48076. private _boundingDimensions;
  48077. private _renderObserver;
  48078. private _pointerObserver;
  48079. private _scaleDragSpeed;
  48080. private _tmpQuaternion;
  48081. private _tmpVector;
  48082. private _tmpRotationMatrix;
  48083. /**
  48084. * 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)
  48085. */
  48086. ignoreChildren: boolean;
  48087. /**
  48088. * 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)
  48089. */
  48090. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48091. /**
  48092. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48093. */
  48094. rotationSphereSize: number;
  48095. /**
  48096. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48097. */
  48098. scaleBoxSize: number;
  48099. /**
  48100. * 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)
  48101. */
  48102. fixedDragMeshScreenSize: boolean;
  48103. /**
  48104. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48105. */
  48106. fixedDragMeshScreenSizeDistanceFactor: number;
  48107. /**
  48108. * Fired when a rotation sphere or scale box is dragged
  48109. */
  48110. onDragStartObservable: Observable<{}>;
  48111. /**
  48112. * Fired when a scale box is dragged
  48113. */
  48114. onScaleBoxDragObservable: Observable<{}>;
  48115. /**
  48116. * Fired when a scale box drag is ended
  48117. */
  48118. onScaleBoxDragEndObservable: Observable<{}>;
  48119. /**
  48120. * Fired when a rotation sphere is dragged
  48121. */
  48122. onRotationSphereDragObservable: Observable<{}>;
  48123. /**
  48124. * Fired when a rotation sphere drag is ended
  48125. */
  48126. onRotationSphereDragEndObservable: Observable<{}>;
  48127. /**
  48128. * 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)
  48129. */
  48130. scalePivot: Nullable<Vector3>;
  48131. /**
  48132. * Mesh used as a pivot to rotate the attached mesh
  48133. */
  48134. private _anchorMesh;
  48135. private _existingMeshScale;
  48136. private _dragMesh;
  48137. private pointerDragBehavior;
  48138. private coloredMaterial;
  48139. private hoverColoredMaterial;
  48140. /**
  48141. * Sets the color of the bounding box gizmo
  48142. * @param color the color to set
  48143. */
  48144. setColor(color: Color3): void;
  48145. /**
  48146. * Creates an BoundingBoxGizmo
  48147. * @param gizmoLayer The utility layer the gizmo will be added to
  48148. * @param color The color of the gizmo
  48149. */
  48150. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48151. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48152. private _selectNode;
  48153. /**
  48154. * Updates the bounding box information for the Gizmo
  48155. */
  48156. updateBoundingBox(): void;
  48157. private _updateRotationSpheres;
  48158. private _updateScaleBoxes;
  48159. /**
  48160. * Enables rotation on the specified axis and disables rotation on the others
  48161. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48162. */
  48163. setEnabledRotationAxis(axis: string): void;
  48164. /**
  48165. * Enables/disables scaling
  48166. * @param enable if scaling should be enabled
  48167. */
  48168. setEnabledScaling(enable: boolean): void;
  48169. private _updateDummy;
  48170. /**
  48171. * Enables a pointer drag behavior on the bounding box of the gizmo
  48172. */
  48173. enableDragBehavior(): void;
  48174. /**
  48175. * Disposes of the gizmo
  48176. */
  48177. dispose(): void;
  48178. /**
  48179. * 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)
  48180. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48181. * @returns the bounding box mesh with the passed in mesh as a child
  48182. */
  48183. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48184. /**
  48185. * CustomMeshes are not supported by this gizmo
  48186. * @param mesh The mesh to replace the default mesh of the gizmo
  48187. */
  48188. setCustomMesh(mesh: Mesh): void;
  48189. }
  48190. }
  48191. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48192. import { Observable } from "babylonjs/Misc/observable";
  48193. import { Nullable } from "babylonjs/types";
  48194. import { Vector3 } from "babylonjs/Maths/math.vector";
  48195. import { Color3 } from "babylonjs/Maths/math.color";
  48196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48197. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48198. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48200. import "babylonjs/Meshes/Builders/linesBuilder";
  48201. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48202. /**
  48203. * Single plane rotation gizmo
  48204. */
  48205. export class PlaneRotationGizmo extends Gizmo {
  48206. /**
  48207. * Drag behavior responsible for the gizmos dragging interactions
  48208. */
  48209. dragBehavior: PointerDragBehavior;
  48210. private _pointerObserver;
  48211. /**
  48212. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48213. */
  48214. snapDistance: number;
  48215. /**
  48216. * Event that fires each time the gizmo snaps to a new location.
  48217. * * snapDistance is the the change in distance
  48218. */
  48219. onSnapObservable: Observable<{
  48220. snapDistance: number;
  48221. }>;
  48222. private _isEnabled;
  48223. private _parent;
  48224. /**
  48225. * Creates a PlaneRotationGizmo
  48226. * @param gizmoLayer The utility layer the gizmo will be added to
  48227. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48228. * @param color The color of the gizmo
  48229. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48230. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48231. */
  48232. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48233. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48234. /**
  48235. * If the gizmo is enabled
  48236. */
  48237. isEnabled: boolean;
  48238. /**
  48239. * Disposes of the gizmo
  48240. */
  48241. dispose(): void;
  48242. }
  48243. }
  48244. declare module "babylonjs/Gizmos/rotationGizmo" {
  48245. import { Observable } from "babylonjs/Misc/observable";
  48246. import { Nullable } from "babylonjs/types";
  48247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48248. import { Mesh } from "babylonjs/Meshes/mesh";
  48249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48250. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48252. /**
  48253. * Gizmo that enables rotating a mesh along 3 axis
  48254. */
  48255. export class RotationGizmo extends Gizmo {
  48256. /**
  48257. * Internal gizmo used for interactions on the x axis
  48258. */
  48259. xGizmo: PlaneRotationGizmo;
  48260. /**
  48261. * Internal gizmo used for interactions on the y axis
  48262. */
  48263. yGizmo: PlaneRotationGizmo;
  48264. /**
  48265. * Internal gizmo used for interactions on the z axis
  48266. */
  48267. zGizmo: PlaneRotationGizmo;
  48268. /** Fires an event when any of it's sub gizmos are dragged */
  48269. onDragStartObservable: Observable<unknown>;
  48270. /** Fires an event when any of it's sub gizmos are released from dragging */
  48271. onDragEndObservable: Observable<unknown>;
  48272. private _meshAttached;
  48273. attachedMesh: Nullable<AbstractMesh>;
  48274. /**
  48275. * Creates a RotationGizmo
  48276. * @param gizmoLayer The utility layer the gizmo will be added to
  48277. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48278. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48279. */
  48280. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48281. updateGizmoRotationToMatchAttachedMesh: boolean;
  48282. /**
  48283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48284. */
  48285. snapDistance: number;
  48286. /**
  48287. * Ratio for the scale of the gizmo (Default: 1)
  48288. */
  48289. scaleRatio: number;
  48290. /**
  48291. * Disposes of the gizmo
  48292. */
  48293. dispose(): void;
  48294. /**
  48295. * CustomMeshes are not supported by this gizmo
  48296. * @param mesh The mesh to replace the default mesh of the gizmo
  48297. */
  48298. setCustomMesh(mesh: Mesh): void;
  48299. }
  48300. }
  48301. declare module "babylonjs/Gizmos/gizmoManager" {
  48302. import { Observable } from "babylonjs/Misc/observable";
  48303. import { Nullable } from "babylonjs/types";
  48304. import { Scene, IDisposable } from "babylonjs/scene";
  48305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48306. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48307. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48308. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48309. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48310. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48311. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48312. /**
  48313. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48314. */
  48315. export class GizmoManager implements IDisposable {
  48316. private scene;
  48317. /**
  48318. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48319. */
  48320. gizmos: {
  48321. positionGizmo: Nullable<PositionGizmo>;
  48322. rotationGizmo: Nullable<RotationGizmo>;
  48323. scaleGizmo: Nullable<ScaleGizmo>;
  48324. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48325. };
  48326. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48327. clearGizmoOnEmptyPointerEvent: boolean;
  48328. /** Fires an event when the manager is attached to a mesh */
  48329. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48330. private _gizmosEnabled;
  48331. private _pointerObserver;
  48332. private _attachedMesh;
  48333. private _boundingBoxColor;
  48334. private _defaultUtilityLayer;
  48335. private _defaultKeepDepthUtilityLayer;
  48336. /**
  48337. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48338. */
  48339. boundingBoxDragBehavior: SixDofDragBehavior;
  48340. /**
  48341. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48342. */
  48343. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48344. /**
  48345. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48346. */
  48347. usePointerToAttachGizmos: boolean;
  48348. /**
  48349. * Utility layer that the bounding box gizmo belongs to
  48350. */
  48351. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48352. /**
  48353. * Utility layer that all gizmos besides bounding box belong to
  48354. */
  48355. readonly utilityLayer: UtilityLayerRenderer;
  48356. /**
  48357. * Instatiates a gizmo manager
  48358. * @param scene the scene to overlay the gizmos on top of
  48359. */
  48360. constructor(scene: Scene);
  48361. /**
  48362. * Attaches a set of gizmos to the specified mesh
  48363. * @param mesh The mesh the gizmo's should be attached to
  48364. */
  48365. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48366. /**
  48367. * If the position gizmo is enabled
  48368. */
  48369. positionGizmoEnabled: boolean;
  48370. /**
  48371. * If the rotation gizmo is enabled
  48372. */
  48373. rotationGizmoEnabled: boolean;
  48374. /**
  48375. * If the scale gizmo is enabled
  48376. */
  48377. scaleGizmoEnabled: boolean;
  48378. /**
  48379. * If the boundingBox gizmo is enabled
  48380. */
  48381. boundingBoxGizmoEnabled: boolean;
  48382. /**
  48383. * Disposes of the gizmo manager
  48384. */
  48385. dispose(): void;
  48386. }
  48387. }
  48388. declare module "babylonjs/Lights/directionalLight" {
  48389. import { Camera } from "babylonjs/Cameras/camera";
  48390. import { Scene } from "babylonjs/scene";
  48391. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48393. import { Light } from "babylonjs/Lights/light";
  48394. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48395. import { Effect } from "babylonjs/Materials/effect";
  48396. /**
  48397. * A directional light is defined by a direction (what a surprise!).
  48398. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48399. * 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.
  48400. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48401. */
  48402. export class DirectionalLight extends ShadowLight {
  48403. private _shadowFrustumSize;
  48404. /**
  48405. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48406. */
  48407. /**
  48408. * Specifies a fix frustum size for the shadow generation.
  48409. */
  48410. shadowFrustumSize: number;
  48411. private _shadowOrthoScale;
  48412. /**
  48413. * Gets the shadow projection scale against the optimal computed one.
  48414. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48415. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48416. */
  48417. /**
  48418. * Sets the shadow projection scale against the optimal computed one.
  48419. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48420. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48421. */
  48422. shadowOrthoScale: number;
  48423. /**
  48424. * Automatically compute the projection matrix to best fit (including all the casters)
  48425. * on each frame.
  48426. */
  48427. autoUpdateExtends: boolean;
  48428. private _orthoLeft;
  48429. private _orthoRight;
  48430. private _orthoTop;
  48431. private _orthoBottom;
  48432. /**
  48433. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48434. * The directional light is emitted from everywhere in the given direction.
  48435. * It can cast shadows.
  48436. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48437. * @param name The friendly name of the light
  48438. * @param direction The direction of the light
  48439. * @param scene The scene the light belongs to
  48440. */
  48441. constructor(name: string, direction: Vector3, scene: Scene);
  48442. /**
  48443. * Returns the string "DirectionalLight".
  48444. * @return The class name
  48445. */
  48446. getClassName(): string;
  48447. /**
  48448. * Returns the integer 1.
  48449. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48450. */
  48451. getTypeID(): number;
  48452. /**
  48453. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48454. * Returns the DirectionalLight Shadow projection matrix.
  48455. */
  48456. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48457. /**
  48458. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48459. * Returns the DirectionalLight Shadow projection matrix.
  48460. */
  48461. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48462. /**
  48463. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48464. * Returns the DirectionalLight Shadow projection matrix.
  48465. */
  48466. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48467. protected _buildUniformLayout(): void;
  48468. /**
  48469. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48470. * @param effect The effect to update
  48471. * @param lightIndex The index of the light in the effect to update
  48472. * @returns The directional light
  48473. */
  48474. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48475. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48476. /**
  48477. * Gets the minZ used for shadow according to both the scene and the light.
  48478. *
  48479. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48480. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48481. * @param activeCamera The camera we are returning the min for
  48482. * @returns the depth min z
  48483. */
  48484. getDepthMinZ(activeCamera: Camera): number;
  48485. /**
  48486. * Gets the maxZ used for shadow according to both the scene and the light.
  48487. *
  48488. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48489. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48490. * @param activeCamera The camera we are returning the max for
  48491. * @returns the depth max z
  48492. */
  48493. getDepthMaxZ(activeCamera: Camera): number;
  48494. /**
  48495. * Prepares the list of defines specific to the light type.
  48496. * @param defines the list of defines
  48497. * @param lightIndex defines the index of the light for the effect
  48498. */
  48499. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48500. }
  48501. }
  48502. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48503. import { Mesh } from "babylonjs/Meshes/mesh";
  48504. /**
  48505. * Class containing static functions to help procedurally build meshes
  48506. */
  48507. export class HemisphereBuilder {
  48508. /**
  48509. * Creates a hemisphere mesh
  48510. * @param name defines the name of the mesh
  48511. * @param options defines the options used to create the mesh
  48512. * @param scene defines the hosting scene
  48513. * @returns the hemisphere mesh
  48514. */
  48515. static CreateHemisphere(name: string, options: {
  48516. segments?: number;
  48517. diameter?: number;
  48518. sideOrientation?: number;
  48519. }, scene: any): Mesh;
  48520. }
  48521. }
  48522. declare module "babylonjs/Lights/spotLight" {
  48523. import { Nullable } from "babylonjs/types";
  48524. import { Scene } from "babylonjs/scene";
  48525. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48527. import { Effect } from "babylonjs/Materials/effect";
  48528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48529. import { Light } from "babylonjs/Lights/light";
  48530. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48531. /**
  48532. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48533. * These values define a cone of light starting from the position, emitting toward the direction.
  48534. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48535. * and the exponent defines the speed of the decay of the light with distance (reach).
  48536. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48537. */
  48538. export class SpotLight extends ShadowLight {
  48539. private _angle;
  48540. private _innerAngle;
  48541. private _cosHalfAngle;
  48542. private _lightAngleScale;
  48543. private _lightAngleOffset;
  48544. /**
  48545. * Gets the cone angle of the spot light in Radians.
  48546. */
  48547. /**
  48548. * Sets the cone angle of the spot light in Radians.
  48549. */
  48550. angle: number;
  48551. /**
  48552. * Only used in gltf falloff mode, this defines the angle where
  48553. * the directional falloff will start before cutting at angle which could be seen
  48554. * as outer angle.
  48555. */
  48556. /**
  48557. * Only used in gltf falloff mode, this defines the angle where
  48558. * the directional falloff will start before cutting at angle which could be seen
  48559. * as outer angle.
  48560. */
  48561. innerAngle: number;
  48562. private _shadowAngleScale;
  48563. /**
  48564. * Allows scaling the angle of the light for shadow generation only.
  48565. */
  48566. /**
  48567. * Allows scaling the angle of the light for shadow generation only.
  48568. */
  48569. shadowAngleScale: number;
  48570. /**
  48571. * The light decay speed with the distance from the emission spot.
  48572. */
  48573. exponent: number;
  48574. private _projectionTextureMatrix;
  48575. /**
  48576. * Allows reading the projecton texture
  48577. */
  48578. readonly projectionTextureMatrix: Matrix;
  48579. protected _projectionTextureLightNear: number;
  48580. /**
  48581. * Gets the near clip of the Spotlight for texture projection.
  48582. */
  48583. /**
  48584. * Sets the near clip of the Spotlight for texture projection.
  48585. */
  48586. projectionTextureLightNear: number;
  48587. protected _projectionTextureLightFar: number;
  48588. /**
  48589. * Gets the far clip of the Spotlight for texture projection.
  48590. */
  48591. /**
  48592. * Sets the far clip of the Spotlight for texture projection.
  48593. */
  48594. projectionTextureLightFar: number;
  48595. protected _projectionTextureUpDirection: Vector3;
  48596. /**
  48597. * Gets the Up vector of the Spotlight for texture projection.
  48598. */
  48599. /**
  48600. * Sets the Up vector of the Spotlight for texture projection.
  48601. */
  48602. projectionTextureUpDirection: Vector3;
  48603. private _projectionTexture;
  48604. /**
  48605. * Gets the projection texture of the light.
  48606. */
  48607. /**
  48608. * Sets the projection texture of the light.
  48609. */
  48610. projectionTexture: Nullable<BaseTexture>;
  48611. private _projectionTextureViewLightDirty;
  48612. private _projectionTextureProjectionLightDirty;
  48613. private _projectionTextureDirty;
  48614. private _projectionTextureViewTargetVector;
  48615. private _projectionTextureViewLightMatrix;
  48616. private _projectionTextureProjectionLightMatrix;
  48617. private _projectionTextureScalingMatrix;
  48618. /**
  48619. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48620. * It can cast shadows.
  48621. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48622. * @param name The light friendly name
  48623. * @param position The position of the spot light in the scene
  48624. * @param direction The direction of the light in the scene
  48625. * @param angle The cone angle of the light in Radians
  48626. * @param exponent The light decay speed with the distance from the emission spot
  48627. * @param scene The scene the lights belongs to
  48628. */
  48629. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48630. /**
  48631. * Returns the string "SpotLight".
  48632. * @returns the class name
  48633. */
  48634. getClassName(): string;
  48635. /**
  48636. * Returns the integer 2.
  48637. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48638. */
  48639. getTypeID(): number;
  48640. /**
  48641. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48642. */
  48643. protected _setDirection(value: Vector3): void;
  48644. /**
  48645. * Overrides the position setter to recompute the projection texture view light Matrix.
  48646. */
  48647. protected _setPosition(value: Vector3): void;
  48648. /**
  48649. * 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.
  48650. * Returns the SpotLight.
  48651. */
  48652. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48653. protected _computeProjectionTextureViewLightMatrix(): void;
  48654. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48655. /**
  48656. * Main function for light texture projection matrix computing.
  48657. */
  48658. protected _computeProjectionTextureMatrix(): void;
  48659. protected _buildUniformLayout(): void;
  48660. private _computeAngleValues;
  48661. /**
  48662. * Sets the passed Effect "effect" with the Light textures.
  48663. * @param effect The effect to update
  48664. * @param lightIndex The index of the light in the effect to update
  48665. * @returns The light
  48666. */
  48667. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48668. /**
  48669. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48670. * @param effect The effect to update
  48671. * @param lightIndex The index of the light in the effect to update
  48672. * @returns The spot light
  48673. */
  48674. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48675. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48676. /**
  48677. * Disposes the light and the associated resources.
  48678. */
  48679. dispose(): void;
  48680. /**
  48681. * Prepares the list of defines specific to the light type.
  48682. * @param defines the list of defines
  48683. * @param lightIndex defines the index of the light for the effect
  48684. */
  48685. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48686. }
  48687. }
  48688. declare module "babylonjs/Gizmos/lightGizmo" {
  48689. import { Nullable } from "babylonjs/types";
  48690. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48691. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48692. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48693. import { Light } from "babylonjs/Lights/light";
  48694. /**
  48695. * Gizmo that enables viewing a light
  48696. */
  48697. export class LightGizmo extends Gizmo {
  48698. private _lightMesh;
  48699. private _material;
  48700. private _cachedPosition;
  48701. private _cachedForward;
  48702. private _attachedMeshParent;
  48703. /**
  48704. * Creates a LightGizmo
  48705. * @param gizmoLayer The utility layer the gizmo will be added to
  48706. */
  48707. constructor(gizmoLayer?: UtilityLayerRenderer);
  48708. private _light;
  48709. /**
  48710. * The light that the gizmo is attached to
  48711. */
  48712. light: Nullable<Light>;
  48713. /**
  48714. * Gets the material used to render the light gizmo
  48715. */
  48716. readonly material: StandardMaterial;
  48717. /**
  48718. * @hidden
  48719. * Updates the gizmo to match the attached mesh's position/rotation
  48720. */
  48721. protected _update(): void;
  48722. private static _Scale;
  48723. /**
  48724. * Creates the lines for a light mesh
  48725. */
  48726. private static _CreateLightLines;
  48727. /**
  48728. * Disposes of the light gizmo
  48729. */
  48730. dispose(): void;
  48731. private static _CreateHemisphericLightMesh;
  48732. private static _CreatePointLightMesh;
  48733. private static _CreateSpotLightMesh;
  48734. private static _CreateDirectionalLightMesh;
  48735. }
  48736. }
  48737. declare module "babylonjs/Gizmos/index" {
  48738. export * from "babylonjs/Gizmos/axisDragGizmo";
  48739. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48740. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48741. export * from "babylonjs/Gizmos/gizmo";
  48742. export * from "babylonjs/Gizmos/gizmoManager";
  48743. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48744. export * from "babylonjs/Gizmos/positionGizmo";
  48745. export * from "babylonjs/Gizmos/rotationGizmo";
  48746. export * from "babylonjs/Gizmos/scaleGizmo";
  48747. export * from "babylonjs/Gizmos/lightGizmo";
  48748. export * from "babylonjs/Gizmos/planeDragGizmo";
  48749. }
  48750. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48751. /** @hidden */
  48752. export var backgroundFragmentDeclaration: {
  48753. name: string;
  48754. shader: string;
  48755. };
  48756. }
  48757. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48758. /** @hidden */
  48759. export var backgroundUboDeclaration: {
  48760. name: string;
  48761. shader: string;
  48762. };
  48763. }
  48764. declare module "babylonjs/Shaders/background.fragment" {
  48765. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48766. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48767. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48768. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48769. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48770. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48772. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48773. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48774. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48776. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48777. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48778. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48779. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48780. /** @hidden */
  48781. export var backgroundPixelShader: {
  48782. name: string;
  48783. shader: string;
  48784. };
  48785. }
  48786. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48787. /** @hidden */
  48788. export var backgroundVertexDeclaration: {
  48789. name: string;
  48790. shader: string;
  48791. };
  48792. }
  48793. declare module "babylonjs/Shaders/background.vertex" {
  48794. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48795. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48797. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48798. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48800. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48801. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48802. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48803. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48804. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48806. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48807. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48808. /** @hidden */
  48809. export var backgroundVertexShader: {
  48810. name: string;
  48811. shader: string;
  48812. };
  48813. }
  48814. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48815. import { Nullable, int, float } from "babylonjs/types";
  48816. import { Scene } from "babylonjs/scene";
  48817. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48818. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48820. import { Mesh } from "babylonjs/Meshes/mesh";
  48821. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48822. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48823. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48825. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48826. import { Color3 } from "babylonjs/Maths/math.color";
  48827. import "babylonjs/Shaders/background.fragment";
  48828. import "babylonjs/Shaders/background.vertex";
  48829. /**
  48830. * Background material used to create an efficient environement around your scene.
  48831. */
  48832. export class BackgroundMaterial extends PushMaterial {
  48833. /**
  48834. * Standard reflectance value at parallel view angle.
  48835. */
  48836. static StandardReflectance0: number;
  48837. /**
  48838. * Standard reflectance value at grazing angle.
  48839. */
  48840. static StandardReflectance90: number;
  48841. protected _primaryColor: Color3;
  48842. /**
  48843. * Key light Color (multiply against the environement texture)
  48844. */
  48845. primaryColor: Color3;
  48846. protected __perceptualColor: Nullable<Color3>;
  48847. /**
  48848. * Experimental Internal Use Only.
  48849. *
  48850. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48851. * This acts as a helper to set the primary color to a more "human friendly" value.
  48852. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48853. * output color as close as possible from the chosen value.
  48854. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48855. * part of lighting setup.)
  48856. */
  48857. _perceptualColor: Nullable<Color3>;
  48858. protected _primaryColorShadowLevel: float;
  48859. /**
  48860. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48861. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48862. */
  48863. primaryColorShadowLevel: float;
  48864. protected _primaryColorHighlightLevel: float;
  48865. /**
  48866. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48867. * The primary color is used at the level chosen to define what the white area would look.
  48868. */
  48869. primaryColorHighlightLevel: float;
  48870. protected _reflectionTexture: Nullable<BaseTexture>;
  48871. /**
  48872. * Reflection Texture used in the material.
  48873. * Should be author in a specific way for the best result (refer to the documentation).
  48874. */
  48875. reflectionTexture: Nullable<BaseTexture>;
  48876. protected _reflectionBlur: float;
  48877. /**
  48878. * Reflection Texture level of blur.
  48879. *
  48880. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48881. * texture twice.
  48882. */
  48883. reflectionBlur: float;
  48884. protected _diffuseTexture: Nullable<BaseTexture>;
  48885. /**
  48886. * Diffuse Texture used in the material.
  48887. * Should be author in a specific way for the best result (refer to the documentation).
  48888. */
  48889. diffuseTexture: Nullable<BaseTexture>;
  48890. protected _shadowLights: Nullable<IShadowLight[]>;
  48891. /**
  48892. * Specify the list of lights casting shadow on the material.
  48893. * All scene shadow lights will be included if null.
  48894. */
  48895. shadowLights: Nullable<IShadowLight[]>;
  48896. protected _shadowLevel: float;
  48897. /**
  48898. * Helps adjusting the shadow to a softer level if required.
  48899. * 0 means black shadows and 1 means no shadows.
  48900. */
  48901. shadowLevel: float;
  48902. protected _sceneCenter: Vector3;
  48903. /**
  48904. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48905. * It is usually zero but might be interesting to modify according to your setup.
  48906. */
  48907. sceneCenter: Vector3;
  48908. protected _opacityFresnel: boolean;
  48909. /**
  48910. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48911. * This helps ensuring a nice transition when the camera goes under the ground.
  48912. */
  48913. opacityFresnel: boolean;
  48914. protected _reflectionFresnel: boolean;
  48915. /**
  48916. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48917. * This helps adding a mirror texture on the ground.
  48918. */
  48919. reflectionFresnel: boolean;
  48920. protected _reflectionFalloffDistance: number;
  48921. /**
  48922. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48923. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48924. */
  48925. reflectionFalloffDistance: number;
  48926. protected _reflectionAmount: number;
  48927. /**
  48928. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48929. */
  48930. reflectionAmount: number;
  48931. protected _reflectionReflectance0: number;
  48932. /**
  48933. * This specifies the weight of the reflection at grazing angle.
  48934. */
  48935. reflectionReflectance0: number;
  48936. protected _reflectionReflectance90: number;
  48937. /**
  48938. * This specifies the weight of the reflection at a perpendicular point of view.
  48939. */
  48940. reflectionReflectance90: number;
  48941. /**
  48942. * Sets the reflection reflectance fresnel values according to the default standard
  48943. * empirically know to work well :-)
  48944. */
  48945. reflectionStandardFresnelWeight: number;
  48946. protected _useRGBColor: boolean;
  48947. /**
  48948. * Helps to directly use the maps channels instead of their level.
  48949. */
  48950. useRGBColor: boolean;
  48951. protected _enableNoise: boolean;
  48952. /**
  48953. * This helps reducing the banding effect that could occur on the background.
  48954. */
  48955. enableNoise: boolean;
  48956. /**
  48957. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48958. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48959. * Recommended to be keep at 1.0 except for special cases.
  48960. */
  48961. fovMultiplier: number;
  48962. private _fovMultiplier;
  48963. /**
  48964. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48965. */
  48966. useEquirectangularFOV: boolean;
  48967. private _maxSimultaneousLights;
  48968. /**
  48969. * Number of Simultaneous lights allowed on the material.
  48970. */
  48971. maxSimultaneousLights: int;
  48972. /**
  48973. * Default configuration related to image processing available in the Background Material.
  48974. */
  48975. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48976. /**
  48977. * Keep track of the image processing observer to allow dispose and replace.
  48978. */
  48979. private _imageProcessingObserver;
  48980. /**
  48981. * Attaches a new image processing configuration to the PBR Material.
  48982. * @param configuration (if null the scene configuration will be use)
  48983. */
  48984. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48985. /**
  48986. * Gets the image processing configuration used either in this material.
  48987. */
  48988. /**
  48989. * Sets the Default image processing configuration used either in the this material.
  48990. *
  48991. * If sets to null, the scene one is in use.
  48992. */
  48993. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48994. /**
  48995. * Gets wether the color curves effect is enabled.
  48996. */
  48997. /**
  48998. * Sets wether the color curves effect is enabled.
  48999. */
  49000. cameraColorCurvesEnabled: boolean;
  49001. /**
  49002. * Gets wether the color grading effect is enabled.
  49003. */
  49004. /**
  49005. * Gets wether the color grading effect is enabled.
  49006. */
  49007. cameraColorGradingEnabled: boolean;
  49008. /**
  49009. * Gets wether tonemapping is enabled or not.
  49010. */
  49011. /**
  49012. * Sets wether tonemapping is enabled or not
  49013. */
  49014. cameraToneMappingEnabled: boolean;
  49015. /**
  49016. * The camera exposure used on this material.
  49017. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49018. * This corresponds to a photographic exposure.
  49019. */
  49020. /**
  49021. * The camera exposure used on this material.
  49022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49023. * This corresponds to a photographic exposure.
  49024. */
  49025. cameraExposure: float;
  49026. /**
  49027. * Gets The camera contrast used on this material.
  49028. */
  49029. /**
  49030. * Sets The camera contrast used on this material.
  49031. */
  49032. cameraContrast: float;
  49033. /**
  49034. * Gets the Color Grading 2D Lookup Texture.
  49035. */
  49036. /**
  49037. * Sets the Color Grading 2D Lookup Texture.
  49038. */
  49039. cameraColorGradingTexture: Nullable<BaseTexture>;
  49040. /**
  49041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49043. * 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;
  49044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49045. */
  49046. /**
  49047. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49048. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49049. * 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;
  49050. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49051. */
  49052. cameraColorCurves: Nullable<ColorCurves>;
  49053. /**
  49054. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49055. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49056. */
  49057. switchToBGR: boolean;
  49058. private _renderTargets;
  49059. private _reflectionControls;
  49060. private _white;
  49061. private _primaryShadowColor;
  49062. private _primaryHighlightColor;
  49063. /**
  49064. * Instantiates a Background Material in the given scene
  49065. * @param name The friendly name of the material
  49066. * @param scene The scene to add the material to
  49067. */
  49068. constructor(name: string, scene: Scene);
  49069. /**
  49070. * Gets a boolean indicating that current material needs to register RTT
  49071. */
  49072. readonly hasRenderTargetTextures: boolean;
  49073. /**
  49074. * The entire material has been created in order to prevent overdraw.
  49075. * @returns false
  49076. */
  49077. needAlphaTesting(): boolean;
  49078. /**
  49079. * The entire material has been created in order to prevent overdraw.
  49080. * @returns true if blending is enable
  49081. */
  49082. needAlphaBlending(): boolean;
  49083. /**
  49084. * Checks wether the material is ready to be rendered for a given mesh.
  49085. * @param mesh The mesh to render
  49086. * @param subMesh The submesh to check against
  49087. * @param useInstances Specify wether or not the material is used with instances
  49088. * @returns true if all the dependencies are ready (Textures, Effects...)
  49089. */
  49090. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49091. /**
  49092. * Compute the primary color according to the chosen perceptual color.
  49093. */
  49094. private _computePrimaryColorFromPerceptualColor;
  49095. /**
  49096. * Compute the highlights and shadow colors according to their chosen levels.
  49097. */
  49098. private _computePrimaryColors;
  49099. /**
  49100. * Build the uniform buffer used in the material.
  49101. */
  49102. buildUniformLayout(): void;
  49103. /**
  49104. * Unbind the material.
  49105. */
  49106. unbind(): void;
  49107. /**
  49108. * Bind only the world matrix to the material.
  49109. * @param world The world matrix to bind.
  49110. */
  49111. bindOnlyWorldMatrix(world: Matrix): void;
  49112. /**
  49113. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49114. * @param world The world matrix to bind.
  49115. * @param subMesh The submesh to bind for.
  49116. */
  49117. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49118. /**
  49119. * Checks to see if a texture is used in the material.
  49120. * @param texture - Base texture to use.
  49121. * @returns - Boolean specifying if a texture is used in the material.
  49122. */
  49123. hasTexture(texture: BaseTexture): boolean;
  49124. /**
  49125. * Dispose the material.
  49126. * @param forceDisposeEffect Force disposal of the associated effect.
  49127. * @param forceDisposeTextures Force disposal of the associated textures.
  49128. */
  49129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49130. /**
  49131. * Clones the material.
  49132. * @param name The cloned name.
  49133. * @returns The cloned material.
  49134. */
  49135. clone(name: string): BackgroundMaterial;
  49136. /**
  49137. * Serializes the current material to its JSON representation.
  49138. * @returns The JSON representation.
  49139. */
  49140. serialize(): any;
  49141. /**
  49142. * Gets the class name of the material
  49143. * @returns "BackgroundMaterial"
  49144. */
  49145. getClassName(): string;
  49146. /**
  49147. * Parse a JSON input to create back a background material.
  49148. * @param source The JSON data to parse
  49149. * @param scene The scene to create the parsed material in
  49150. * @param rootUrl The root url of the assets the material depends upon
  49151. * @returns the instantiated BackgroundMaterial.
  49152. */
  49153. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49154. }
  49155. }
  49156. declare module "babylonjs/Helpers/environmentHelper" {
  49157. import { Observable } from "babylonjs/Misc/observable";
  49158. import { Nullable } from "babylonjs/types";
  49159. import { Scene } from "babylonjs/scene";
  49160. import { Vector3 } from "babylonjs/Maths/math.vector";
  49161. import { Color3 } from "babylonjs/Maths/math.color";
  49162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49163. import { Mesh } from "babylonjs/Meshes/mesh";
  49164. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49165. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49166. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49167. import "babylonjs/Meshes/Builders/planeBuilder";
  49168. import "babylonjs/Meshes/Builders/boxBuilder";
  49169. /**
  49170. * Represents the different options available during the creation of
  49171. * a Environment helper.
  49172. *
  49173. * This can control the default ground, skybox and image processing setup of your scene.
  49174. */
  49175. export interface IEnvironmentHelperOptions {
  49176. /**
  49177. * Specifies wether or not to create a ground.
  49178. * True by default.
  49179. */
  49180. createGround: boolean;
  49181. /**
  49182. * Specifies the ground size.
  49183. * 15 by default.
  49184. */
  49185. groundSize: number;
  49186. /**
  49187. * The texture used on the ground for the main color.
  49188. * Comes from the BabylonJS CDN by default.
  49189. *
  49190. * Remarks: Can be either a texture or a url.
  49191. */
  49192. groundTexture: string | BaseTexture;
  49193. /**
  49194. * The color mixed in the ground texture by default.
  49195. * BabylonJS clearColor by default.
  49196. */
  49197. groundColor: Color3;
  49198. /**
  49199. * Specifies the ground opacity.
  49200. * 1 by default.
  49201. */
  49202. groundOpacity: number;
  49203. /**
  49204. * Enables the ground to receive shadows.
  49205. * True by default.
  49206. */
  49207. enableGroundShadow: boolean;
  49208. /**
  49209. * Helps preventing the shadow to be fully black on the ground.
  49210. * 0.5 by default.
  49211. */
  49212. groundShadowLevel: number;
  49213. /**
  49214. * Creates a mirror texture attach to the ground.
  49215. * false by default.
  49216. */
  49217. enableGroundMirror: boolean;
  49218. /**
  49219. * Specifies the ground mirror size ratio.
  49220. * 0.3 by default as the default kernel is 64.
  49221. */
  49222. groundMirrorSizeRatio: number;
  49223. /**
  49224. * Specifies the ground mirror blur kernel size.
  49225. * 64 by default.
  49226. */
  49227. groundMirrorBlurKernel: number;
  49228. /**
  49229. * Specifies the ground mirror visibility amount.
  49230. * 1 by default
  49231. */
  49232. groundMirrorAmount: number;
  49233. /**
  49234. * Specifies the ground mirror reflectance weight.
  49235. * This uses the standard weight of the background material to setup the fresnel effect
  49236. * of the mirror.
  49237. * 1 by default.
  49238. */
  49239. groundMirrorFresnelWeight: number;
  49240. /**
  49241. * Specifies the ground mirror Falloff distance.
  49242. * This can helps reducing the size of the reflection.
  49243. * 0 by Default.
  49244. */
  49245. groundMirrorFallOffDistance: number;
  49246. /**
  49247. * Specifies the ground mirror texture type.
  49248. * Unsigned Int by Default.
  49249. */
  49250. groundMirrorTextureType: number;
  49251. /**
  49252. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49253. * the shown objects.
  49254. */
  49255. groundYBias: number;
  49256. /**
  49257. * Specifies wether or not to create a skybox.
  49258. * True by default.
  49259. */
  49260. createSkybox: boolean;
  49261. /**
  49262. * Specifies the skybox size.
  49263. * 20 by default.
  49264. */
  49265. skyboxSize: number;
  49266. /**
  49267. * The texture used on the skybox for the main color.
  49268. * Comes from the BabylonJS CDN by default.
  49269. *
  49270. * Remarks: Can be either a texture or a url.
  49271. */
  49272. skyboxTexture: string | BaseTexture;
  49273. /**
  49274. * The color mixed in the skybox texture by default.
  49275. * BabylonJS clearColor by default.
  49276. */
  49277. skyboxColor: Color3;
  49278. /**
  49279. * The background rotation around the Y axis of the scene.
  49280. * This helps aligning the key lights of your scene with the background.
  49281. * 0 by default.
  49282. */
  49283. backgroundYRotation: number;
  49284. /**
  49285. * Compute automatically the size of the elements to best fit with the scene.
  49286. */
  49287. sizeAuto: boolean;
  49288. /**
  49289. * Default position of the rootMesh if autoSize is not true.
  49290. */
  49291. rootPosition: Vector3;
  49292. /**
  49293. * Sets up the image processing in the scene.
  49294. * true by default.
  49295. */
  49296. setupImageProcessing: boolean;
  49297. /**
  49298. * The texture used as your environment texture in the scene.
  49299. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49300. *
  49301. * Remarks: Can be either a texture or a url.
  49302. */
  49303. environmentTexture: string | BaseTexture;
  49304. /**
  49305. * The value of the exposure to apply to the scene.
  49306. * 0.6 by default if setupImageProcessing is true.
  49307. */
  49308. cameraExposure: number;
  49309. /**
  49310. * The value of the contrast to apply to the scene.
  49311. * 1.6 by default if setupImageProcessing is true.
  49312. */
  49313. cameraContrast: number;
  49314. /**
  49315. * Specifies wether or not tonemapping should be enabled in the scene.
  49316. * true by default if setupImageProcessing is true.
  49317. */
  49318. toneMappingEnabled: boolean;
  49319. }
  49320. /**
  49321. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49322. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49323. * It also helps with the default setup of your imageProcessing configuration.
  49324. */
  49325. export class EnvironmentHelper {
  49326. /**
  49327. * Default ground texture URL.
  49328. */
  49329. private static _groundTextureCDNUrl;
  49330. /**
  49331. * Default skybox texture URL.
  49332. */
  49333. private static _skyboxTextureCDNUrl;
  49334. /**
  49335. * Default environment texture URL.
  49336. */
  49337. private static _environmentTextureCDNUrl;
  49338. /**
  49339. * Creates the default options for the helper.
  49340. */
  49341. private static _getDefaultOptions;
  49342. private _rootMesh;
  49343. /**
  49344. * Gets the root mesh created by the helper.
  49345. */
  49346. readonly rootMesh: Mesh;
  49347. private _skybox;
  49348. /**
  49349. * Gets the skybox created by the helper.
  49350. */
  49351. readonly skybox: Nullable<Mesh>;
  49352. private _skyboxTexture;
  49353. /**
  49354. * Gets the skybox texture created by the helper.
  49355. */
  49356. readonly skyboxTexture: Nullable<BaseTexture>;
  49357. private _skyboxMaterial;
  49358. /**
  49359. * Gets the skybox material created by the helper.
  49360. */
  49361. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49362. private _ground;
  49363. /**
  49364. * Gets the ground mesh created by the helper.
  49365. */
  49366. readonly ground: Nullable<Mesh>;
  49367. private _groundTexture;
  49368. /**
  49369. * Gets the ground texture created by the helper.
  49370. */
  49371. readonly groundTexture: Nullable<BaseTexture>;
  49372. private _groundMirror;
  49373. /**
  49374. * Gets the ground mirror created by the helper.
  49375. */
  49376. readonly groundMirror: Nullable<MirrorTexture>;
  49377. /**
  49378. * Gets the ground mirror render list to helps pushing the meshes
  49379. * you wish in the ground reflection.
  49380. */
  49381. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49382. private _groundMaterial;
  49383. /**
  49384. * Gets the ground material created by the helper.
  49385. */
  49386. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49387. /**
  49388. * Stores the creation options.
  49389. */
  49390. private readonly _scene;
  49391. private _options;
  49392. /**
  49393. * This observable will be notified with any error during the creation of the environment,
  49394. * mainly texture creation errors.
  49395. */
  49396. onErrorObservable: Observable<{
  49397. message?: string;
  49398. exception?: any;
  49399. }>;
  49400. /**
  49401. * constructor
  49402. * @param options Defines the options we want to customize the helper
  49403. * @param scene The scene to add the material to
  49404. */
  49405. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49406. /**
  49407. * Updates the background according to the new options
  49408. * @param options
  49409. */
  49410. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49411. /**
  49412. * Sets the primary color of all the available elements.
  49413. * @param color the main color to affect to the ground and the background
  49414. */
  49415. setMainColor(color: Color3): void;
  49416. /**
  49417. * Setup the image processing according to the specified options.
  49418. */
  49419. private _setupImageProcessing;
  49420. /**
  49421. * Setup the environment texture according to the specified options.
  49422. */
  49423. private _setupEnvironmentTexture;
  49424. /**
  49425. * Setup the background according to the specified options.
  49426. */
  49427. private _setupBackground;
  49428. /**
  49429. * Get the scene sizes according to the setup.
  49430. */
  49431. private _getSceneSize;
  49432. /**
  49433. * Setup the ground according to the specified options.
  49434. */
  49435. private _setupGround;
  49436. /**
  49437. * Setup the ground material according to the specified options.
  49438. */
  49439. private _setupGroundMaterial;
  49440. /**
  49441. * Setup the ground diffuse texture according to the specified options.
  49442. */
  49443. private _setupGroundDiffuseTexture;
  49444. /**
  49445. * Setup the ground mirror texture according to the specified options.
  49446. */
  49447. private _setupGroundMirrorTexture;
  49448. /**
  49449. * Setup the ground to receive the mirror texture.
  49450. */
  49451. private _setupMirrorInGroundMaterial;
  49452. /**
  49453. * Setup the skybox according to the specified options.
  49454. */
  49455. private _setupSkybox;
  49456. /**
  49457. * Setup the skybox material according to the specified options.
  49458. */
  49459. private _setupSkyboxMaterial;
  49460. /**
  49461. * Setup the skybox reflection texture according to the specified options.
  49462. */
  49463. private _setupSkyboxReflectionTexture;
  49464. private _errorHandler;
  49465. /**
  49466. * Dispose all the elements created by the Helper.
  49467. */
  49468. dispose(): void;
  49469. }
  49470. }
  49471. declare module "babylonjs/Helpers/photoDome" {
  49472. import { Observable } from "babylonjs/Misc/observable";
  49473. import { Nullable } from "babylonjs/types";
  49474. import { Scene } from "babylonjs/scene";
  49475. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49476. import { Mesh } from "babylonjs/Meshes/mesh";
  49477. import { Texture } from "babylonjs/Materials/Textures/texture";
  49478. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49479. import "babylonjs/Meshes/Builders/sphereBuilder";
  49480. /**
  49481. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49482. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49483. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49484. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49485. */
  49486. export class PhotoDome extends TransformNode {
  49487. /**
  49488. * Define the image as a Monoscopic panoramic 360 image.
  49489. */
  49490. static readonly MODE_MONOSCOPIC: number;
  49491. /**
  49492. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49493. */
  49494. static readonly MODE_TOPBOTTOM: number;
  49495. /**
  49496. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49497. */
  49498. static readonly MODE_SIDEBYSIDE: number;
  49499. private _useDirectMapping;
  49500. /**
  49501. * The texture being displayed on the sphere
  49502. */
  49503. protected _photoTexture: Texture;
  49504. /**
  49505. * Gets or sets the texture being displayed on the sphere
  49506. */
  49507. photoTexture: Texture;
  49508. /**
  49509. * Observable raised when an error occured while loading the 360 image
  49510. */
  49511. onLoadErrorObservable: Observable<string>;
  49512. /**
  49513. * The skybox material
  49514. */
  49515. protected _material: BackgroundMaterial;
  49516. /**
  49517. * The surface used for the skybox
  49518. */
  49519. protected _mesh: Mesh;
  49520. /**
  49521. * Gets the mesh used for the skybox.
  49522. */
  49523. readonly mesh: Mesh;
  49524. /**
  49525. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49526. * Also see the options.resolution property.
  49527. */
  49528. fovMultiplier: number;
  49529. private _imageMode;
  49530. /**
  49531. * Gets or set the current video mode for the video. It can be:
  49532. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49533. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49534. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49535. */
  49536. imageMode: number;
  49537. /**
  49538. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49539. * @param name Element's name, child elements will append suffixes for their own names.
  49540. * @param urlsOfPhoto defines the url of the photo to display
  49541. * @param options defines an object containing optional or exposed sub element properties
  49542. * @param onError defines a callback called when an error occured while loading the texture
  49543. */
  49544. constructor(name: string, urlOfPhoto: string, options: {
  49545. resolution?: number;
  49546. size?: number;
  49547. useDirectMapping?: boolean;
  49548. faceForward?: boolean;
  49549. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49550. private _onBeforeCameraRenderObserver;
  49551. private _changeImageMode;
  49552. /**
  49553. * Releases resources associated with this node.
  49554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49556. */
  49557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49558. }
  49559. }
  49560. declare module "babylonjs/Misc/rgbdTextureTools" {
  49561. import "babylonjs/Shaders/rgbdDecode.fragment";
  49562. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49563. import { Texture } from "babylonjs/Materials/Textures/texture";
  49564. /**
  49565. * Class used to host RGBD texture specific utilities
  49566. */
  49567. export class RGBDTextureTools {
  49568. /**
  49569. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49570. * @param texture the texture to expand.
  49571. */
  49572. static ExpandRGBDTexture(texture: Texture): void;
  49573. }
  49574. }
  49575. declare module "babylonjs/Misc/brdfTextureTools" {
  49576. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49577. import { Scene } from "babylonjs/scene";
  49578. /**
  49579. * Class used to host texture specific utilities
  49580. */
  49581. export class BRDFTextureTools {
  49582. /**
  49583. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49584. * @param scene defines the hosting scene
  49585. * @returns the environment BRDF texture
  49586. */
  49587. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49588. private static _environmentBRDFBase64Texture;
  49589. }
  49590. }
  49591. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49592. import { Nullable } from "babylonjs/types";
  49593. import { Color3 } from "babylonjs/Maths/math.color";
  49594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49595. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49597. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49598. import { Engine } from "babylonjs/Engines/engine";
  49599. import { Scene } from "babylonjs/scene";
  49600. /**
  49601. * @hidden
  49602. */
  49603. export interface IMaterialClearCoatDefines {
  49604. CLEARCOAT: boolean;
  49605. CLEARCOAT_DEFAULTIOR: boolean;
  49606. CLEARCOAT_TEXTURE: boolean;
  49607. CLEARCOAT_TEXTUREDIRECTUV: number;
  49608. CLEARCOAT_BUMP: boolean;
  49609. CLEARCOAT_BUMPDIRECTUV: number;
  49610. CLEARCOAT_TINT: boolean;
  49611. CLEARCOAT_TINT_TEXTURE: boolean;
  49612. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49613. /** @hidden */
  49614. _areTexturesDirty: boolean;
  49615. }
  49616. /**
  49617. * Define the code related to the clear coat parameters of the pbr material.
  49618. */
  49619. export class PBRClearCoatConfiguration {
  49620. /**
  49621. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49622. * The default fits with a polyurethane material.
  49623. */
  49624. private static readonly _DefaultIndexOfRefraction;
  49625. private _isEnabled;
  49626. /**
  49627. * Defines if the clear coat is enabled in the material.
  49628. */
  49629. isEnabled: boolean;
  49630. /**
  49631. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49632. */
  49633. intensity: number;
  49634. /**
  49635. * Defines the clear coat layer roughness.
  49636. */
  49637. roughness: number;
  49638. private _indexOfRefraction;
  49639. /**
  49640. * Defines the index of refraction of the clear coat.
  49641. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49642. * The default fits with a polyurethane material.
  49643. * Changing the default value is more performance intensive.
  49644. */
  49645. indexOfRefraction: number;
  49646. private _texture;
  49647. /**
  49648. * Stores the clear coat values in a texture.
  49649. */
  49650. texture: Nullable<BaseTexture>;
  49651. private _bumpTexture;
  49652. /**
  49653. * Define the clear coat specific bump texture.
  49654. */
  49655. bumpTexture: Nullable<BaseTexture>;
  49656. private _isTintEnabled;
  49657. /**
  49658. * Defines if the clear coat tint is enabled in the material.
  49659. */
  49660. isTintEnabled: boolean;
  49661. /**
  49662. * Defines the clear coat tint of the material.
  49663. * This is only use if tint is enabled
  49664. */
  49665. tintColor: Color3;
  49666. /**
  49667. * Defines the distance at which the tint color should be found in the
  49668. * clear coat media.
  49669. * This is only use if tint is enabled
  49670. */
  49671. tintColorAtDistance: number;
  49672. /**
  49673. * Defines the clear coat layer thickness.
  49674. * This is only use if tint is enabled
  49675. */
  49676. tintThickness: number;
  49677. private _tintTexture;
  49678. /**
  49679. * Stores the clear tint values in a texture.
  49680. * rgb is tint
  49681. * a is a thickness factor
  49682. */
  49683. tintTexture: Nullable<BaseTexture>;
  49684. /** @hidden */
  49685. private _internalMarkAllSubMeshesAsTexturesDirty;
  49686. /** @hidden */
  49687. _markAllSubMeshesAsTexturesDirty(): void;
  49688. /**
  49689. * Instantiate a new istance of clear coat configuration.
  49690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49691. */
  49692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49693. /**
  49694. * Gets wehter the submesh is ready to be used or not.
  49695. * @param defines the list of "defines" to update.
  49696. * @param scene defines the scene the material belongs to.
  49697. * @param engine defines the engine the material belongs to.
  49698. * @param disableBumpMap defines wether the material disables bump or not.
  49699. * @returns - boolean indicating that the submesh is ready or not.
  49700. */
  49701. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49702. /**
  49703. * Checks to see if a texture is used in the material.
  49704. * @param defines the list of "defines" to update.
  49705. * @param scene defines the scene to the material belongs to.
  49706. */
  49707. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49708. /**
  49709. * Binds the material data.
  49710. * @param uniformBuffer defines the Uniform buffer to fill in.
  49711. * @param scene defines the scene the material belongs to.
  49712. * @param engine defines the engine the material belongs to.
  49713. * @param disableBumpMap defines wether the material disables bump or not.
  49714. * @param isFrozen defines wether the material is frozen or not.
  49715. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49716. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49717. */
  49718. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49719. /**
  49720. * Checks to see if a texture is used in the material.
  49721. * @param texture - Base texture to use.
  49722. * @returns - Boolean specifying if a texture is used in the material.
  49723. */
  49724. hasTexture(texture: BaseTexture): boolean;
  49725. /**
  49726. * Returns an array of the actively used textures.
  49727. * @param activeTextures Array of BaseTextures
  49728. */
  49729. getActiveTextures(activeTextures: BaseTexture[]): void;
  49730. /**
  49731. * Returns the animatable textures.
  49732. * @param animatables Array of animatable textures.
  49733. */
  49734. getAnimatables(animatables: IAnimatable[]): void;
  49735. /**
  49736. * Disposes the resources of the material.
  49737. * @param forceDisposeTextures - Forces the disposal of all textures.
  49738. */
  49739. dispose(forceDisposeTextures?: boolean): void;
  49740. /**
  49741. * Get the current class name of the texture useful for serialization or dynamic coding.
  49742. * @returns "PBRClearCoatConfiguration"
  49743. */
  49744. getClassName(): string;
  49745. /**
  49746. * Add fallbacks to the effect fallbacks list.
  49747. * @param defines defines the Base texture to use.
  49748. * @param fallbacks defines the current fallback list.
  49749. * @param currentRank defines the current fallback rank.
  49750. * @returns the new fallback rank.
  49751. */
  49752. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49753. /**
  49754. * Add the required uniforms to the current list.
  49755. * @param uniforms defines the current uniform list.
  49756. */
  49757. static AddUniforms(uniforms: string[]): void;
  49758. /**
  49759. * Add the required samplers to the current list.
  49760. * @param samplers defines the current sampler list.
  49761. */
  49762. static AddSamplers(samplers: string[]): void;
  49763. /**
  49764. * Add the required uniforms to the current buffer.
  49765. * @param uniformBuffer defines the current uniform buffer.
  49766. */
  49767. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49768. /**
  49769. * Makes a duplicate of the current configuration into another one.
  49770. * @param clearCoatConfiguration define the config where to copy the info
  49771. */
  49772. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49773. /**
  49774. * Serializes this clear coat configuration.
  49775. * @returns - An object with the serialized config.
  49776. */
  49777. serialize(): any;
  49778. /**
  49779. * Parses a anisotropy Configuration from a serialized object.
  49780. * @param source - Serialized object.
  49781. * @param scene Defines the scene we are parsing for
  49782. * @param rootUrl Defines the rootUrl to load from
  49783. */
  49784. parse(source: any, scene: Scene, rootUrl: string): void;
  49785. }
  49786. }
  49787. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49788. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49790. import { Vector2 } from "babylonjs/Maths/math.vector";
  49791. import { Scene } from "babylonjs/scene";
  49792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49793. import { Nullable } from "babylonjs/types";
  49794. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49795. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49796. /**
  49797. * @hidden
  49798. */
  49799. export interface IMaterialAnisotropicDefines {
  49800. ANISOTROPIC: boolean;
  49801. ANISOTROPIC_TEXTURE: boolean;
  49802. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49803. MAINUV1: boolean;
  49804. _areTexturesDirty: boolean;
  49805. _needUVs: boolean;
  49806. }
  49807. /**
  49808. * Define the code related to the anisotropic parameters of the pbr material.
  49809. */
  49810. export class PBRAnisotropicConfiguration {
  49811. private _isEnabled;
  49812. /**
  49813. * Defines if the anisotropy is enabled in the material.
  49814. */
  49815. isEnabled: boolean;
  49816. /**
  49817. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49818. */
  49819. intensity: number;
  49820. /**
  49821. * Defines if the effect is along the tangents, bitangents or in between.
  49822. * By default, the effect is "strectching" the highlights along the tangents.
  49823. */
  49824. direction: Vector2;
  49825. private _texture;
  49826. /**
  49827. * Stores the anisotropy values in a texture.
  49828. * rg is direction (like normal from -1 to 1)
  49829. * b is a intensity
  49830. */
  49831. texture: Nullable<BaseTexture>;
  49832. /** @hidden */
  49833. private _internalMarkAllSubMeshesAsTexturesDirty;
  49834. /** @hidden */
  49835. _markAllSubMeshesAsTexturesDirty(): void;
  49836. /**
  49837. * Instantiate a new istance of anisotropy configuration.
  49838. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49839. */
  49840. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49841. /**
  49842. * Specifies that the submesh is ready to be used.
  49843. * @param defines the list of "defines" to update.
  49844. * @param scene defines the scene the material belongs to.
  49845. * @returns - boolean indicating that the submesh is ready or not.
  49846. */
  49847. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49848. /**
  49849. * Checks to see if a texture is used in the material.
  49850. * @param defines the list of "defines" to update.
  49851. * @param mesh the mesh we are preparing the defines for.
  49852. * @param scene defines the scene the material belongs to.
  49853. */
  49854. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49855. /**
  49856. * Binds the material data.
  49857. * @param uniformBuffer defines the Uniform buffer to fill in.
  49858. * @param scene defines the scene the material belongs to.
  49859. * @param isFrozen defines wether the material is frozen or not.
  49860. */
  49861. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49862. /**
  49863. * Checks to see if a texture is used in the material.
  49864. * @param texture - Base texture to use.
  49865. * @returns - Boolean specifying if a texture is used in the material.
  49866. */
  49867. hasTexture(texture: BaseTexture): boolean;
  49868. /**
  49869. * Returns an array of the actively used textures.
  49870. * @param activeTextures Array of BaseTextures
  49871. */
  49872. getActiveTextures(activeTextures: BaseTexture[]): void;
  49873. /**
  49874. * Returns the animatable textures.
  49875. * @param animatables Array of animatable textures.
  49876. */
  49877. getAnimatables(animatables: IAnimatable[]): void;
  49878. /**
  49879. * Disposes the resources of the material.
  49880. * @param forceDisposeTextures - Forces the disposal of all textures.
  49881. */
  49882. dispose(forceDisposeTextures?: boolean): void;
  49883. /**
  49884. * Get the current class name of the texture useful for serialization or dynamic coding.
  49885. * @returns "PBRAnisotropicConfiguration"
  49886. */
  49887. getClassName(): string;
  49888. /**
  49889. * Add fallbacks to the effect fallbacks list.
  49890. * @param defines defines the Base texture to use.
  49891. * @param fallbacks defines the current fallback list.
  49892. * @param currentRank defines the current fallback rank.
  49893. * @returns the new fallback rank.
  49894. */
  49895. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49896. /**
  49897. * Add the required uniforms to the current list.
  49898. * @param uniforms defines the current uniform list.
  49899. */
  49900. static AddUniforms(uniforms: string[]): void;
  49901. /**
  49902. * Add the required uniforms to the current buffer.
  49903. * @param uniformBuffer defines the current uniform buffer.
  49904. */
  49905. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49906. /**
  49907. * Add the required samplers to the current list.
  49908. * @param samplers defines the current sampler list.
  49909. */
  49910. static AddSamplers(samplers: string[]): void;
  49911. /**
  49912. * Makes a duplicate of the current configuration into another one.
  49913. * @param anisotropicConfiguration define the config where to copy the info
  49914. */
  49915. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49916. /**
  49917. * Serializes this anisotropy configuration.
  49918. * @returns - An object with the serialized config.
  49919. */
  49920. serialize(): any;
  49921. /**
  49922. * Parses a anisotropy Configuration from a serialized object.
  49923. * @param source - Serialized object.
  49924. * @param scene Defines the scene we are parsing for
  49925. * @param rootUrl Defines the rootUrl to load from
  49926. */
  49927. parse(source: any, scene: Scene, rootUrl: string): void;
  49928. }
  49929. }
  49930. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49931. import { Scene } from "babylonjs/scene";
  49932. /**
  49933. * @hidden
  49934. */
  49935. export interface IMaterialBRDFDefines {
  49936. BRDF_V_HEIGHT_CORRELATED: boolean;
  49937. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49938. SPHERICAL_HARMONICS: boolean;
  49939. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49940. /** @hidden */
  49941. _areMiscDirty: boolean;
  49942. }
  49943. /**
  49944. * Define the code related to the BRDF parameters of the pbr material.
  49945. */
  49946. export class PBRBRDFConfiguration {
  49947. /**
  49948. * Default value used for the energy conservation.
  49949. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49950. */
  49951. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49952. /**
  49953. * Default value used for the Smith Visibility Height Correlated mode.
  49954. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49955. */
  49956. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49957. /**
  49958. * Default value used for the IBL diffuse part.
  49959. * This can help switching back to the polynomials mode globally which is a tiny bit
  49960. * less GPU intensive at the drawback of a lower quality.
  49961. */
  49962. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49963. /**
  49964. * Default value used for activating energy conservation for the specular workflow.
  49965. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49966. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49967. */
  49968. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49969. private _useEnergyConservation;
  49970. /**
  49971. * Defines if the material uses energy conservation.
  49972. */
  49973. useEnergyConservation: boolean;
  49974. private _useSmithVisibilityHeightCorrelated;
  49975. /**
  49976. * LEGACY Mode set to false
  49977. * Defines if the material uses height smith correlated visibility term.
  49978. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49979. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49980. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49981. * Not relying on height correlated will also disable energy conservation.
  49982. */
  49983. useSmithVisibilityHeightCorrelated: boolean;
  49984. private _useSphericalHarmonics;
  49985. /**
  49986. * LEGACY Mode set to false
  49987. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49988. * diffuse part of the IBL.
  49989. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49990. * to the ground truth.
  49991. */
  49992. useSphericalHarmonics: boolean;
  49993. private _useSpecularGlossinessInputEnergyConservation;
  49994. /**
  49995. * Defines if the material uses energy conservation, when the specular workflow is active.
  49996. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49997. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49998. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49999. */
  50000. useSpecularGlossinessInputEnergyConservation: boolean;
  50001. /** @hidden */
  50002. private _internalMarkAllSubMeshesAsMiscDirty;
  50003. /** @hidden */
  50004. _markAllSubMeshesAsMiscDirty(): void;
  50005. /**
  50006. * Instantiate a new istance of clear coat configuration.
  50007. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50008. */
  50009. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50010. /**
  50011. * Checks to see if a texture is used in the material.
  50012. * @param defines the list of "defines" to update.
  50013. */
  50014. prepareDefines(defines: IMaterialBRDFDefines): void;
  50015. /**
  50016. * Get the current class name of the texture useful for serialization or dynamic coding.
  50017. * @returns "PBRClearCoatConfiguration"
  50018. */
  50019. getClassName(): string;
  50020. /**
  50021. * Makes a duplicate of the current configuration into another one.
  50022. * @param brdfConfiguration define the config where to copy the info
  50023. */
  50024. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50025. /**
  50026. * Serializes this BRDF configuration.
  50027. * @returns - An object with the serialized config.
  50028. */
  50029. serialize(): any;
  50030. /**
  50031. * Parses a anisotropy Configuration from a serialized object.
  50032. * @param source - Serialized object.
  50033. * @param scene Defines the scene we are parsing for
  50034. * @param rootUrl Defines the rootUrl to load from
  50035. */
  50036. parse(source: any, scene: Scene, rootUrl: string): void;
  50037. }
  50038. }
  50039. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50041. import { Color3 } from "babylonjs/Maths/math.color";
  50042. import { Scene } from "babylonjs/scene";
  50043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50044. import { Nullable } from "babylonjs/types";
  50045. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50046. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50047. /**
  50048. * @hidden
  50049. */
  50050. export interface IMaterialSheenDefines {
  50051. SHEEN: boolean;
  50052. SHEEN_TEXTURE: boolean;
  50053. SHEEN_TEXTUREDIRECTUV: number;
  50054. SHEEN_LINKWITHALBEDO: boolean;
  50055. /** @hidden */
  50056. _areTexturesDirty: boolean;
  50057. }
  50058. /**
  50059. * Define the code related to the Sheen parameters of the pbr material.
  50060. */
  50061. export class PBRSheenConfiguration {
  50062. private _isEnabled;
  50063. /**
  50064. * Defines if the material uses sheen.
  50065. */
  50066. isEnabled: boolean;
  50067. private _linkSheenWithAlbedo;
  50068. /**
  50069. * Defines if the sheen is linked to the sheen color.
  50070. */
  50071. linkSheenWithAlbedo: boolean;
  50072. /**
  50073. * Defines the sheen intensity.
  50074. */
  50075. intensity: number;
  50076. /**
  50077. * Defines the sheen color.
  50078. */
  50079. color: Color3;
  50080. private _texture;
  50081. /**
  50082. * Stores the sheen tint values in a texture.
  50083. * rgb is tint
  50084. * a is a intensity
  50085. */
  50086. texture: Nullable<BaseTexture>;
  50087. /** @hidden */
  50088. private _internalMarkAllSubMeshesAsTexturesDirty;
  50089. /** @hidden */
  50090. _markAllSubMeshesAsTexturesDirty(): void;
  50091. /**
  50092. * Instantiate a new istance of clear coat configuration.
  50093. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50094. */
  50095. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50096. /**
  50097. * Specifies that the submesh is ready to be used.
  50098. * @param defines the list of "defines" to update.
  50099. * @param scene defines the scene the material belongs to.
  50100. * @returns - boolean indicating that the submesh is ready or not.
  50101. */
  50102. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50103. /**
  50104. * Checks to see if a texture is used in the material.
  50105. * @param defines the list of "defines" to update.
  50106. * @param scene defines the scene the material belongs to.
  50107. */
  50108. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50109. /**
  50110. * Binds the material data.
  50111. * @param uniformBuffer defines the Uniform buffer to fill in.
  50112. * @param scene defines the scene the material belongs to.
  50113. * @param isFrozen defines wether the material is frozen or not.
  50114. */
  50115. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50116. /**
  50117. * Checks to see if a texture is used in the material.
  50118. * @param texture - Base texture to use.
  50119. * @returns - Boolean specifying if a texture is used in the material.
  50120. */
  50121. hasTexture(texture: BaseTexture): boolean;
  50122. /**
  50123. * Returns an array of the actively used textures.
  50124. * @param activeTextures Array of BaseTextures
  50125. */
  50126. getActiveTextures(activeTextures: BaseTexture[]): void;
  50127. /**
  50128. * Returns the animatable textures.
  50129. * @param animatables Array of animatable textures.
  50130. */
  50131. getAnimatables(animatables: IAnimatable[]): void;
  50132. /**
  50133. * Disposes the resources of the material.
  50134. * @param forceDisposeTextures - Forces the disposal of all textures.
  50135. */
  50136. dispose(forceDisposeTextures?: boolean): void;
  50137. /**
  50138. * Get the current class name of the texture useful for serialization or dynamic coding.
  50139. * @returns "PBRSheenConfiguration"
  50140. */
  50141. getClassName(): string;
  50142. /**
  50143. * Add fallbacks to the effect fallbacks list.
  50144. * @param defines defines the Base texture to use.
  50145. * @param fallbacks defines the current fallback list.
  50146. * @param currentRank defines the current fallback rank.
  50147. * @returns the new fallback rank.
  50148. */
  50149. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50150. /**
  50151. * Add the required uniforms to the current list.
  50152. * @param uniforms defines the current uniform list.
  50153. */
  50154. static AddUniforms(uniforms: string[]): void;
  50155. /**
  50156. * Add the required uniforms to the current buffer.
  50157. * @param uniformBuffer defines the current uniform buffer.
  50158. */
  50159. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50160. /**
  50161. * Add the required samplers to the current list.
  50162. * @param samplers defines the current sampler list.
  50163. */
  50164. static AddSamplers(samplers: string[]): void;
  50165. /**
  50166. * Makes a duplicate of the current configuration into another one.
  50167. * @param sheenConfiguration define the config where to copy the info
  50168. */
  50169. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50170. /**
  50171. * Serializes this BRDF configuration.
  50172. * @returns - An object with the serialized config.
  50173. */
  50174. serialize(): any;
  50175. /**
  50176. * Parses a anisotropy Configuration from a serialized object.
  50177. * @param source - Serialized object.
  50178. * @param scene Defines the scene we are parsing for
  50179. * @param rootUrl Defines the rootUrl to load from
  50180. */
  50181. parse(source: any, scene: Scene, rootUrl: string): void;
  50182. }
  50183. }
  50184. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50185. import { Nullable } from "babylonjs/types";
  50186. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50187. import { Color3 } from "babylonjs/Maths/math.color";
  50188. import { SmartArray } from "babylonjs/Misc/smartArray";
  50189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50190. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50191. import { Effect } from "babylonjs/Materials/effect";
  50192. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50193. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50194. import { Engine } from "babylonjs/Engines/engine";
  50195. import { Scene } from "babylonjs/scene";
  50196. /**
  50197. * @hidden
  50198. */
  50199. export interface IMaterialSubSurfaceDefines {
  50200. SUBSURFACE: boolean;
  50201. SS_REFRACTION: boolean;
  50202. SS_TRANSLUCENCY: boolean;
  50203. SS_SCATERRING: boolean;
  50204. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50205. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50206. SS_REFRACTIONMAP_3D: boolean;
  50207. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50208. SS_LODINREFRACTIONALPHA: boolean;
  50209. SS_GAMMAREFRACTION: boolean;
  50210. SS_RGBDREFRACTION: boolean;
  50211. SS_LINEARSPECULARREFRACTION: boolean;
  50212. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50213. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50214. /** @hidden */
  50215. _areTexturesDirty: boolean;
  50216. }
  50217. /**
  50218. * Define the code related to the sub surface parameters of the pbr material.
  50219. */
  50220. export class PBRSubSurfaceConfiguration {
  50221. private _isRefractionEnabled;
  50222. /**
  50223. * Defines if the refraction is enabled in the material.
  50224. */
  50225. isRefractionEnabled: boolean;
  50226. private _isTranslucencyEnabled;
  50227. /**
  50228. * Defines if the translucency is enabled in the material.
  50229. */
  50230. isTranslucencyEnabled: boolean;
  50231. private _isScatteringEnabled;
  50232. /**
  50233. * Defines the refraction intensity of the material.
  50234. * The refraction when enabled replaces the Diffuse part of the material.
  50235. * The intensity helps transitionning between diffuse and refraction.
  50236. */
  50237. refractionIntensity: number;
  50238. /**
  50239. * Defines the translucency intensity of the material.
  50240. * When translucency has been enabled, this defines how much of the "translucency"
  50241. * is addded to the diffuse part of the material.
  50242. */
  50243. translucencyIntensity: number;
  50244. /**
  50245. * Defines the scattering intensity of the material.
  50246. * When scattering has been enabled, this defines how much of the "scattered light"
  50247. * is addded to the diffuse part of the material.
  50248. */
  50249. scatteringIntensity: number;
  50250. private _thicknessTexture;
  50251. /**
  50252. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50253. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50254. * 0 would mean minimumThickness
  50255. * 1 would mean maximumThickness
  50256. * The other channels might be use as a mask to vary the different effects intensity.
  50257. */
  50258. thicknessTexture: Nullable<BaseTexture>;
  50259. private _refractionTexture;
  50260. /**
  50261. * Defines the texture to use for refraction.
  50262. */
  50263. refractionTexture: Nullable<BaseTexture>;
  50264. private _indexOfRefraction;
  50265. /**
  50266. * Defines the index of refraction used in the material.
  50267. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50268. */
  50269. indexOfRefraction: number;
  50270. private _invertRefractionY;
  50271. /**
  50272. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50273. */
  50274. invertRefractionY: boolean;
  50275. private _linkRefractionWithTransparency;
  50276. /**
  50277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50278. * Materials half opaque for instance using refraction could benefit from this control.
  50279. */
  50280. linkRefractionWithTransparency: boolean;
  50281. /**
  50282. * Defines the minimum thickness stored in the thickness map.
  50283. * If no thickness map is defined, this value will be used to simulate thickness.
  50284. */
  50285. minimumThickness: number;
  50286. /**
  50287. * Defines the maximum thickness stored in the thickness map.
  50288. */
  50289. maximumThickness: number;
  50290. /**
  50291. * Defines the volume tint of the material.
  50292. * This is used for both translucency and scattering.
  50293. */
  50294. tintColor: Color3;
  50295. /**
  50296. * Defines the distance at which the tint color should be found in the media.
  50297. * This is used for refraction only.
  50298. */
  50299. tintColorAtDistance: number;
  50300. /**
  50301. * Defines how far each channel transmit through the media.
  50302. * It is defined as a color to simplify it selection.
  50303. */
  50304. diffusionDistance: Color3;
  50305. private _useMaskFromThicknessTexture;
  50306. /**
  50307. * Stores the intensity of the different subsurface effects in the thickness texture.
  50308. * * the green channel is the translucency intensity.
  50309. * * the blue channel is the scattering intensity.
  50310. * * the alpha channel is the refraction intensity.
  50311. */
  50312. useMaskFromThicknessTexture: boolean;
  50313. /** @hidden */
  50314. private _internalMarkAllSubMeshesAsTexturesDirty;
  50315. /** @hidden */
  50316. _markAllSubMeshesAsTexturesDirty(): void;
  50317. /**
  50318. * Instantiate a new istance of sub surface configuration.
  50319. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50320. */
  50321. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50322. /**
  50323. * Gets wehter the submesh is ready to be used or not.
  50324. * @param defines the list of "defines" to update.
  50325. * @param scene defines the scene the material belongs to.
  50326. * @returns - boolean indicating that the submesh is ready or not.
  50327. */
  50328. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50329. /**
  50330. * Checks to see if a texture is used in the material.
  50331. * @param defines the list of "defines" to update.
  50332. * @param scene defines the scene to the material belongs to.
  50333. */
  50334. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50335. /**
  50336. * Binds the material data.
  50337. * @param uniformBuffer defines the Uniform buffer to fill in.
  50338. * @param scene defines the scene the material belongs to.
  50339. * @param engine defines the engine the material belongs to.
  50340. * @param isFrozen defines wether the material is frozen or not.
  50341. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50342. */
  50343. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50344. /**
  50345. * Unbinds the material from the mesh.
  50346. * @param activeEffect defines the effect that should be unbound from.
  50347. * @returns true if unbound, otherwise false
  50348. */
  50349. unbind(activeEffect: Effect): boolean;
  50350. /**
  50351. * Returns the texture used for refraction or null if none is used.
  50352. * @param scene defines the scene the material belongs to.
  50353. * @returns - Refraction texture if present. If no refraction texture and refraction
  50354. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50355. */
  50356. private _getRefractionTexture;
  50357. /**
  50358. * Returns true if alpha blending should be disabled.
  50359. */
  50360. readonly disableAlphaBlending: boolean;
  50361. /**
  50362. * Fills the list of render target textures.
  50363. * @param renderTargets the list of render targets to update
  50364. */
  50365. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50366. /**
  50367. * Checks to see if a texture is used in the material.
  50368. * @param texture - Base texture to use.
  50369. * @returns - Boolean specifying if a texture is used in the material.
  50370. */
  50371. hasTexture(texture: BaseTexture): boolean;
  50372. /**
  50373. * Gets a boolean indicating that current material needs to register RTT
  50374. * @returns true if this uses a render target otherwise false.
  50375. */
  50376. hasRenderTargetTextures(): boolean;
  50377. /**
  50378. * Returns an array of the actively used textures.
  50379. * @param activeTextures Array of BaseTextures
  50380. */
  50381. getActiveTextures(activeTextures: BaseTexture[]): void;
  50382. /**
  50383. * Returns the animatable textures.
  50384. * @param animatables Array of animatable textures.
  50385. */
  50386. getAnimatables(animatables: IAnimatable[]): void;
  50387. /**
  50388. * Disposes the resources of the material.
  50389. * @param forceDisposeTextures - Forces the disposal of all textures.
  50390. */
  50391. dispose(forceDisposeTextures?: boolean): void;
  50392. /**
  50393. * Get the current class name of the texture useful for serialization or dynamic coding.
  50394. * @returns "PBRSubSurfaceConfiguration"
  50395. */
  50396. getClassName(): string;
  50397. /**
  50398. * Add fallbacks to the effect fallbacks list.
  50399. * @param defines defines the Base texture to use.
  50400. * @param fallbacks defines the current fallback list.
  50401. * @param currentRank defines the current fallback rank.
  50402. * @returns the new fallback rank.
  50403. */
  50404. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50405. /**
  50406. * Add the required uniforms to the current list.
  50407. * @param uniforms defines the current uniform list.
  50408. */
  50409. static AddUniforms(uniforms: string[]): void;
  50410. /**
  50411. * Add the required samplers to the current list.
  50412. * @param samplers defines the current sampler list.
  50413. */
  50414. static AddSamplers(samplers: string[]): void;
  50415. /**
  50416. * Add the required uniforms to the current buffer.
  50417. * @param uniformBuffer defines the current uniform buffer.
  50418. */
  50419. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50420. /**
  50421. * Makes a duplicate of the current configuration into another one.
  50422. * @param configuration define the config where to copy the info
  50423. */
  50424. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50425. /**
  50426. * Serializes this Sub Surface configuration.
  50427. * @returns - An object with the serialized config.
  50428. */
  50429. serialize(): any;
  50430. /**
  50431. * Parses a anisotropy Configuration from a serialized object.
  50432. * @param source - Serialized object.
  50433. * @param scene Defines the scene we are parsing for
  50434. * @param rootUrl Defines the rootUrl to load from
  50435. */
  50436. parse(source: any, scene: Scene, rootUrl: string): void;
  50437. }
  50438. }
  50439. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50440. /** @hidden */
  50441. export var pbrFragmentDeclaration: {
  50442. name: string;
  50443. shader: string;
  50444. };
  50445. }
  50446. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50447. /** @hidden */
  50448. export var pbrUboDeclaration: {
  50449. name: string;
  50450. shader: string;
  50451. };
  50452. }
  50453. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50454. /** @hidden */
  50455. export var pbrFragmentExtraDeclaration: {
  50456. name: string;
  50457. shader: string;
  50458. };
  50459. }
  50460. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50461. /** @hidden */
  50462. export var pbrFragmentSamplersDeclaration: {
  50463. name: string;
  50464. shader: string;
  50465. };
  50466. }
  50467. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50468. /** @hidden */
  50469. export var pbrHelperFunctions: {
  50470. name: string;
  50471. shader: string;
  50472. };
  50473. }
  50474. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50475. /** @hidden */
  50476. export var harmonicsFunctions: {
  50477. name: string;
  50478. shader: string;
  50479. };
  50480. }
  50481. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50482. /** @hidden */
  50483. export var pbrDirectLightingSetupFunctions: {
  50484. name: string;
  50485. shader: string;
  50486. };
  50487. }
  50488. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50489. /** @hidden */
  50490. export var pbrDirectLightingFalloffFunctions: {
  50491. name: string;
  50492. shader: string;
  50493. };
  50494. }
  50495. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50496. /** @hidden */
  50497. export var pbrBRDFFunctions: {
  50498. name: string;
  50499. shader: string;
  50500. };
  50501. }
  50502. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50503. /** @hidden */
  50504. export var pbrDirectLightingFunctions: {
  50505. name: string;
  50506. shader: string;
  50507. };
  50508. }
  50509. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50510. /** @hidden */
  50511. export var pbrIBLFunctions: {
  50512. name: string;
  50513. shader: string;
  50514. };
  50515. }
  50516. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50517. /** @hidden */
  50518. export var pbrDebug: {
  50519. name: string;
  50520. shader: string;
  50521. };
  50522. }
  50523. declare module "babylonjs/Shaders/pbr.fragment" {
  50524. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50525. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50526. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50527. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50528. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50529. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50530. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50531. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50532. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50533. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50534. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50535. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50536. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50537. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50538. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50539. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50540. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50541. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50542. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50543. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50544. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50545. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50546. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50547. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50548. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50549. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50550. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50551. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50552. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50553. /** @hidden */
  50554. export var pbrPixelShader: {
  50555. name: string;
  50556. shader: string;
  50557. };
  50558. }
  50559. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50560. /** @hidden */
  50561. export var pbrVertexDeclaration: {
  50562. name: string;
  50563. shader: string;
  50564. };
  50565. }
  50566. declare module "babylonjs/Shaders/pbr.vertex" {
  50567. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50568. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50569. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50570. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50571. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50572. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50573. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50574. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50575. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50576. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50577. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50580. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50581. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50582. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50583. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50584. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50586. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50587. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50588. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50589. /** @hidden */
  50590. export var pbrVertexShader: {
  50591. name: string;
  50592. shader: string;
  50593. };
  50594. }
  50595. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50596. import { Nullable } from "babylonjs/types";
  50597. import { Scene } from "babylonjs/scene";
  50598. import { Matrix } from "babylonjs/Maths/math.vector";
  50599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50601. import { Mesh } from "babylonjs/Meshes/mesh";
  50602. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50603. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50604. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50605. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50606. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50607. import { Color3 } from "babylonjs/Maths/math.color";
  50608. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50609. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50610. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50611. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50613. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50614. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50615. import "babylonjs/Shaders/pbr.fragment";
  50616. import "babylonjs/Shaders/pbr.vertex";
  50617. /**
  50618. * Manages the defines for the PBR Material.
  50619. * @hidden
  50620. */
  50621. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50622. PBR: boolean;
  50623. MAINUV1: boolean;
  50624. MAINUV2: boolean;
  50625. UV1: boolean;
  50626. UV2: boolean;
  50627. ALBEDO: boolean;
  50628. ALBEDODIRECTUV: number;
  50629. VERTEXCOLOR: boolean;
  50630. AMBIENT: boolean;
  50631. AMBIENTDIRECTUV: number;
  50632. AMBIENTINGRAYSCALE: boolean;
  50633. OPACITY: boolean;
  50634. VERTEXALPHA: boolean;
  50635. OPACITYDIRECTUV: number;
  50636. OPACITYRGB: boolean;
  50637. ALPHATEST: boolean;
  50638. DEPTHPREPASS: boolean;
  50639. ALPHABLEND: boolean;
  50640. ALPHAFROMALBEDO: boolean;
  50641. ALPHATESTVALUE: string;
  50642. SPECULAROVERALPHA: boolean;
  50643. RADIANCEOVERALPHA: boolean;
  50644. ALPHAFRESNEL: boolean;
  50645. LINEARALPHAFRESNEL: boolean;
  50646. PREMULTIPLYALPHA: boolean;
  50647. EMISSIVE: boolean;
  50648. EMISSIVEDIRECTUV: number;
  50649. REFLECTIVITY: boolean;
  50650. REFLECTIVITYDIRECTUV: number;
  50651. SPECULARTERM: boolean;
  50652. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50653. MICROSURFACEAUTOMATIC: boolean;
  50654. LODBASEDMICROSFURACE: boolean;
  50655. MICROSURFACEMAP: boolean;
  50656. MICROSURFACEMAPDIRECTUV: number;
  50657. METALLICWORKFLOW: boolean;
  50658. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50659. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50660. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50661. AOSTOREINMETALMAPRED: boolean;
  50662. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50663. ENVIRONMENTBRDF: boolean;
  50664. ENVIRONMENTBRDF_RGBD: boolean;
  50665. NORMAL: boolean;
  50666. TANGENT: boolean;
  50667. BUMP: boolean;
  50668. BUMPDIRECTUV: number;
  50669. OBJECTSPACE_NORMALMAP: boolean;
  50670. PARALLAX: boolean;
  50671. PARALLAXOCCLUSION: boolean;
  50672. NORMALXYSCALE: boolean;
  50673. LIGHTMAP: boolean;
  50674. LIGHTMAPDIRECTUV: number;
  50675. USELIGHTMAPASSHADOWMAP: boolean;
  50676. GAMMALIGHTMAP: boolean;
  50677. RGBDLIGHTMAP: boolean;
  50678. REFLECTION: boolean;
  50679. REFLECTIONMAP_3D: boolean;
  50680. REFLECTIONMAP_SPHERICAL: boolean;
  50681. REFLECTIONMAP_PLANAR: boolean;
  50682. REFLECTIONMAP_CUBIC: boolean;
  50683. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50684. REFLECTIONMAP_PROJECTION: boolean;
  50685. REFLECTIONMAP_SKYBOX: boolean;
  50686. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50687. REFLECTIONMAP_EXPLICIT: boolean;
  50688. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50689. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50690. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50691. INVERTCUBICMAP: boolean;
  50692. USESPHERICALFROMREFLECTIONMAP: boolean;
  50693. USEIRRADIANCEMAP: boolean;
  50694. SPHERICAL_HARMONICS: boolean;
  50695. USESPHERICALINVERTEX: boolean;
  50696. REFLECTIONMAP_OPPOSITEZ: boolean;
  50697. LODINREFLECTIONALPHA: boolean;
  50698. GAMMAREFLECTION: boolean;
  50699. RGBDREFLECTION: boolean;
  50700. LINEARSPECULARREFLECTION: boolean;
  50701. RADIANCEOCCLUSION: boolean;
  50702. HORIZONOCCLUSION: boolean;
  50703. INSTANCES: boolean;
  50704. NUM_BONE_INFLUENCERS: number;
  50705. BonesPerMesh: number;
  50706. BONETEXTURE: boolean;
  50707. NONUNIFORMSCALING: boolean;
  50708. MORPHTARGETS: boolean;
  50709. MORPHTARGETS_NORMAL: boolean;
  50710. MORPHTARGETS_TANGENT: boolean;
  50711. MORPHTARGETS_UV: boolean;
  50712. NUM_MORPH_INFLUENCERS: number;
  50713. IMAGEPROCESSING: boolean;
  50714. VIGNETTE: boolean;
  50715. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50716. VIGNETTEBLENDMODEOPAQUE: boolean;
  50717. TONEMAPPING: boolean;
  50718. TONEMAPPING_ACES: boolean;
  50719. CONTRAST: boolean;
  50720. COLORCURVES: boolean;
  50721. COLORGRADING: boolean;
  50722. COLORGRADING3D: boolean;
  50723. SAMPLER3DGREENDEPTH: boolean;
  50724. SAMPLER3DBGRMAP: boolean;
  50725. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50726. EXPOSURE: boolean;
  50727. MULTIVIEW: boolean;
  50728. USEPHYSICALLIGHTFALLOFF: boolean;
  50729. USEGLTFLIGHTFALLOFF: boolean;
  50730. TWOSIDEDLIGHTING: boolean;
  50731. SHADOWFLOAT: boolean;
  50732. CLIPPLANE: boolean;
  50733. CLIPPLANE2: boolean;
  50734. CLIPPLANE3: boolean;
  50735. CLIPPLANE4: boolean;
  50736. POINTSIZE: boolean;
  50737. FOG: boolean;
  50738. LOGARITHMICDEPTH: boolean;
  50739. FORCENORMALFORWARD: boolean;
  50740. SPECULARAA: boolean;
  50741. CLEARCOAT: boolean;
  50742. CLEARCOAT_DEFAULTIOR: boolean;
  50743. CLEARCOAT_TEXTURE: boolean;
  50744. CLEARCOAT_TEXTUREDIRECTUV: number;
  50745. CLEARCOAT_BUMP: boolean;
  50746. CLEARCOAT_BUMPDIRECTUV: number;
  50747. CLEARCOAT_TINT: boolean;
  50748. CLEARCOAT_TINT_TEXTURE: boolean;
  50749. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50750. ANISOTROPIC: boolean;
  50751. ANISOTROPIC_TEXTURE: boolean;
  50752. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50753. BRDF_V_HEIGHT_CORRELATED: boolean;
  50754. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50755. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50756. SHEEN: boolean;
  50757. SHEEN_TEXTURE: boolean;
  50758. SHEEN_TEXTUREDIRECTUV: number;
  50759. SHEEN_LINKWITHALBEDO: boolean;
  50760. SUBSURFACE: boolean;
  50761. SS_REFRACTION: boolean;
  50762. SS_TRANSLUCENCY: boolean;
  50763. SS_SCATERRING: boolean;
  50764. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50765. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50766. SS_REFRACTIONMAP_3D: boolean;
  50767. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50768. SS_LODINREFRACTIONALPHA: boolean;
  50769. SS_GAMMAREFRACTION: boolean;
  50770. SS_RGBDREFRACTION: boolean;
  50771. SS_LINEARSPECULARREFRACTION: boolean;
  50772. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50773. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50774. UNLIT: boolean;
  50775. DEBUGMODE: number;
  50776. /**
  50777. * Initializes the PBR Material defines.
  50778. */
  50779. constructor();
  50780. /**
  50781. * Resets the PBR Material defines.
  50782. */
  50783. reset(): void;
  50784. }
  50785. /**
  50786. * The Physically based material base class of BJS.
  50787. *
  50788. * This offers the main features of a standard PBR material.
  50789. * For more information, please refer to the documentation :
  50790. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50791. */
  50792. export abstract class PBRBaseMaterial extends PushMaterial {
  50793. /**
  50794. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50795. */
  50796. static readonly PBRMATERIAL_OPAQUE: number;
  50797. /**
  50798. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50799. */
  50800. static readonly PBRMATERIAL_ALPHATEST: number;
  50801. /**
  50802. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50803. */
  50804. static readonly PBRMATERIAL_ALPHABLEND: number;
  50805. /**
  50806. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50807. * They are also discarded below the alpha cutoff threshold to improve performances.
  50808. */
  50809. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50810. /**
  50811. * Defines the default value of how much AO map is occluding the analytical lights
  50812. * (point spot...).
  50813. */
  50814. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50815. /**
  50816. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50817. */
  50818. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50819. /**
  50820. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50821. * to enhance interoperability with other engines.
  50822. */
  50823. static readonly LIGHTFALLOFF_GLTF: number;
  50824. /**
  50825. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50826. * to enhance interoperability with other materials.
  50827. */
  50828. static readonly LIGHTFALLOFF_STANDARD: number;
  50829. /**
  50830. * Intensity of the direct lights e.g. the four lights available in your scene.
  50831. * This impacts both the direct diffuse and specular highlights.
  50832. */
  50833. protected _directIntensity: number;
  50834. /**
  50835. * Intensity of the emissive part of the material.
  50836. * This helps controlling the emissive effect without modifying the emissive color.
  50837. */
  50838. protected _emissiveIntensity: number;
  50839. /**
  50840. * Intensity of the environment e.g. how much the environment will light the object
  50841. * either through harmonics for rough material or through the refelction for shiny ones.
  50842. */
  50843. protected _environmentIntensity: number;
  50844. /**
  50845. * This is a special control allowing the reduction of the specular highlights coming from the
  50846. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50847. */
  50848. protected _specularIntensity: number;
  50849. /**
  50850. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50851. */
  50852. private _lightingInfos;
  50853. /**
  50854. * Debug Control allowing disabling the bump map on this material.
  50855. */
  50856. protected _disableBumpMap: boolean;
  50857. /**
  50858. * AKA Diffuse Texture in standard nomenclature.
  50859. */
  50860. protected _albedoTexture: Nullable<BaseTexture>;
  50861. /**
  50862. * AKA Occlusion Texture in other nomenclature.
  50863. */
  50864. protected _ambientTexture: Nullable<BaseTexture>;
  50865. /**
  50866. * AKA Occlusion Texture Intensity in other nomenclature.
  50867. */
  50868. protected _ambientTextureStrength: number;
  50869. /**
  50870. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50871. * 1 means it completely occludes it
  50872. * 0 mean it has no impact
  50873. */
  50874. protected _ambientTextureImpactOnAnalyticalLights: number;
  50875. /**
  50876. * Stores the alpha values in a texture.
  50877. */
  50878. protected _opacityTexture: Nullable<BaseTexture>;
  50879. /**
  50880. * Stores the reflection values in a texture.
  50881. */
  50882. protected _reflectionTexture: Nullable<BaseTexture>;
  50883. /**
  50884. * Stores the emissive values in a texture.
  50885. */
  50886. protected _emissiveTexture: Nullable<BaseTexture>;
  50887. /**
  50888. * AKA Specular texture in other nomenclature.
  50889. */
  50890. protected _reflectivityTexture: Nullable<BaseTexture>;
  50891. /**
  50892. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50893. */
  50894. protected _metallicTexture: Nullable<BaseTexture>;
  50895. /**
  50896. * Specifies the metallic scalar of the metallic/roughness workflow.
  50897. * Can also be used to scale the metalness values of the metallic texture.
  50898. */
  50899. protected _metallic: Nullable<number>;
  50900. /**
  50901. * Specifies the roughness scalar of the metallic/roughness workflow.
  50902. * Can also be used to scale the roughness values of the metallic texture.
  50903. */
  50904. protected _roughness: Nullable<number>;
  50905. /**
  50906. * Specifies the an F0 factor to help configuring the material F0.
  50907. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50908. * to 0.5 the previously hard coded value stays the same.
  50909. * Can also be used to scale the F0 values of the metallic texture.
  50910. */
  50911. protected _metallicF0Factor: number;
  50912. /**
  50913. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50914. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50915. * your expectation as it multiplies with the texture data.
  50916. */
  50917. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50918. /**
  50919. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50920. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50921. */
  50922. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50923. /**
  50924. * Stores surface normal data used to displace a mesh in a texture.
  50925. */
  50926. protected _bumpTexture: Nullable<BaseTexture>;
  50927. /**
  50928. * Stores the pre-calculated light information of a mesh in a texture.
  50929. */
  50930. protected _lightmapTexture: Nullable<BaseTexture>;
  50931. /**
  50932. * The color of a material in ambient lighting.
  50933. */
  50934. protected _ambientColor: Color3;
  50935. /**
  50936. * AKA Diffuse Color in other nomenclature.
  50937. */
  50938. protected _albedoColor: Color3;
  50939. /**
  50940. * AKA Specular Color in other nomenclature.
  50941. */
  50942. protected _reflectivityColor: Color3;
  50943. /**
  50944. * The color applied when light is reflected from a material.
  50945. */
  50946. protected _reflectionColor: Color3;
  50947. /**
  50948. * The color applied when light is emitted from a material.
  50949. */
  50950. protected _emissiveColor: Color3;
  50951. /**
  50952. * AKA Glossiness in other nomenclature.
  50953. */
  50954. protected _microSurface: number;
  50955. /**
  50956. * Specifies that the material will use the light map as a show map.
  50957. */
  50958. protected _useLightmapAsShadowmap: boolean;
  50959. /**
  50960. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50961. * makes the reflect vector face the model (under horizon).
  50962. */
  50963. protected _useHorizonOcclusion: boolean;
  50964. /**
  50965. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50966. * too much the area relying on ambient texture to define their ambient occlusion.
  50967. */
  50968. protected _useRadianceOcclusion: boolean;
  50969. /**
  50970. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50971. */
  50972. protected _useAlphaFromAlbedoTexture: boolean;
  50973. /**
  50974. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50975. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50976. */
  50977. protected _useSpecularOverAlpha: boolean;
  50978. /**
  50979. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50980. */
  50981. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50982. /**
  50983. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50984. */
  50985. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50986. /**
  50987. * Specifies if the metallic texture contains the roughness information in its green channel.
  50988. */
  50989. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50990. /**
  50991. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50992. */
  50993. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50994. /**
  50995. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50996. */
  50997. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50998. /**
  50999. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51000. */
  51001. protected _useAmbientInGrayScale: boolean;
  51002. /**
  51003. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51004. * The material will try to infer what glossiness each pixel should be.
  51005. */
  51006. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51007. /**
  51008. * Defines the falloff type used in this material.
  51009. * It by default is Physical.
  51010. */
  51011. protected _lightFalloff: number;
  51012. /**
  51013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51015. */
  51016. protected _useRadianceOverAlpha: boolean;
  51017. /**
  51018. * Allows using an object space normal map (instead of tangent space).
  51019. */
  51020. protected _useObjectSpaceNormalMap: boolean;
  51021. /**
  51022. * Allows using the bump map in parallax mode.
  51023. */
  51024. protected _useParallax: boolean;
  51025. /**
  51026. * Allows using the bump map in parallax occlusion mode.
  51027. */
  51028. protected _useParallaxOcclusion: boolean;
  51029. /**
  51030. * Controls the scale bias of the parallax mode.
  51031. */
  51032. protected _parallaxScaleBias: number;
  51033. /**
  51034. * If sets to true, disables all the lights affecting the material.
  51035. */
  51036. protected _disableLighting: boolean;
  51037. /**
  51038. * Number of Simultaneous lights allowed on the material.
  51039. */
  51040. protected _maxSimultaneousLights: number;
  51041. /**
  51042. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51043. */
  51044. protected _invertNormalMapX: boolean;
  51045. /**
  51046. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51047. */
  51048. protected _invertNormalMapY: boolean;
  51049. /**
  51050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51051. */
  51052. protected _twoSidedLighting: boolean;
  51053. /**
  51054. * Defines the alpha limits in alpha test mode.
  51055. */
  51056. protected _alphaCutOff: number;
  51057. /**
  51058. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51059. */
  51060. protected _forceAlphaTest: boolean;
  51061. /**
  51062. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51063. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51064. */
  51065. protected _useAlphaFresnel: boolean;
  51066. /**
  51067. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51068. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51069. */
  51070. protected _useLinearAlphaFresnel: boolean;
  51071. /**
  51072. * The transparency mode of the material.
  51073. */
  51074. protected _transparencyMode: Nullable<number>;
  51075. /**
  51076. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51077. * from cos thetav and roughness:
  51078. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51079. */
  51080. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51081. /**
  51082. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51083. */
  51084. protected _forceIrradianceInFragment: boolean;
  51085. /**
  51086. * Force normal to face away from face.
  51087. */
  51088. protected _forceNormalForward: boolean;
  51089. /**
  51090. * Enables specular anti aliasing in the PBR shader.
  51091. * It will both interacts on the Geometry for analytical and IBL lighting.
  51092. * It also prefilter the roughness map based on the bump values.
  51093. */
  51094. protected _enableSpecularAntiAliasing: boolean;
  51095. /**
  51096. * Default configuration related to image processing available in the PBR Material.
  51097. */
  51098. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51099. /**
  51100. * Keep track of the image processing observer to allow dispose and replace.
  51101. */
  51102. private _imageProcessingObserver;
  51103. /**
  51104. * Attaches a new image processing configuration to the PBR Material.
  51105. * @param configuration
  51106. */
  51107. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51108. /**
  51109. * Stores the available render targets.
  51110. */
  51111. private _renderTargets;
  51112. /**
  51113. * Sets the global ambient color for the material used in lighting calculations.
  51114. */
  51115. private _globalAmbientColor;
  51116. /**
  51117. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51118. */
  51119. private _useLogarithmicDepth;
  51120. /**
  51121. * If set to true, no lighting calculations will be applied.
  51122. */
  51123. private _unlit;
  51124. private _debugMode;
  51125. /**
  51126. * @hidden
  51127. * This is reserved for the inspector.
  51128. * Defines the material debug mode.
  51129. * It helps seeing only some components of the material while troubleshooting.
  51130. */
  51131. debugMode: number;
  51132. /**
  51133. * @hidden
  51134. * This is reserved for the inspector.
  51135. * Specify from where on screen the debug mode should start.
  51136. * The value goes from -1 (full screen) to 1 (not visible)
  51137. * It helps with side by side comparison against the final render
  51138. * This defaults to -1
  51139. */
  51140. private debugLimit;
  51141. /**
  51142. * @hidden
  51143. * This is reserved for the inspector.
  51144. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51145. * You can use the factor to better multiply the final value.
  51146. */
  51147. private debugFactor;
  51148. /**
  51149. * Defines the clear coat layer parameters for the material.
  51150. */
  51151. readonly clearCoat: PBRClearCoatConfiguration;
  51152. /**
  51153. * Defines the anisotropic parameters for the material.
  51154. */
  51155. readonly anisotropy: PBRAnisotropicConfiguration;
  51156. /**
  51157. * Defines the BRDF parameters for the material.
  51158. */
  51159. readonly brdf: PBRBRDFConfiguration;
  51160. /**
  51161. * Defines the Sheen parameters for the material.
  51162. */
  51163. readonly sheen: PBRSheenConfiguration;
  51164. /**
  51165. * Defines the SubSurface parameters for the material.
  51166. */
  51167. readonly subSurface: PBRSubSurfaceConfiguration;
  51168. /**
  51169. * Custom callback helping to override the default shader used in the material.
  51170. */
  51171. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51172. protected _rebuildInParallel: boolean;
  51173. /**
  51174. * Instantiates a new PBRMaterial instance.
  51175. *
  51176. * @param name The material name
  51177. * @param scene The scene the material will be use in.
  51178. */
  51179. constructor(name: string, scene: Scene);
  51180. /**
  51181. * Gets a boolean indicating that current material needs to register RTT
  51182. */
  51183. readonly hasRenderTargetTextures: boolean;
  51184. /**
  51185. * Gets the name of the material class.
  51186. */
  51187. getClassName(): string;
  51188. /**
  51189. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51190. */
  51191. /**
  51192. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51193. */
  51194. useLogarithmicDepth: boolean;
  51195. /**
  51196. * Gets the current transparency mode.
  51197. */
  51198. /**
  51199. * Sets the transparency mode of the material.
  51200. *
  51201. * | Value | Type | Description |
  51202. * | ----- | ----------------------------------- | ----------- |
  51203. * | 0 | OPAQUE | |
  51204. * | 1 | ALPHATEST | |
  51205. * | 2 | ALPHABLEND | |
  51206. * | 3 | ALPHATESTANDBLEND | |
  51207. *
  51208. */
  51209. transparencyMode: Nullable<number>;
  51210. /**
  51211. * Returns true if alpha blending should be disabled.
  51212. */
  51213. private readonly _disableAlphaBlending;
  51214. /**
  51215. * Specifies whether or not this material should be rendered in alpha blend mode.
  51216. */
  51217. needAlphaBlending(): boolean;
  51218. /**
  51219. * Specifies if the mesh will require alpha blending.
  51220. * @param mesh - BJS mesh.
  51221. */
  51222. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51223. /**
  51224. * Specifies whether or not this material should be rendered in alpha test mode.
  51225. */
  51226. needAlphaTesting(): boolean;
  51227. /**
  51228. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51229. */
  51230. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51231. /**
  51232. * Gets the texture used for the alpha test.
  51233. */
  51234. getAlphaTestTexture(): Nullable<BaseTexture>;
  51235. /**
  51236. * Specifies that the submesh is ready to be used.
  51237. * @param mesh - BJS mesh.
  51238. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51239. * @param useInstances - Specifies that instances should be used.
  51240. * @returns - boolean indicating that the submesh is ready or not.
  51241. */
  51242. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51243. /**
  51244. * Specifies if the material uses metallic roughness workflow.
  51245. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51246. */
  51247. isMetallicWorkflow(): boolean;
  51248. private _prepareEffect;
  51249. private _prepareDefines;
  51250. /**
  51251. * Force shader compilation
  51252. */
  51253. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51254. /**
  51255. * Initializes the uniform buffer layout for the shader.
  51256. */
  51257. buildUniformLayout(): void;
  51258. /**
  51259. * Unbinds the material from the mesh
  51260. */
  51261. unbind(): void;
  51262. /**
  51263. * Binds the submesh data.
  51264. * @param world - The world matrix.
  51265. * @param mesh - The BJS mesh.
  51266. * @param subMesh - A submesh of the BJS mesh.
  51267. */
  51268. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51269. /**
  51270. * Returns the animatable textures.
  51271. * @returns - Array of animatable textures.
  51272. */
  51273. getAnimatables(): IAnimatable[];
  51274. /**
  51275. * Returns the texture used for reflections.
  51276. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51277. */
  51278. private _getReflectionTexture;
  51279. /**
  51280. * Returns an array of the actively used textures.
  51281. * @returns - Array of BaseTextures
  51282. */
  51283. getActiveTextures(): BaseTexture[];
  51284. /**
  51285. * Checks to see if a texture is used in the material.
  51286. * @param texture - Base texture to use.
  51287. * @returns - Boolean specifying if a texture is used in the material.
  51288. */
  51289. hasTexture(texture: BaseTexture): boolean;
  51290. /**
  51291. * Disposes the resources of the material.
  51292. * @param forceDisposeEffect - Forces the disposal of effects.
  51293. * @param forceDisposeTextures - Forces the disposal of all textures.
  51294. */
  51295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51296. }
  51297. }
  51298. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51299. import { Nullable } from "babylonjs/types";
  51300. import { Scene } from "babylonjs/scene";
  51301. import { Color3 } from "babylonjs/Maths/math.color";
  51302. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51303. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51305. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51306. /**
  51307. * The Physically based material of BJS.
  51308. *
  51309. * This offers the main features of a standard PBR material.
  51310. * For more information, please refer to the documentation :
  51311. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51312. */
  51313. export class PBRMaterial extends PBRBaseMaterial {
  51314. /**
  51315. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51316. */
  51317. static readonly PBRMATERIAL_OPAQUE: number;
  51318. /**
  51319. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51320. */
  51321. static readonly PBRMATERIAL_ALPHATEST: number;
  51322. /**
  51323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51324. */
  51325. static readonly PBRMATERIAL_ALPHABLEND: number;
  51326. /**
  51327. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51328. * They are also discarded below the alpha cutoff threshold to improve performances.
  51329. */
  51330. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51331. /**
  51332. * Defines the default value of how much AO map is occluding the analytical lights
  51333. * (point spot...).
  51334. */
  51335. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51336. /**
  51337. * Intensity of the direct lights e.g. the four lights available in your scene.
  51338. * This impacts both the direct diffuse and specular highlights.
  51339. */
  51340. directIntensity: number;
  51341. /**
  51342. * Intensity of the emissive part of the material.
  51343. * This helps controlling the emissive effect without modifying the emissive color.
  51344. */
  51345. emissiveIntensity: number;
  51346. /**
  51347. * Intensity of the environment e.g. how much the environment will light the object
  51348. * either through harmonics for rough material or through the refelction for shiny ones.
  51349. */
  51350. environmentIntensity: number;
  51351. /**
  51352. * This is a special control allowing the reduction of the specular highlights coming from the
  51353. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51354. */
  51355. specularIntensity: number;
  51356. /**
  51357. * Debug Control allowing disabling the bump map on this material.
  51358. */
  51359. disableBumpMap: boolean;
  51360. /**
  51361. * AKA Diffuse Texture in standard nomenclature.
  51362. */
  51363. albedoTexture: BaseTexture;
  51364. /**
  51365. * AKA Occlusion Texture in other nomenclature.
  51366. */
  51367. ambientTexture: BaseTexture;
  51368. /**
  51369. * AKA Occlusion Texture Intensity in other nomenclature.
  51370. */
  51371. ambientTextureStrength: number;
  51372. /**
  51373. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51374. * 1 means it completely occludes it
  51375. * 0 mean it has no impact
  51376. */
  51377. ambientTextureImpactOnAnalyticalLights: number;
  51378. /**
  51379. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51380. */
  51381. opacityTexture: BaseTexture;
  51382. /**
  51383. * Stores the reflection values in a texture.
  51384. */
  51385. reflectionTexture: Nullable<BaseTexture>;
  51386. /**
  51387. * Stores the emissive values in a texture.
  51388. */
  51389. emissiveTexture: BaseTexture;
  51390. /**
  51391. * AKA Specular texture in other nomenclature.
  51392. */
  51393. reflectivityTexture: BaseTexture;
  51394. /**
  51395. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51396. */
  51397. metallicTexture: BaseTexture;
  51398. /**
  51399. * Specifies the metallic scalar of the metallic/roughness workflow.
  51400. * Can also be used to scale the metalness values of the metallic texture.
  51401. */
  51402. metallic: Nullable<number>;
  51403. /**
  51404. * Specifies the roughness scalar of the metallic/roughness workflow.
  51405. * Can also be used to scale the roughness values of the metallic texture.
  51406. */
  51407. roughness: Nullable<number>;
  51408. /**
  51409. * Specifies the an F0 factor to help configuring the material F0.
  51410. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51411. * to 0.5 the previously hard coded value stays the same.
  51412. * Can also be used to scale the F0 values of the metallic texture.
  51413. */
  51414. metallicF0Factor: number;
  51415. /**
  51416. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51417. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51418. * your expectation as it multiplies with the texture data.
  51419. */
  51420. useMetallicF0FactorFromMetallicTexture: boolean;
  51421. /**
  51422. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51423. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51424. */
  51425. microSurfaceTexture: BaseTexture;
  51426. /**
  51427. * Stores surface normal data used to displace a mesh in a texture.
  51428. */
  51429. bumpTexture: BaseTexture;
  51430. /**
  51431. * Stores the pre-calculated light information of a mesh in a texture.
  51432. */
  51433. lightmapTexture: BaseTexture;
  51434. /**
  51435. * Stores the refracted light information in a texture.
  51436. */
  51437. refractionTexture: Nullable<BaseTexture>;
  51438. /**
  51439. * The color of a material in ambient lighting.
  51440. */
  51441. ambientColor: Color3;
  51442. /**
  51443. * AKA Diffuse Color in other nomenclature.
  51444. */
  51445. albedoColor: Color3;
  51446. /**
  51447. * AKA Specular Color in other nomenclature.
  51448. */
  51449. reflectivityColor: Color3;
  51450. /**
  51451. * The color reflected from the material.
  51452. */
  51453. reflectionColor: Color3;
  51454. /**
  51455. * The color emitted from the material.
  51456. */
  51457. emissiveColor: Color3;
  51458. /**
  51459. * AKA Glossiness in other nomenclature.
  51460. */
  51461. microSurface: number;
  51462. /**
  51463. * source material index of refraction (IOR)' / 'destination material IOR.
  51464. */
  51465. indexOfRefraction: number;
  51466. /**
  51467. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51468. */
  51469. invertRefractionY: boolean;
  51470. /**
  51471. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51472. * Materials half opaque for instance using refraction could benefit from this control.
  51473. */
  51474. linkRefractionWithTransparency: boolean;
  51475. /**
  51476. * If true, the light map contains occlusion information instead of lighting info.
  51477. */
  51478. useLightmapAsShadowmap: boolean;
  51479. /**
  51480. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51481. */
  51482. useAlphaFromAlbedoTexture: boolean;
  51483. /**
  51484. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51485. */
  51486. forceAlphaTest: boolean;
  51487. /**
  51488. * Defines the alpha limits in alpha test mode.
  51489. */
  51490. alphaCutOff: number;
  51491. /**
  51492. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51493. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51494. */
  51495. useSpecularOverAlpha: boolean;
  51496. /**
  51497. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51498. */
  51499. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51500. /**
  51501. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51502. */
  51503. useRoughnessFromMetallicTextureAlpha: boolean;
  51504. /**
  51505. * Specifies if the metallic texture contains the roughness information in its green channel.
  51506. */
  51507. useRoughnessFromMetallicTextureGreen: boolean;
  51508. /**
  51509. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51510. */
  51511. useMetallnessFromMetallicTextureBlue: boolean;
  51512. /**
  51513. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51514. */
  51515. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51516. /**
  51517. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51518. */
  51519. useAmbientInGrayScale: boolean;
  51520. /**
  51521. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51522. * The material will try to infer what glossiness each pixel should be.
  51523. */
  51524. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51525. /**
  51526. * BJS is using an harcoded light falloff based on a manually sets up range.
  51527. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51528. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51529. */
  51530. /**
  51531. * BJS is using an harcoded light falloff based on a manually sets up range.
  51532. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51533. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51534. */
  51535. usePhysicalLightFalloff: boolean;
  51536. /**
  51537. * In order to support the falloff compatibility with gltf, a special mode has been added
  51538. * to reproduce the gltf light falloff.
  51539. */
  51540. /**
  51541. * In order to support the falloff compatibility with gltf, a special mode has been added
  51542. * to reproduce the gltf light falloff.
  51543. */
  51544. useGLTFLightFalloff: boolean;
  51545. /**
  51546. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51547. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51548. */
  51549. useRadianceOverAlpha: boolean;
  51550. /**
  51551. * Allows using an object space normal map (instead of tangent space).
  51552. */
  51553. useObjectSpaceNormalMap: boolean;
  51554. /**
  51555. * Allows using the bump map in parallax mode.
  51556. */
  51557. useParallax: boolean;
  51558. /**
  51559. * Allows using the bump map in parallax occlusion mode.
  51560. */
  51561. useParallaxOcclusion: boolean;
  51562. /**
  51563. * Controls the scale bias of the parallax mode.
  51564. */
  51565. parallaxScaleBias: number;
  51566. /**
  51567. * If sets to true, disables all the lights affecting the material.
  51568. */
  51569. disableLighting: boolean;
  51570. /**
  51571. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51572. */
  51573. forceIrradianceInFragment: boolean;
  51574. /**
  51575. * Number of Simultaneous lights allowed on the material.
  51576. */
  51577. maxSimultaneousLights: number;
  51578. /**
  51579. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51580. */
  51581. invertNormalMapX: boolean;
  51582. /**
  51583. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51584. */
  51585. invertNormalMapY: boolean;
  51586. /**
  51587. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51588. */
  51589. twoSidedLighting: boolean;
  51590. /**
  51591. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51592. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51593. */
  51594. useAlphaFresnel: boolean;
  51595. /**
  51596. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51597. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51598. */
  51599. useLinearAlphaFresnel: boolean;
  51600. /**
  51601. * Let user defines the brdf lookup texture used for IBL.
  51602. * A default 8bit version is embedded but you could point at :
  51603. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51604. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51605. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51606. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51607. */
  51608. environmentBRDFTexture: Nullable<BaseTexture>;
  51609. /**
  51610. * Force normal to face away from face.
  51611. */
  51612. forceNormalForward: boolean;
  51613. /**
  51614. * Enables specular anti aliasing in the PBR shader.
  51615. * It will both interacts on the Geometry for analytical and IBL lighting.
  51616. * It also prefilter the roughness map based on the bump values.
  51617. */
  51618. enableSpecularAntiAliasing: boolean;
  51619. /**
  51620. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51621. * makes the reflect vector face the model (under horizon).
  51622. */
  51623. useHorizonOcclusion: boolean;
  51624. /**
  51625. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51626. * too much the area relying on ambient texture to define their ambient occlusion.
  51627. */
  51628. useRadianceOcclusion: boolean;
  51629. /**
  51630. * If set to true, no lighting calculations will be applied.
  51631. */
  51632. unlit: boolean;
  51633. /**
  51634. * Gets the image processing configuration used either in this material.
  51635. */
  51636. /**
  51637. * Sets the Default image processing configuration used either in the this material.
  51638. *
  51639. * If sets to null, the scene one is in use.
  51640. */
  51641. imageProcessingConfiguration: ImageProcessingConfiguration;
  51642. /**
  51643. * Gets wether the color curves effect is enabled.
  51644. */
  51645. /**
  51646. * Sets wether the color curves effect is enabled.
  51647. */
  51648. cameraColorCurvesEnabled: boolean;
  51649. /**
  51650. * Gets wether the color grading effect is enabled.
  51651. */
  51652. /**
  51653. * Gets wether the color grading effect is enabled.
  51654. */
  51655. cameraColorGradingEnabled: boolean;
  51656. /**
  51657. * Gets wether tonemapping is enabled or not.
  51658. */
  51659. /**
  51660. * Sets wether tonemapping is enabled or not
  51661. */
  51662. cameraToneMappingEnabled: boolean;
  51663. /**
  51664. * The camera exposure used on this material.
  51665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51666. * This corresponds to a photographic exposure.
  51667. */
  51668. /**
  51669. * The camera exposure used on this material.
  51670. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51671. * This corresponds to a photographic exposure.
  51672. */
  51673. cameraExposure: number;
  51674. /**
  51675. * Gets The camera contrast used on this material.
  51676. */
  51677. /**
  51678. * Sets The camera contrast used on this material.
  51679. */
  51680. cameraContrast: number;
  51681. /**
  51682. * Gets the Color Grading 2D Lookup Texture.
  51683. */
  51684. /**
  51685. * Sets the Color Grading 2D Lookup Texture.
  51686. */
  51687. cameraColorGradingTexture: Nullable<BaseTexture>;
  51688. /**
  51689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51691. * 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;
  51692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51693. */
  51694. /**
  51695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51697. * 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;
  51698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51699. */
  51700. cameraColorCurves: Nullable<ColorCurves>;
  51701. /**
  51702. * Instantiates a new PBRMaterial instance.
  51703. *
  51704. * @param name The material name
  51705. * @param scene The scene the material will be use in.
  51706. */
  51707. constructor(name: string, scene: Scene);
  51708. /**
  51709. * Returns the name of this material class.
  51710. */
  51711. getClassName(): string;
  51712. /**
  51713. * Makes a duplicate of the current material.
  51714. * @param name - name to use for the new material.
  51715. */
  51716. clone(name: string): PBRMaterial;
  51717. /**
  51718. * Serializes this PBR Material.
  51719. * @returns - An object with the serialized material.
  51720. */
  51721. serialize(): any;
  51722. /**
  51723. * Parses a PBR Material from a serialized object.
  51724. * @param source - Serialized object.
  51725. * @param scene - BJS scene instance.
  51726. * @param rootUrl - url for the scene object
  51727. * @returns - PBRMaterial
  51728. */
  51729. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51730. }
  51731. }
  51732. declare module "babylonjs/Misc/dds" {
  51733. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51735. import { Nullable } from "babylonjs/types";
  51736. import { Scene } from "babylonjs/scene";
  51737. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51738. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51739. /**
  51740. * Direct draw surface info
  51741. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51742. */
  51743. export interface DDSInfo {
  51744. /**
  51745. * Width of the texture
  51746. */
  51747. width: number;
  51748. /**
  51749. * Width of the texture
  51750. */
  51751. height: number;
  51752. /**
  51753. * Number of Mipmaps for the texture
  51754. * @see https://en.wikipedia.org/wiki/Mipmap
  51755. */
  51756. mipmapCount: number;
  51757. /**
  51758. * If the textures format is a known fourCC format
  51759. * @see https://www.fourcc.org/
  51760. */
  51761. isFourCC: boolean;
  51762. /**
  51763. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51764. */
  51765. isRGB: boolean;
  51766. /**
  51767. * If the texture is a lumincance format
  51768. */
  51769. isLuminance: boolean;
  51770. /**
  51771. * If this is a cube texture
  51772. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51773. */
  51774. isCube: boolean;
  51775. /**
  51776. * If the texture is a compressed format eg. FOURCC_DXT1
  51777. */
  51778. isCompressed: boolean;
  51779. /**
  51780. * The dxgiFormat of the texture
  51781. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51782. */
  51783. dxgiFormat: number;
  51784. /**
  51785. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51786. */
  51787. textureType: number;
  51788. /**
  51789. * Sphericle polynomial created for the dds texture
  51790. */
  51791. sphericalPolynomial?: SphericalPolynomial;
  51792. }
  51793. /**
  51794. * Class used to provide DDS decompression tools
  51795. */
  51796. export class DDSTools {
  51797. /**
  51798. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51799. */
  51800. static StoreLODInAlphaChannel: boolean;
  51801. /**
  51802. * Gets DDS information from an array buffer
  51803. * @param arrayBuffer defines the array buffer to read data from
  51804. * @returns the DDS information
  51805. */
  51806. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51807. private static _FloatView;
  51808. private static _Int32View;
  51809. private static _ToHalfFloat;
  51810. private static _FromHalfFloat;
  51811. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51812. private static _GetHalfFloatRGBAArrayBuffer;
  51813. private static _GetFloatRGBAArrayBuffer;
  51814. private static _GetFloatAsUIntRGBAArrayBuffer;
  51815. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51816. private static _GetRGBAArrayBuffer;
  51817. private static _ExtractLongWordOrder;
  51818. private static _GetRGBArrayBuffer;
  51819. private static _GetLuminanceArrayBuffer;
  51820. /**
  51821. * Uploads DDS Levels to a Babylon Texture
  51822. * @hidden
  51823. */
  51824. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51825. }
  51826. module "babylonjs/Engines/thinEngine" {
  51827. interface ThinEngine {
  51828. /**
  51829. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51830. * @param rootUrl defines the url where the file to load is located
  51831. * @param scene defines the current scene
  51832. * @param lodScale defines scale to apply to the mip map selection
  51833. * @param lodOffset defines offset to apply to the mip map selection
  51834. * @param onLoad defines an optional callback raised when the texture is loaded
  51835. * @param onError defines an optional callback raised if there is an issue to load the texture
  51836. * @param format defines the format of the data
  51837. * @param forcedExtension defines the extension to use to pick the right loader
  51838. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51839. * @returns the cube texture as an InternalTexture
  51840. */
  51841. 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;
  51842. }
  51843. }
  51844. }
  51845. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51846. import { Nullable } from "babylonjs/types";
  51847. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51848. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51849. /**
  51850. * Implementation of the DDS Texture Loader.
  51851. * @hidden
  51852. */
  51853. export class _DDSTextureLoader implements IInternalTextureLoader {
  51854. /**
  51855. * Defines wether the loader supports cascade loading the different faces.
  51856. */
  51857. readonly supportCascades: boolean;
  51858. /**
  51859. * This returns if the loader support the current file information.
  51860. * @param extension defines the file extension of the file being loaded
  51861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51862. * @param fallback defines the fallback internal texture if any
  51863. * @param isBase64 defines whether the texture is encoded as a base64
  51864. * @param isBuffer defines whether the texture data are stored as a buffer
  51865. * @returns true if the loader can load the specified file
  51866. */
  51867. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51868. /**
  51869. * Transform the url before loading if required.
  51870. * @param rootUrl the url of the texture
  51871. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51872. * @returns the transformed texture
  51873. */
  51874. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51875. /**
  51876. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51877. * @param rootUrl the url of the texture
  51878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51879. * @returns the fallback texture
  51880. */
  51881. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51882. /**
  51883. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51884. * @param data contains the texture data
  51885. * @param texture defines the BabylonJS internal texture
  51886. * @param createPolynomials will be true if polynomials have been requested
  51887. * @param onLoad defines the callback to trigger once the texture is ready
  51888. * @param onError defines the callback to trigger in case of error
  51889. */
  51890. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51891. /**
  51892. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51893. * @param data contains the texture data
  51894. * @param texture defines the BabylonJS internal texture
  51895. * @param callback defines the method to call once ready to upload
  51896. */
  51897. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51898. }
  51899. }
  51900. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51901. import { Nullable } from "babylonjs/types";
  51902. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51903. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51904. /**
  51905. * Implementation of the ENV Texture Loader.
  51906. * @hidden
  51907. */
  51908. export class _ENVTextureLoader implements IInternalTextureLoader {
  51909. /**
  51910. * Defines wether the loader supports cascade loading the different faces.
  51911. */
  51912. readonly supportCascades: boolean;
  51913. /**
  51914. * This returns if the loader support the current file information.
  51915. * @param extension defines the file extension of the file being loaded
  51916. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51917. * @param fallback defines the fallback internal texture if any
  51918. * @param isBase64 defines whether the texture is encoded as a base64
  51919. * @param isBuffer defines whether the texture data are stored as a buffer
  51920. * @returns true if the loader can load the specified file
  51921. */
  51922. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51923. /**
  51924. * Transform the url before loading if required.
  51925. * @param rootUrl the url of the texture
  51926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51927. * @returns the transformed texture
  51928. */
  51929. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51930. /**
  51931. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51932. * @param rootUrl the url of the texture
  51933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51934. * @returns the fallback texture
  51935. */
  51936. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51937. /**
  51938. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51939. * @param data contains the texture data
  51940. * @param texture defines the BabylonJS internal texture
  51941. * @param createPolynomials will be true if polynomials have been requested
  51942. * @param onLoad defines the callback to trigger once the texture is ready
  51943. * @param onError defines the callback to trigger in case of error
  51944. */
  51945. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51946. /**
  51947. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51948. * @param data contains the texture data
  51949. * @param texture defines the BabylonJS internal texture
  51950. * @param callback defines the method to call once ready to upload
  51951. */
  51952. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51953. }
  51954. }
  51955. declare module "babylonjs/Misc/khronosTextureContainer" {
  51956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51957. /**
  51958. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51959. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51960. */
  51961. export class KhronosTextureContainer {
  51962. /** contents of the KTX container file */
  51963. arrayBuffer: any;
  51964. private static HEADER_LEN;
  51965. private static COMPRESSED_2D;
  51966. private static COMPRESSED_3D;
  51967. private static TEX_2D;
  51968. private static TEX_3D;
  51969. /**
  51970. * Gets the openGL type
  51971. */
  51972. glType: number;
  51973. /**
  51974. * Gets the openGL type size
  51975. */
  51976. glTypeSize: number;
  51977. /**
  51978. * Gets the openGL format
  51979. */
  51980. glFormat: number;
  51981. /**
  51982. * Gets the openGL internal format
  51983. */
  51984. glInternalFormat: number;
  51985. /**
  51986. * Gets the base internal format
  51987. */
  51988. glBaseInternalFormat: number;
  51989. /**
  51990. * Gets image width in pixel
  51991. */
  51992. pixelWidth: number;
  51993. /**
  51994. * Gets image height in pixel
  51995. */
  51996. pixelHeight: number;
  51997. /**
  51998. * Gets image depth in pixels
  51999. */
  52000. pixelDepth: number;
  52001. /**
  52002. * Gets the number of array elements
  52003. */
  52004. numberOfArrayElements: number;
  52005. /**
  52006. * Gets the number of faces
  52007. */
  52008. numberOfFaces: number;
  52009. /**
  52010. * Gets the number of mipmap levels
  52011. */
  52012. numberOfMipmapLevels: number;
  52013. /**
  52014. * Gets the bytes of key value data
  52015. */
  52016. bytesOfKeyValueData: number;
  52017. /**
  52018. * Gets the load type
  52019. */
  52020. loadType: number;
  52021. /**
  52022. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52023. */
  52024. isInvalid: boolean;
  52025. /**
  52026. * Creates a new KhronosTextureContainer
  52027. * @param arrayBuffer contents of the KTX container file
  52028. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52029. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52030. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52031. */
  52032. constructor(
  52033. /** contents of the KTX container file */
  52034. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52035. /**
  52036. * Uploads KTX content to a Babylon Texture.
  52037. * It is assumed that the texture has already been created & is currently bound
  52038. * @hidden
  52039. */
  52040. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52041. private _upload2DCompressedLevels;
  52042. }
  52043. }
  52044. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52045. import { Nullable } from "babylonjs/types";
  52046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52047. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52048. /**
  52049. * Implementation of the KTX Texture Loader.
  52050. * @hidden
  52051. */
  52052. export class _KTXTextureLoader implements IInternalTextureLoader {
  52053. /**
  52054. * Defines wether the loader supports cascade loading the different faces.
  52055. */
  52056. readonly supportCascades: boolean;
  52057. /**
  52058. * This returns if the loader support the current file information.
  52059. * @param extension defines the file extension of the file being loaded
  52060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52061. * @param fallback defines the fallback internal texture if any
  52062. * @param isBase64 defines whether the texture is encoded as a base64
  52063. * @param isBuffer defines whether the texture data are stored as a buffer
  52064. * @returns true if the loader can load the specified file
  52065. */
  52066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52067. /**
  52068. * Transform the url before loading if required.
  52069. * @param rootUrl the url of the texture
  52070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52071. * @returns the transformed texture
  52072. */
  52073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52074. /**
  52075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52076. * @param rootUrl the url of the texture
  52077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52078. * @returns the fallback texture
  52079. */
  52080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52081. /**
  52082. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52083. * @param data contains the texture data
  52084. * @param texture defines the BabylonJS internal texture
  52085. * @param createPolynomials will be true if polynomials have been requested
  52086. * @param onLoad defines the callback to trigger once the texture is ready
  52087. * @param onError defines the callback to trigger in case of error
  52088. */
  52089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52090. /**
  52091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52092. * @param data contains the texture data
  52093. * @param texture defines the BabylonJS internal texture
  52094. * @param callback defines the method to call once ready to upload
  52095. */
  52096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52097. }
  52098. }
  52099. declare module "babylonjs/Helpers/sceneHelpers" {
  52100. import { Nullable } from "babylonjs/types";
  52101. import { Mesh } from "babylonjs/Meshes/mesh";
  52102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52103. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52104. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52105. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52106. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52107. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52108. import "babylonjs/Meshes/Builders/boxBuilder";
  52109. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52110. /** @hidden */
  52111. export var _forceSceneHelpersToBundle: boolean;
  52112. module "babylonjs/scene" {
  52113. interface Scene {
  52114. /**
  52115. * Creates a default light for the scene.
  52116. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52117. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52118. */
  52119. createDefaultLight(replace?: boolean): void;
  52120. /**
  52121. * Creates a default camera for the scene.
  52122. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52123. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52124. * @param replace has default false, when true replaces the active camera in the scene
  52125. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52126. */
  52127. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52128. /**
  52129. * Creates a default camera and a default light.
  52130. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52131. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52132. * @param replace has the default false, when true replaces the active camera/light in the scene
  52133. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52134. */
  52135. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52136. /**
  52137. * Creates a new sky box
  52138. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52139. * @param environmentTexture defines the texture to use as environment texture
  52140. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52141. * @param scale defines the overall scale of the skybox
  52142. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52143. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52144. * @returns a new mesh holding the sky box
  52145. */
  52146. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52147. /**
  52148. * Creates a new environment
  52149. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52150. * @param options defines the options you can use to configure the environment
  52151. * @returns the new EnvironmentHelper
  52152. */
  52153. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52154. /**
  52155. * Creates a new VREXperienceHelper
  52156. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52157. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52158. * @returns a new VREXperienceHelper
  52159. */
  52160. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52161. /**
  52162. * Creates a new WebXRDefaultExperience
  52163. * @see http://doc.babylonjs.com/how_to/webxr
  52164. * @param options experience options
  52165. * @returns a promise for a new WebXRDefaultExperience
  52166. */
  52167. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52168. }
  52169. }
  52170. }
  52171. declare module "babylonjs/Helpers/videoDome" {
  52172. import { Scene } from "babylonjs/scene";
  52173. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52174. import { Mesh } from "babylonjs/Meshes/mesh";
  52175. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52176. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52177. import "babylonjs/Meshes/Builders/sphereBuilder";
  52178. /**
  52179. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52180. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52181. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52182. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52183. */
  52184. export class VideoDome extends TransformNode {
  52185. /**
  52186. * Define the video source as a Monoscopic panoramic 360 video.
  52187. */
  52188. static readonly MODE_MONOSCOPIC: number;
  52189. /**
  52190. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52191. */
  52192. static readonly MODE_TOPBOTTOM: number;
  52193. /**
  52194. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52195. */
  52196. static readonly MODE_SIDEBYSIDE: number;
  52197. private _halfDome;
  52198. private _useDirectMapping;
  52199. /**
  52200. * The video texture being displayed on the sphere
  52201. */
  52202. protected _videoTexture: VideoTexture;
  52203. /**
  52204. * Gets the video texture being displayed on the sphere
  52205. */
  52206. readonly videoTexture: VideoTexture;
  52207. /**
  52208. * The skybox material
  52209. */
  52210. protected _material: BackgroundMaterial;
  52211. /**
  52212. * The surface used for the skybox
  52213. */
  52214. protected _mesh: Mesh;
  52215. /**
  52216. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52217. */
  52218. private _halfDomeMask;
  52219. /**
  52220. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52221. * Also see the options.resolution property.
  52222. */
  52223. fovMultiplier: number;
  52224. private _videoMode;
  52225. /**
  52226. * Gets or set the current video mode for the video. It can be:
  52227. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52228. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52229. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52230. */
  52231. videoMode: number;
  52232. /**
  52233. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52234. *
  52235. */
  52236. /**
  52237. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52238. */
  52239. halfDome: boolean;
  52240. /**
  52241. * Oberserver used in Stereoscopic VR Mode.
  52242. */
  52243. private _onBeforeCameraRenderObserver;
  52244. /**
  52245. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52246. * @param name Element's name, child elements will append suffixes for their own names.
  52247. * @param urlsOrVideo defines the url(s) or the video element to use
  52248. * @param options An object containing optional or exposed sub element properties
  52249. */
  52250. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52251. resolution?: number;
  52252. clickToPlay?: boolean;
  52253. autoPlay?: boolean;
  52254. loop?: boolean;
  52255. size?: number;
  52256. poster?: string;
  52257. faceForward?: boolean;
  52258. useDirectMapping?: boolean;
  52259. halfDomeMode?: boolean;
  52260. }, scene: Scene);
  52261. private _changeVideoMode;
  52262. /**
  52263. * Releases resources associated with this node.
  52264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52266. */
  52267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52268. }
  52269. }
  52270. declare module "babylonjs/Helpers/index" {
  52271. export * from "babylonjs/Helpers/environmentHelper";
  52272. export * from "babylonjs/Helpers/photoDome";
  52273. export * from "babylonjs/Helpers/sceneHelpers";
  52274. export * from "babylonjs/Helpers/videoDome";
  52275. }
  52276. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52277. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52278. import { IDisposable } from "babylonjs/scene";
  52279. import { Engine } from "babylonjs/Engines/engine";
  52280. /**
  52281. * This class can be used to get instrumentation data from a Babylon engine
  52282. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52283. */
  52284. export class EngineInstrumentation implements IDisposable {
  52285. /**
  52286. * Define the instrumented engine.
  52287. */
  52288. engine: Engine;
  52289. private _captureGPUFrameTime;
  52290. private _gpuFrameTimeToken;
  52291. private _gpuFrameTime;
  52292. private _captureShaderCompilationTime;
  52293. private _shaderCompilationTime;
  52294. private _onBeginFrameObserver;
  52295. private _onEndFrameObserver;
  52296. private _onBeforeShaderCompilationObserver;
  52297. private _onAfterShaderCompilationObserver;
  52298. /**
  52299. * Gets the perf counter used for GPU frame time
  52300. */
  52301. readonly gpuFrameTimeCounter: PerfCounter;
  52302. /**
  52303. * Gets the GPU frame time capture status
  52304. */
  52305. /**
  52306. * Enable or disable the GPU frame time capture
  52307. */
  52308. captureGPUFrameTime: boolean;
  52309. /**
  52310. * Gets the perf counter used for shader compilation time
  52311. */
  52312. readonly shaderCompilationTimeCounter: PerfCounter;
  52313. /**
  52314. * Gets the shader compilation time capture status
  52315. */
  52316. /**
  52317. * Enable or disable the shader compilation time capture
  52318. */
  52319. captureShaderCompilationTime: boolean;
  52320. /**
  52321. * Instantiates a new engine instrumentation.
  52322. * This class can be used to get instrumentation data from a Babylon engine
  52323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52324. * @param engine Defines the engine to instrument
  52325. */
  52326. constructor(
  52327. /**
  52328. * Define the instrumented engine.
  52329. */
  52330. engine: Engine);
  52331. /**
  52332. * Dispose and release associated resources.
  52333. */
  52334. dispose(): void;
  52335. }
  52336. }
  52337. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52338. import { Scene, IDisposable } from "babylonjs/scene";
  52339. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52340. /**
  52341. * This class can be used to get instrumentation data from a Babylon engine
  52342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52343. */
  52344. export class SceneInstrumentation implements IDisposable {
  52345. /**
  52346. * Defines the scene to instrument
  52347. */
  52348. scene: Scene;
  52349. private _captureActiveMeshesEvaluationTime;
  52350. private _activeMeshesEvaluationTime;
  52351. private _captureRenderTargetsRenderTime;
  52352. private _renderTargetsRenderTime;
  52353. private _captureFrameTime;
  52354. private _frameTime;
  52355. private _captureRenderTime;
  52356. private _renderTime;
  52357. private _captureInterFrameTime;
  52358. private _interFrameTime;
  52359. private _captureParticlesRenderTime;
  52360. private _particlesRenderTime;
  52361. private _captureSpritesRenderTime;
  52362. private _spritesRenderTime;
  52363. private _capturePhysicsTime;
  52364. private _physicsTime;
  52365. private _captureAnimationsTime;
  52366. private _animationsTime;
  52367. private _captureCameraRenderTime;
  52368. private _cameraRenderTime;
  52369. private _onBeforeActiveMeshesEvaluationObserver;
  52370. private _onAfterActiveMeshesEvaluationObserver;
  52371. private _onBeforeRenderTargetsRenderObserver;
  52372. private _onAfterRenderTargetsRenderObserver;
  52373. private _onAfterRenderObserver;
  52374. private _onBeforeDrawPhaseObserver;
  52375. private _onAfterDrawPhaseObserver;
  52376. private _onBeforeAnimationsObserver;
  52377. private _onBeforeParticlesRenderingObserver;
  52378. private _onAfterParticlesRenderingObserver;
  52379. private _onBeforeSpritesRenderingObserver;
  52380. private _onAfterSpritesRenderingObserver;
  52381. private _onBeforePhysicsObserver;
  52382. private _onAfterPhysicsObserver;
  52383. private _onAfterAnimationsObserver;
  52384. private _onBeforeCameraRenderObserver;
  52385. private _onAfterCameraRenderObserver;
  52386. /**
  52387. * Gets the perf counter used for active meshes evaluation time
  52388. */
  52389. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52390. /**
  52391. * Gets the active meshes evaluation time capture status
  52392. */
  52393. /**
  52394. * Enable or disable the active meshes evaluation time capture
  52395. */
  52396. captureActiveMeshesEvaluationTime: boolean;
  52397. /**
  52398. * Gets the perf counter used for render targets render time
  52399. */
  52400. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52401. /**
  52402. * Gets the render targets render time capture status
  52403. */
  52404. /**
  52405. * Enable or disable the render targets render time capture
  52406. */
  52407. captureRenderTargetsRenderTime: boolean;
  52408. /**
  52409. * Gets the perf counter used for particles render time
  52410. */
  52411. readonly particlesRenderTimeCounter: PerfCounter;
  52412. /**
  52413. * Gets the particles render time capture status
  52414. */
  52415. /**
  52416. * Enable or disable the particles render time capture
  52417. */
  52418. captureParticlesRenderTime: boolean;
  52419. /**
  52420. * Gets the perf counter used for sprites render time
  52421. */
  52422. readonly spritesRenderTimeCounter: PerfCounter;
  52423. /**
  52424. * Gets the sprites render time capture status
  52425. */
  52426. /**
  52427. * Enable or disable the sprites render time capture
  52428. */
  52429. captureSpritesRenderTime: boolean;
  52430. /**
  52431. * Gets the perf counter used for physics time
  52432. */
  52433. readonly physicsTimeCounter: PerfCounter;
  52434. /**
  52435. * Gets the physics time capture status
  52436. */
  52437. /**
  52438. * Enable or disable the physics time capture
  52439. */
  52440. capturePhysicsTime: boolean;
  52441. /**
  52442. * Gets the perf counter used for animations time
  52443. */
  52444. readonly animationsTimeCounter: PerfCounter;
  52445. /**
  52446. * Gets the animations time capture status
  52447. */
  52448. /**
  52449. * Enable or disable the animations time capture
  52450. */
  52451. captureAnimationsTime: boolean;
  52452. /**
  52453. * Gets the perf counter used for frame time capture
  52454. */
  52455. readonly frameTimeCounter: PerfCounter;
  52456. /**
  52457. * Gets the frame time capture status
  52458. */
  52459. /**
  52460. * Enable or disable the frame time capture
  52461. */
  52462. captureFrameTime: boolean;
  52463. /**
  52464. * Gets the perf counter used for inter-frames time capture
  52465. */
  52466. readonly interFrameTimeCounter: PerfCounter;
  52467. /**
  52468. * Gets the inter-frames time capture status
  52469. */
  52470. /**
  52471. * Enable or disable the inter-frames time capture
  52472. */
  52473. captureInterFrameTime: boolean;
  52474. /**
  52475. * Gets the perf counter used for render time capture
  52476. */
  52477. readonly renderTimeCounter: PerfCounter;
  52478. /**
  52479. * Gets the render time capture status
  52480. */
  52481. /**
  52482. * Enable or disable the render time capture
  52483. */
  52484. captureRenderTime: boolean;
  52485. /**
  52486. * Gets the perf counter used for camera render time capture
  52487. */
  52488. readonly cameraRenderTimeCounter: PerfCounter;
  52489. /**
  52490. * Gets the camera render time capture status
  52491. */
  52492. /**
  52493. * Enable or disable the camera render time capture
  52494. */
  52495. captureCameraRenderTime: boolean;
  52496. /**
  52497. * Gets the perf counter used for draw calls
  52498. */
  52499. readonly drawCallsCounter: PerfCounter;
  52500. /**
  52501. * Instantiates a new scene instrumentation.
  52502. * This class can be used to get instrumentation data from a Babylon engine
  52503. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52504. * @param scene Defines the scene to instrument
  52505. */
  52506. constructor(
  52507. /**
  52508. * Defines the scene to instrument
  52509. */
  52510. scene: Scene);
  52511. /**
  52512. * Dispose and release associated resources.
  52513. */
  52514. dispose(): void;
  52515. }
  52516. }
  52517. declare module "babylonjs/Instrumentation/index" {
  52518. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52519. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52520. export * from "babylonjs/Instrumentation/timeToken";
  52521. }
  52522. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52523. /** @hidden */
  52524. export var glowMapGenerationPixelShader: {
  52525. name: string;
  52526. shader: string;
  52527. };
  52528. }
  52529. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52535. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52537. /** @hidden */
  52538. export var glowMapGenerationVertexShader: {
  52539. name: string;
  52540. shader: string;
  52541. };
  52542. }
  52543. declare module "babylonjs/Layers/effectLayer" {
  52544. import { Observable } from "babylonjs/Misc/observable";
  52545. import { Nullable } from "babylonjs/types";
  52546. import { Camera } from "babylonjs/Cameras/camera";
  52547. import { Scene } from "babylonjs/scene";
  52548. import { ISize } from "babylonjs/Maths/math.size";
  52549. import { Color4 } from "babylonjs/Maths/math.color";
  52550. import { Engine } from "babylonjs/Engines/engine";
  52551. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52553. import { Mesh } from "babylonjs/Meshes/mesh";
  52554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52557. import { Effect } from "babylonjs/Materials/effect";
  52558. import { Material } from "babylonjs/Materials/material";
  52559. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52560. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52561. /**
  52562. * Effect layer options. This helps customizing the behaviour
  52563. * of the effect layer.
  52564. */
  52565. export interface IEffectLayerOptions {
  52566. /**
  52567. * Multiplication factor apply to the canvas size to compute the render target size
  52568. * used to generated the objects (the smaller the faster).
  52569. */
  52570. mainTextureRatio: number;
  52571. /**
  52572. * Enforces a fixed size texture to ensure effect stability across devices.
  52573. */
  52574. mainTextureFixedSize?: number;
  52575. /**
  52576. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52577. */
  52578. alphaBlendingMode: number;
  52579. /**
  52580. * The camera attached to the layer.
  52581. */
  52582. camera: Nullable<Camera>;
  52583. /**
  52584. * The rendering group to draw the layer in.
  52585. */
  52586. renderingGroupId: number;
  52587. }
  52588. /**
  52589. * The effect layer Helps adding post process effect blended with the main pass.
  52590. *
  52591. * This can be for instance use to generate glow or higlight effects on the scene.
  52592. *
  52593. * The effect layer class can not be used directly and is intented to inherited from to be
  52594. * customized per effects.
  52595. */
  52596. export abstract class EffectLayer {
  52597. private _vertexBuffers;
  52598. private _indexBuffer;
  52599. private _cachedDefines;
  52600. private _effectLayerMapGenerationEffect;
  52601. private _effectLayerOptions;
  52602. private _mergeEffect;
  52603. protected _scene: Scene;
  52604. protected _engine: Engine;
  52605. protected _maxSize: number;
  52606. protected _mainTextureDesiredSize: ISize;
  52607. protected _mainTexture: RenderTargetTexture;
  52608. protected _shouldRender: boolean;
  52609. protected _postProcesses: PostProcess[];
  52610. protected _textures: BaseTexture[];
  52611. protected _emissiveTextureAndColor: {
  52612. texture: Nullable<BaseTexture>;
  52613. color: Color4;
  52614. };
  52615. /**
  52616. * The name of the layer
  52617. */
  52618. name: string;
  52619. /**
  52620. * The clear color of the texture used to generate the glow map.
  52621. */
  52622. neutralColor: Color4;
  52623. /**
  52624. * Specifies wether the highlight layer is enabled or not.
  52625. */
  52626. isEnabled: boolean;
  52627. /**
  52628. * Gets the camera attached to the layer.
  52629. */
  52630. readonly camera: Nullable<Camera>;
  52631. /**
  52632. * Gets the rendering group id the layer should render in.
  52633. */
  52634. renderingGroupId: number;
  52635. /**
  52636. * An event triggered when the effect layer has been disposed.
  52637. */
  52638. onDisposeObservable: Observable<EffectLayer>;
  52639. /**
  52640. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52641. */
  52642. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52643. /**
  52644. * An event triggered when the generated texture is being merged in the scene.
  52645. */
  52646. onBeforeComposeObservable: Observable<EffectLayer>;
  52647. /**
  52648. * An event triggered when the mesh is rendered into the effect render target.
  52649. */
  52650. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52651. /**
  52652. * An event triggered after the mesh has been rendered into the effect render target.
  52653. */
  52654. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52655. /**
  52656. * An event triggered when the generated texture has been merged in the scene.
  52657. */
  52658. onAfterComposeObservable: Observable<EffectLayer>;
  52659. /**
  52660. * An event triggered when the efffect layer changes its size.
  52661. */
  52662. onSizeChangedObservable: Observable<EffectLayer>;
  52663. /** @hidden */
  52664. static _SceneComponentInitialization: (scene: Scene) => void;
  52665. /**
  52666. * Instantiates a new effect Layer and references it in the scene.
  52667. * @param name The name of the layer
  52668. * @param scene The scene to use the layer in
  52669. */
  52670. constructor(
  52671. /** The Friendly of the effect in the scene */
  52672. name: string, scene: Scene);
  52673. /**
  52674. * Get the effect name of the layer.
  52675. * @return The effect name
  52676. */
  52677. abstract getEffectName(): string;
  52678. /**
  52679. * Checks for the readiness of the element composing the layer.
  52680. * @param subMesh the mesh to check for
  52681. * @param useInstances specify wether or not to use instances to render the mesh
  52682. * @return true if ready otherwise, false
  52683. */
  52684. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52685. /**
  52686. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52687. * @returns true if the effect requires stencil during the main canvas render pass.
  52688. */
  52689. abstract needStencil(): boolean;
  52690. /**
  52691. * Create the merge effect. This is the shader use to blit the information back
  52692. * to the main canvas at the end of the scene rendering.
  52693. * @returns The effect containing the shader used to merge the effect on the main canvas
  52694. */
  52695. protected abstract _createMergeEffect(): Effect;
  52696. /**
  52697. * Creates the render target textures and post processes used in the effect layer.
  52698. */
  52699. protected abstract _createTextureAndPostProcesses(): void;
  52700. /**
  52701. * Implementation specific of rendering the generating effect on the main canvas.
  52702. * @param effect The effect used to render through
  52703. */
  52704. protected abstract _internalRender(effect: Effect): void;
  52705. /**
  52706. * Sets the required values for both the emissive texture and and the main color.
  52707. */
  52708. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52709. /**
  52710. * Free any resources and references associated to a mesh.
  52711. * Internal use
  52712. * @param mesh The mesh to free.
  52713. */
  52714. abstract _disposeMesh(mesh: Mesh): void;
  52715. /**
  52716. * Serializes this layer (Glow or Highlight for example)
  52717. * @returns a serialized layer object
  52718. */
  52719. abstract serialize?(): any;
  52720. /**
  52721. * Initializes the effect layer with the required options.
  52722. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52723. */
  52724. protected _init(options: Partial<IEffectLayerOptions>): void;
  52725. /**
  52726. * Generates the index buffer of the full screen quad blending to the main canvas.
  52727. */
  52728. private _generateIndexBuffer;
  52729. /**
  52730. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52731. */
  52732. private _generateVertexBuffer;
  52733. /**
  52734. * Sets the main texture desired size which is the closest power of two
  52735. * of the engine canvas size.
  52736. */
  52737. private _setMainTextureSize;
  52738. /**
  52739. * Creates the main texture for the effect layer.
  52740. */
  52741. protected _createMainTexture(): void;
  52742. /**
  52743. * Adds specific effects defines.
  52744. * @param defines The defines to add specifics to.
  52745. */
  52746. protected _addCustomEffectDefines(defines: string[]): void;
  52747. /**
  52748. * Checks for the readiness of the element composing the layer.
  52749. * @param subMesh the mesh to check for
  52750. * @param useInstances specify wether or not to use instances to render the mesh
  52751. * @param emissiveTexture the associated emissive texture used to generate the glow
  52752. * @return true if ready otherwise, false
  52753. */
  52754. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52755. /**
  52756. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52757. */
  52758. render(): void;
  52759. /**
  52760. * Determine if a given mesh will be used in the current effect.
  52761. * @param mesh mesh to test
  52762. * @returns true if the mesh will be used
  52763. */
  52764. hasMesh(mesh: AbstractMesh): boolean;
  52765. /**
  52766. * Returns true if the layer contains information to display, otherwise false.
  52767. * @returns true if the glow layer should be rendered
  52768. */
  52769. shouldRender(): boolean;
  52770. /**
  52771. * Returns true if the mesh should render, otherwise false.
  52772. * @param mesh The mesh to render
  52773. * @returns true if it should render otherwise false
  52774. */
  52775. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52776. /**
  52777. * Returns true if the mesh can be rendered, otherwise false.
  52778. * @param mesh The mesh to render
  52779. * @param material The material used on the mesh
  52780. * @returns true if it can be rendered otherwise false
  52781. */
  52782. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52783. /**
  52784. * Returns true if the mesh should render, otherwise false.
  52785. * @param mesh The mesh to render
  52786. * @returns true if it should render otherwise false
  52787. */
  52788. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52789. /**
  52790. * Renders the submesh passed in parameter to the generation map.
  52791. */
  52792. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52793. /**
  52794. * Defines wether the current material of the mesh should be use to render the effect.
  52795. * @param mesh defines the current mesh to render
  52796. */
  52797. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52798. /**
  52799. * Rebuild the required buffers.
  52800. * @hidden Internal use only.
  52801. */
  52802. _rebuild(): void;
  52803. /**
  52804. * Dispose only the render target textures and post process.
  52805. */
  52806. private _disposeTextureAndPostProcesses;
  52807. /**
  52808. * Dispose the highlight layer and free resources.
  52809. */
  52810. dispose(): void;
  52811. /**
  52812. * Gets the class name of the effect layer
  52813. * @returns the string with the class name of the effect layer
  52814. */
  52815. getClassName(): string;
  52816. /**
  52817. * Creates an effect layer from parsed effect layer data
  52818. * @param parsedEffectLayer defines effect layer data
  52819. * @param scene defines the current scene
  52820. * @param rootUrl defines the root URL containing the effect layer information
  52821. * @returns a parsed effect Layer
  52822. */
  52823. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52824. }
  52825. }
  52826. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52827. import { Scene } from "babylonjs/scene";
  52828. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52829. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52830. import { AbstractScene } from "babylonjs/abstractScene";
  52831. module "babylonjs/abstractScene" {
  52832. interface AbstractScene {
  52833. /**
  52834. * The list of effect layers (highlights/glow) added to the scene
  52835. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52836. * @see http://doc.babylonjs.com/how_to/glow_layer
  52837. */
  52838. effectLayers: Array<EffectLayer>;
  52839. /**
  52840. * Removes the given effect layer from this scene.
  52841. * @param toRemove defines the effect layer to remove
  52842. * @returns the index of the removed effect layer
  52843. */
  52844. removeEffectLayer(toRemove: EffectLayer): number;
  52845. /**
  52846. * Adds the given effect layer to this scene
  52847. * @param newEffectLayer defines the effect layer to add
  52848. */
  52849. addEffectLayer(newEffectLayer: EffectLayer): void;
  52850. }
  52851. }
  52852. /**
  52853. * Defines the layer scene component responsible to manage any effect layers
  52854. * in a given scene.
  52855. */
  52856. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52857. /**
  52858. * The component name helpfull to identify the component in the list of scene components.
  52859. */
  52860. readonly name: string;
  52861. /**
  52862. * The scene the component belongs to.
  52863. */
  52864. scene: Scene;
  52865. private _engine;
  52866. private _renderEffects;
  52867. private _needStencil;
  52868. private _previousStencilState;
  52869. /**
  52870. * Creates a new instance of the component for the given scene
  52871. * @param scene Defines the scene to register the component in
  52872. */
  52873. constructor(scene: Scene);
  52874. /**
  52875. * Registers the component in a given scene
  52876. */
  52877. register(): void;
  52878. /**
  52879. * Rebuilds the elements related to this component in case of
  52880. * context lost for instance.
  52881. */
  52882. rebuild(): void;
  52883. /**
  52884. * Serializes the component data to the specified json object
  52885. * @param serializationObject The object to serialize to
  52886. */
  52887. serialize(serializationObject: any): void;
  52888. /**
  52889. * Adds all the elements from the container to the scene
  52890. * @param container the container holding the elements
  52891. */
  52892. addFromContainer(container: AbstractScene): void;
  52893. /**
  52894. * Removes all the elements in the container from the scene
  52895. * @param container contains the elements to remove
  52896. * @param dispose if the removed element should be disposed (default: false)
  52897. */
  52898. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52899. /**
  52900. * Disposes the component and the associated ressources.
  52901. */
  52902. dispose(): void;
  52903. private _isReadyForMesh;
  52904. private _renderMainTexture;
  52905. private _setStencil;
  52906. private _setStencilBack;
  52907. private _draw;
  52908. private _drawCamera;
  52909. private _drawRenderingGroup;
  52910. }
  52911. }
  52912. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52913. /** @hidden */
  52914. export var glowMapMergePixelShader: {
  52915. name: string;
  52916. shader: string;
  52917. };
  52918. }
  52919. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52920. /** @hidden */
  52921. export var glowMapMergeVertexShader: {
  52922. name: string;
  52923. shader: string;
  52924. };
  52925. }
  52926. declare module "babylonjs/Layers/glowLayer" {
  52927. import { Nullable } from "babylonjs/types";
  52928. import { Camera } from "babylonjs/Cameras/camera";
  52929. import { Scene } from "babylonjs/scene";
  52930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52932. import { Mesh } from "babylonjs/Meshes/mesh";
  52933. import { Texture } from "babylonjs/Materials/Textures/texture";
  52934. import { Effect } from "babylonjs/Materials/effect";
  52935. import { Material } from "babylonjs/Materials/material";
  52936. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52937. import { Color4 } from "babylonjs/Maths/math.color";
  52938. import "babylonjs/Shaders/glowMapMerge.fragment";
  52939. import "babylonjs/Shaders/glowMapMerge.vertex";
  52940. import "babylonjs/Layers/effectLayerSceneComponent";
  52941. module "babylonjs/abstractScene" {
  52942. interface AbstractScene {
  52943. /**
  52944. * Return a the first highlight layer of the scene with a given name.
  52945. * @param name The name of the highlight layer to look for.
  52946. * @return The highlight layer if found otherwise null.
  52947. */
  52948. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52949. }
  52950. }
  52951. /**
  52952. * Glow layer options. This helps customizing the behaviour
  52953. * of the glow layer.
  52954. */
  52955. export interface IGlowLayerOptions {
  52956. /**
  52957. * Multiplication factor apply to the canvas size to compute the render target size
  52958. * used to generated the glowing objects (the smaller the faster).
  52959. */
  52960. mainTextureRatio: number;
  52961. /**
  52962. * Enforces a fixed size texture to ensure resize independant blur.
  52963. */
  52964. mainTextureFixedSize?: number;
  52965. /**
  52966. * How big is the kernel of the blur texture.
  52967. */
  52968. blurKernelSize: number;
  52969. /**
  52970. * The camera attached to the layer.
  52971. */
  52972. camera: Nullable<Camera>;
  52973. /**
  52974. * Enable MSAA by chosing the number of samples.
  52975. */
  52976. mainTextureSamples?: number;
  52977. /**
  52978. * The rendering group to draw the layer in.
  52979. */
  52980. renderingGroupId: number;
  52981. }
  52982. /**
  52983. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52984. *
  52985. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52986. *
  52987. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52988. */
  52989. export class GlowLayer extends EffectLayer {
  52990. /**
  52991. * Effect Name of the layer.
  52992. */
  52993. static readonly EffectName: string;
  52994. /**
  52995. * The default blur kernel size used for the glow.
  52996. */
  52997. static DefaultBlurKernelSize: number;
  52998. /**
  52999. * The default texture size ratio used for the glow.
  53000. */
  53001. static DefaultTextureRatio: number;
  53002. /**
  53003. * Sets the kernel size of the blur.
  53004. */
  53005. /**
  53006. * Gets the kernel size of the blur.
  53007. */
  53008. blurKernelSize: number;
  53009. /**
  53010. * Sets the glow intensity.
  53011. */
  53012. /**
  53013. * Gets the glow intensity.
  53014. */
  53015. intensity: number;
  53016. private _options;
  53017. private _intensity;
  53018. private _horizontalBlurPostprocess1;
  53019. private _verticalBlurPostprocess1;
  53020. private _horizontalBlurPostprocess2;
  53021. private _verticalBlurPostprocess2;
  53022. private _blurTexture1;
  53023. private _blurTexture2;
  53024. private _postProcesses1;
  53025. private _postProcesses2;
  53026. private _includedOnlyMeshes;
  53027. private _excludedMeshes;
  53028. private _meshesUsingTheirOwnMaterials;
  53029. /**
  53030. * Callback used to let the user override the color selection on a per mesh basis
  53031. */
  53032. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53033. /**
  53034. * Callback used to let the user override the texture selection on a per mesh basis
  53035. */
  53036. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53037. /**
  53038. * Instantiates a new glow Layer and references it to the scene.
  53039. * @param name The name of the layer
  53040. * @param scene The scene to use the layer in
  53041. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53042. */
  53043. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53044. /**
  53045. * Get the effect name of the layer.
  53046. * @return The effect name
  53047. */
  53048. getEffectName(): string;
  53049. /**
  53050. * Create the merge effect. This is the shader use to blit the information back
  53051. * to the main canvas at the end of the scene rendering.
  53052. */
  53053. protected _createMergeEffect(): Effect;
  53054. /**
  53055. * Creates the render target textures and post processes used in the glow layer.
  53056. */
  53057. protected _createTextureAndPostProcesses(): void;
  53058. /**
  53059. * Checks for the readiness of the element composing the layer.
  53060. * @param subMesh the mesh to check for
  53061. * @param useInstances specify wether or not to use instances to render the mesh
  53062. * @param emissiveTexture the associated emissive texture used to generate the glow
  53063. * @return true if ready otherwise, false
  53064. */
  53065. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53066. /**
  53067. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53068. */
  53069. needStencil(): boolean;
  53070. /**
  53071. * Returns true if the mesh can be rendered, otherwise false.
  53072. * @param mesh The mesh to render
  53073. * @param material The material used on the mesh
  53074. * @returns true if it can be rendered otherwise false
  53075. */
  53076. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53077. /**
  53078. * Implementation specific of rendering the generating effect on the main canvas.
  53079. * @param effect The effect used to render through
  53080. */
  53081. protected _internalRender(effect: Effect): void;
  53082. /**
  53083. * Sets the required values for both the emissive texture and and the main color.
  53084. */
  53085. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53086. /**
  53087. * Returns true if the mesh should render, otherwise false.
  53088. * @param mesh The mesh to render
  53089. * @returns true if it should render otherwise false
  53090. */
  53091. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53092. /**
  53093. * Adds specific effects defines.
  53094. * @param defines The defines to add specifics to.
  53095. */
  53096. protected _addCustomEffectDefines(defines: string[]): void;
  53097. /**
  53098. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53099. * @param mesh The mesh to exclude from the glow layer
  53100. */
  53101. addExcludedMesh(mesh: Mesh): void;
  53102. /**
  53103. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53104. * @param mesh The mesh to remove
  53105. */
  53106. removeExcludedMesh(mesh: Mesh): void;
  53107. /**
  53108. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53109. * @param mesh The mesh to include in the glow layer
  53110. */
  53111. addIncludedOnlyMesh(mesh: Mesh): void;
  53112. /**
  53113. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53114. * @param mesh The mesh to remove
  53115. */
  53116. removeIncludedOnlyMesh(mesh: Mesh): void;
  53117. /**
  53118. * Determine if a given mesh will be used in the glow layer
  53119. * @param mesh The mesh to test
  53120. * @returns true if the mesh will be highlighted by the current glow layer
  53121. */
  53122. hasMesh(mesh: AbstractMesh): boolean;
  53123. /**
  53124. * Defines wether the current material of the mesh should be use to render the effect.
  53125. * @param mesh defines the current mesh to render
  53126. */
  53127. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53128. /**
  53129. * Add a mesh to be rendered through its own material and not with emissive only.
  53130. * @param mesh The mesh for which we need to use its material
  53131. */
  53132. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53133. /**
  53134. * Remove a mesh from being rendered through its own material and not with emissive only.
  53135. * @param mesh The mesh for which we need to not use its material
  53136. */
  53137. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53138. /**
  53139. * Free any resources and references associated to a mesh.
  53140. * Internal use
  53141. * @param mesh The mesh to free.
  53142. * @hidden
  53143. */
  53144. _disposeMesh(mesh: Mesh): void;
  53145. /**
  53146. * Gets the class name of the effect layer
  53147. * @returns the string with the class name of the effect layer
  53148. */
  53149. getClassName(): string;
  53150. /**
  53151. * Serializes this glow layer
  53152. * @returns a serialized glow layer object
  53153. */
  53154. serialize(): any;
  53155. /**
  53156. * Creates a Glow Layer from parsed glow layer data
  53157. * @param parsedGlowLayer defines glow layer data
  53158. * @param scene defines the current scene
  53159. * @param rootUrl defines the root URL containing the glow layer information
  53160. * @returns a parsed Glow Layer
  53161. */
  53162. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53163. }
  53164. }
  53165. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53166. /** @hidden */
  53167. export var glowBlurPostProcessPixelShader: {
  53168. name: string;
  53169. shader: string;
  53170. };
  53171. }
  53172. declare module "babylonjs/Layers/highlightLayer" {
  53173. import { Observable } from "babylonjs/Misc/observable";
  53174. import { Nullable } from "babylonjs/types";
  53175. import { Camera } from "babylonjs/Cameras/camera";
  53176. import { Scene } from "babylonjs/scene";
  53177. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53179. import { Mesh } from "babylonjs/Meshes/mesh";
  53180. import { Effect } from "babylonjs/Materials/effect";
  53181. import { Material } from "babylonjs/Materials/material";
  53182. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53183. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53184. import "babylonjs/Shaders/glowMapMerge.fragment";
  53185. import "babylonjs/Shaders/glowMapMerge.vertex";
  53186. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53187. module "babylonjs/abstractScene" {
  53188. interface AbstractScene {
  53189. /**
  53190. * Return a the first highlight layer of the scene with a given name.
  53191. * @param name The name of the highlight layer to look for.
  53192. * @return The highlight layer if found otherwise null.
  53193. */
  53194. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53195. }
  53196. }
  53197. /**
  53198. * Highlight layer options. This helps customizing the behaviour
  53199. * of the highlight layer.
  53200. */
  53201. export interface IHighlightLayerOptions {
  53202. /**
  53203. * Multiplication factor apply to the canvas size to compute the render target size
  53204. * used to generated the glowing objects (the smaller the faster).
  53205. */
  53206. mainTextureRatio: number;
  53207. /**
  53208. * Enforces a fixed size texture to ensure resize independant blur.
  53209. */
  53210. mainTextureFixedSize?: number;
  53211. /**
  53212. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53213. * of the picture to blur (the smaller the faster).
  53214. */
  53215. blurTextureSizeRatio: number;
  53216. /**
  53217. * How big in texel of the blur texture is the vertical blur.
  53218. */
  53219. blurVerticalSize: number;
  53220. /**
  53221. * How big in texel of the blur texture is the horizontal blur.
  53222. */
  53223. blurHorizontalSize: number;
  53224. /**
  53225. * Alpha blending mode used to apply the blur. Default is combine.
  53226. */
  53227. alphaBlendingMode: number;
  53228. /**
  53229. * The camera attached to the layer.
  53230. */
  53231. camera: Nullable<Camera>;
  53232. /**
  53233. * Should we display highlight as a solid stroke?
  53234. */
  53235. isStroke?: boolean;
  53236. /**
  53237. * The rendering group to draw the layer in.
  53238. */
  53239. renderingGroupId: number;
  53240. }
  53241. /**
  53242. * The highlight layer Helps adding a glow effect around a mesh.
  53243. *
  53244. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53245. * glowy meshes to your scene.
  53246. *
  53247. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53248. */
  53249. export class HighlightLayer extends EffectLayer {
  53250. name: string;
  53251. /**
  53252. * Effect Name of the highlight layer.
  53253. */
  53254. static readonly EffectName: string;
  53255. /**
  53256. * The neutral color used during the preparation of the glow effect.
  53257. * This is black by default as the blend operation is a blend operation.
  53258. */
  53259. static NeutralColor: Color4;
  53260. /**
  53261. * Stencil value used for glowing meshes.
  53262. */
  53263. static GlowingMeshStencilReference: number;
  53264. /**
  53265. * Stencil value used for the other meshes in the scene.
  53266. */
  53267. static NormalMeshStencilReference: number;
  53268. /**
  53269. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53270. */
  53271. innerGlow: boolean;
  53272. /**
  53273. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53274. */
  53275. outerGlow: boolean;
  53276. /**
  53277. * Specifies the horizontal size of the blur.
  53278. */
  53279. /**
  53280. * Gets the horizontal size of the blur.
  53281. */
  53282. blurHorizontalSize: number;
  53283. /**
  53284. * Specifies the vertical size of the blur.
  53285. */
  53286. /**
  53287. * Gets the vertical size of the blur.
  53288. */
  53289. blurVerticalSize: number;
  53290. /**
  53291. * An event triggered when the highlight layer is being blurred.
  53292. */
  53293. onBeforeBlurObservable: Observable<HighlightLayer>;
  53294. /**
  53295. * An event triggered when the highlight layer has been blurred.
  53296. */
  53297. onAfterBlurObservable: Observable<HighlightLayer>;
  53298. private _instanceGlowingMeshStencilReference;
  53299. private _options;
  53300. private _downSamplePostprocess;
  53301. private _horizontalBlurPostprocess;
  53302. private _verticalBlurPostprocess;
  53303. private _blurTexture;
  53304. private _meshes;
  53305. private _excludedMeshes;
  53306. /**
  53307. * Instantiates a new highlight Layer and references it to the scene..
  53308. * @param name The name of the layer
  53309. * @param scene The scene to use the layer in
  53310. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53311. */
  53312. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53313. /**
  53314. * Get the effect name of the layer.
  53315. * @return The effect name
  53316. */
  53317. getEffectName(): string;
  53318. /**
  53319. * Create the merge effect. This is the shader use to blit the information back
  53320. * to the main canvas at the end of the scene rendering.
  53321. */
  53322. protected _createMergeEffect(): Effect;
  53323. /**
  53324. * Creates the render target textures and post processes used in the highlight layer.
  53325. */
  53326. protected _createTextureAndPostProcesses(): void;
  53327. /**
  53328. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53329. */
  53330. needStencil(): boolean;
  53331. /**
  53332. * Checks for the readiness of the element composing the layer.
  53333. * @param subMesh the mesh to check for
  53334. * @param useInstances specify wether or not to use instances to render the mesh
  53335. * @param emissiveTexture the associated emissive texture used to generate the glow
  53336. * @return true if ready otherwise, false
  53337. */
  53338. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53339. /**
  53340. * Implementation specific of rendering the generating effect on the main canvas.
  53341. * @param effect The effect used to render through
  53342. */
  53343. protected _internalRender(effect: Effect): void;
  53344. /**
  53345. * Returns true if the layer contains information to display, otherwise false.
  53346. */
  53347. shouldRender(): boolean;
  53348. /**
  53349. * Returns true if the mesh should render, otherwise false.
  53350. * @param mesh The mesh to render
  53351. * @returns true if it should render otherwise false
  53352. */
  53353. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53354. /**
  53355. * Sets the required values for both the emissive texture and and the main color.
  53356. */
  53357. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53358. /**
  53359. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53360. * @param mesh The mesh to exclude from the highlight layer
  53361. */
  53362. addExcludedMesh(mesh: Mesh): void;
  53363. /**
  53364. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53365. * @param mesh The mesh to highlight
  53366. */
  53367. removeExcludedMesh(mesh: Mesh): void;
  53368. /**
  53369. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53370. * @param mesh mesh to test
  53371. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53372. */
  53373. hasMesh(mesh: AbstractMesh): boolean;
  53374. /**
  53375. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53376. * @param mesh The mesh to highlight
  53377. * @param color The color of the highlight
  53378. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53379. */
  53380. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53381. /**
  53382. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53383. * @param mesh The mesh to highlight
  53384. */
  53385. removeMesh(mesh: Mesh): void;
  53386. /**
  53387. * Force the stencil to the normal expected value for none glowing parts
  53388. */
  53389. private _defaultStencilReference;
  53390. /**
  53391. * Free any resources and references associated to a mesh.
  53392. * Internal use
  53393. * @param mesh The mesh to free.
  53394. * @hidden
  53395. */
  53396. _disposeMesh(mesh: Mesh): void;
  53397. /**
  53398. * Dispose the highlight layer and free resources.
  53399. */
  53400. dispose(): void;
  53401. /**
  53402. * Gets the class name of the effect layer
  53403. * @returns the string with the class name of the effect layer
  53404. */
  53405. getClassName(): string;
  53406. /**
  53407. * Serializes this Highlight layer
  53408. * @returns a serialized Highlight layer object
  53409. */
  53410. serialize(): any;
  53411. /**
  53412. * Creates a Highlight layer from parsed Highlight layer data
  53413. * @param parsedHightlightLayer defines the Highlight layer data
  53414. * @param scene defines the current scene
  53415. * @param rootUrl defines the root URL containing the Highlight layer information
  53416. * @returns a parsed Highlight layer
  53417. */
  53418. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53419. }
  53420. }
  53421. declare module "babylonjs/Layers/layerSceneComponent" {
  53422. import { Scene } from "babylonjs/scene";
  53423. import { ISceneComponent } from "babylonjs/sceneComponent";
  53424. import { Layer } from "babylonjs/Layers/layer";
  53425. import { AbstractScene } from "babylonjs/abstractScene";
  53426. module "babylonjs/abstractScene" {
  53427. interface AbstractScene {
  53428. /**
  53429. * The list of layers (background and foreground) of the scene
  53430. */
  53431. layers: Array<Layer>;
  53432. }
  53433. }
  53434. /**
  53435. * Defines the layer scene component responsible to manage any layers
  53436. * in a given scene.
  53437. */
  53438. export class LayerSceneComponent implements ISceneComponent {
  53439. /**
  53440. * The component name helpfull to identify the component in the list of scene components.
  53441. */
  53442. readonly name: string;
  53443. /**
  53444. * The scene the component belongs to.
  53445. */
  53446. scene: Scene;
  53447. private _engine;
  53448. /**
  53449. * Creates a new instance of the component for the given scene
  53450. * @param scene Defines the scene to register the component in
  53451. */
  53452. constructor(scene: Scene);
  53453. /**
  53454. * Registers the component in a given scene
  53455. */
  53456. register(): void;
  53457. /**
  53458. * Rebuilds the elements related to this component in case of
  53459. * context lost for instance.
  53460. */
  53461. rebuild(): void;
  53462. /**
  53463. * Disposes the component and the associated ressources.
  53464. */
  53465. dispose(): void;
  53466. private _draw;
  53467. private _drawCameraPredicate;
  53468. private _drawCameraBackground;
  53469. private _drawCameraForeground;
  53470. private _drawRenderTargetPredicate;
  53471. private _drawRenderTargetBackground;
  53472. private _drawRenderTargetForeground;
  53473. /**
  53474. * Adds all the elements from the container to the scene
  53475. * @param container the container holding the elements
  53476. */
  53477. addFromContainer(container: AbstractScene): void;
  53478. /**
  53479. * Removes all the elements in the container from the scene
  53480. * @param container contains the elements to remove
  53481. * @param dispose if the removed element should be disposed (default: false)
  53482. */
  53483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53484. }
  53485. }
  53486. declare module "babylonjs/Shaders/layer.fragment" {
  53487. /** @hidden */
  53488. export var layerPixelShader: {
  53489. name: string;
  53490. shader: string;
  53491. };
  53492. }
  53493. declare module "babylonjs/Shaders/layer.vertex" {
  53494. /** @hidden */
  53495. export var layerVertexShader: {
  53496. name: string;
  53497. shader: string;
  53498. };
  53499. }
  53500. declare module "babylonjs/Layers/layer" {
  53501. import { Observable } from "babylonjs/Misc/observable";
  53502. import { Nullable } from "babylonjs/types";
  53503. import { Scene } from "babylonjs/scene";
  53504. import { Vector2 } from "babylonjs/Maths/math.vector";
  53505. import { Color4 } from "babylonjs/Maths/math.color";
  53506. import { Texture } from "babylonjs/Materials/Textures/texture";
  53507. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53508. import "babylonjs/Shaders/layer.fragment";
  53509. import "babylonjs/Shaders/layer.vertex";
  53510. /**
  53511. * This represents a full screen 2d layer.
  53512. * This can be useful to display a picture in the background of your scene for instance.
  53513. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53514. */
  53515. export class Layer {
  53516. /**
  53517. * Define the name of the layer.
  53518. */
  53519. name: string;
  53520. /**
  53521. * Define the texture the layer should display.
  53522. */
  53523. texture: Nullable<Texture>;
  53524. /**
  53525. * Is the layer in background or foreground.
  53526. */
  53527. isBackground: boolean;
  53528. /**
  53529. * Define the color of the layer (instead of texture).
  53530. */
  53531. color: Color4;
  53532. /**
  53533. * Define the scale of the layer in order to zoom in out of the texture.
  53534. */
  53535. scale: Vector2;
  53536. /**
  53537. * Define an offset for the layer in order to shift the texture.
  53538. */
  53539. offset: Vector2;
  53540. /**
  53541. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53542. */
  53543. alphaBlendingMode: number;
  53544. /**
  53545. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53546. * Alpha test will not mix with the background color in case of transparency.
  53547. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53548. */
  53549. alphaTest: boolean;
  53550. /**
  53551. * Define a mask to restrict the layer to only some of the scene cameras.
  53552. */
  53553. layerMask: number;
  53554. /**
  53555. * Define the list of render target the layer is visible into.
  53556. */
  53557. renderTargetTextures: RenderTargetTexture[];
  53558. /**
  53559. * Define if the layer is only used in renderTarget or if it also
  53560. * renders in the main frame buffer of the canvas.
  53561. */
  53562. renderOnlyInRenderTargetTextures: boolean;
  53563. private _scene;
  53564. private _vertexBuffers;
  53565. private _indexBuffer;
  53566. private _effect;
  53567. private _alphaTestEffect;
  53568. /**
  53569. * An event triggered when the layer is disposed.
  53570. */
  53571. onDisposeObservable: Observable<Layer>;
  53572. private _onDisposeObserver;
  53573. /**
  53574. * Back compatibility with callback before the onDisposeObservable existed.
  53575. * The set callback will be triggered when the layer has been disposed.
  53576. */
  53577. onDispose: () => void;
  53578. /**
  53579. * An event triggered before rendering the scene
  53580. */
  53581. onBeforeRenderObservable: Observable<Layer>;
  53582. private _onBeforeRenderObserver;
  53583. /**
  53584. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53585. * The set callback will be triggered just before rendering the layer.
  53586. */
  53587. onBeforeRender: () => void;
  53588. /**
  53589. * An event triggered after rendering the scene
  53590. */
  53591. onAfterRenderObservable: Observable<Layer>;
  53592. private _onAfterRenderObserver;
  53593. /**
  53594. * Back compatibility with callback before the onAfterRenderObservable existed.
  53595. * The set callback will be triggered just after rendering the layer.
  53596. */
  53597. onAfterRender: () => void;
  53598. /**
  53599. * Instantiates a new layer.
  53600. * This represents a full screen 2d layer.
  53601. * This can be useful to display a picture in the background of your scene for instance.
  53602. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53603. * @param name Define the name of the layer in the scene
  53604. * @param imgUrl Define the url of the texture to display in the layer
  53605. * @param scene Define the scene the layer belongs to
  53606. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53607. * @param color Defines a color for the layer
  53608. */
  53609. constructor(
  53610. /**
  53611. * Define the name of the layer.
  53612. */
  53613. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53614. private _createIndexBuffer;
  53615. /** @hidden */
  53616. _rebuild(): void;
  53617. /**
  53618. * Renders the layer in the scene.
  53619. */
  53620. render(): void;
  53621. /**
  53622. * Disposes and releases the associated ressources.
  53623. */
  53624. dispose(): void;
  53625. }
  53626. }
  53627. declare module "babylonjs/Layers/index" {
  53628. export * from "babylonjs/Layers/effectLayer";
  53629. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53630. export * from "babylonjs/Layers/glowLayer";
  53631. export * from "babylonjs/Layers/highlightLayer";
  53632. export * from "babylonjs/Layers/layer";
  53633. export * from "babylonjs/Layers/layerSceneComponent";
  53634. }
  53635. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53636. /** @hidden */
  53637. export var lensFlarePixelShader: {
  53638. name: string;
  53639. shader: string;
  53640. };
  53641. }
  53642. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53643. /** @hidden */
  53644. export var lensFlareVertexShader: {
  53645. name: string;
  53646. shader: string;
  53647. };
  53648. }
  53649. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53650. import { Scene } from "babylonjs/scene";
  53651. import { Vector3 } from "babylonjs/Maths/math.vector";
  53652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53653. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53654. import "babylonjs/Shaders/lensFlare.fragment";
  53655. import "babylonjs/Shaders/lensFlare.vertex";
  53656. import { Viewport } from "babylonjs/Maths/math.viewport";
  53657. /**
  53658. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53659. * It is usually composed of several `lensFlare`.
  53660. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53661. */
  53662. export class LensFlareSystem {
  53663. /**
  53664. * Define the name of the lens flare system
  53665. */
  53666. name: string;
  53667. /**
  53668. * List of lens flares used in this system.
  53669. */
  53670. lensFlares: LensFlare[];
  53671. /**
  53672. * Define a limit from the border the lens flare can be visible.
  53673. */
  53674. borderLimit: number;
  53675. /**
  53676. * Define a viewport border we do not want to see the lens flare in.
  53677. */
  53678. viewportBorder: number;
  53679. /**
  53680. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53681. */
  53682. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53683. /**
  53684. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53685. */
  53686. layerMask: number;
  53687. /**
  53688. * Define the id of the lens flare system in the scene.
  53689. * (equal to name by default)
  53690. */
  53691. id: string;
  53692. private _scene;
  53693. private _emitter;
  53694. private _vertexBuffers;
  53695. private _indexBuffer;
  53696. private _effect;
  53697. private _positionX;
  53698. private _positionY;
  53699. private _isEnabled;
  53700. /** @hidden */
  53701. static _SceneComponentInitialization: (scene: Scene) => void;
  53702. /**
  53703. * Instantiates a lens flare system.
  53704. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53705. * It is usually composed of several `lensFlare`.
  53706. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53707. * @param name Define the name of the lens flare system in the scene
  53708. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53709. * @param scene Define the scene the lens flare system belongs to
  53710. */
  53711. constructor(
  53712. /**
  53713. * Define the name of the lens flare system
  53714. */
  53715. name: string, emitter: any, scene: Scene);
  53716. /**
  53717. * Define if the lens flare system is enabled.
  53718. */
  53719. isEnabled: boolean;
  53720. /**
  53721. * Get the scene the effects belongs to.
  53722. * @returns the scene holding the lens flare system
  53723. */
  53724. getScene(): Scene;
  53725. /**
  53726. * Get the emitter of the lens flare system.
  53727. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53728. * @returns the emitter of the lens flare system
  53729. */
  53730. getEmitter(): any;
  53731. /**
  53732. * Set the emitter of the lens flare system.
  53733. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53734. * @param newEmitter Define the new emitter of the system
  53735. */
  53736. setEmitter(newEmitter: any): void;
  53737. /**
  53738. * Get the lens flare system emitter position.
  53739. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53740. * @returns the position
  53741. */
  53742. getEmitterPosition(): Vector3;
  53743. /**
  53744. * @hidden
  53745. */
  53746. computeEffectivePosition(globalViewport: Viewport): boolean;
  53747. /** @hidden */
  53748. _isVisible(): boolean;
  53749. /**
  53750. * @hidden
  53751. */
  53752. render(): boolean;
  53753. /**
  53754. * Dispose and release the lens flare with its associated resources.
  53755. */
  53756. dispose(): void;
  53757. /**
  53758. * Parse a lens flare system from a JSON repressentation
  53759. * @param parsedLensFlareSystem Define the JSON to parse
  53760. * @param scene Define the scene the parsed system should be instantiated in
  53761. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53762. * @returns the parsed system
  53763. */
  53764. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53765. /**
  53766. * Serialize the current Lens Flare System into a JSON representation.
  53767. * @returns the serialized JSON
  53768. */
  53769. serialize(): any;
  53770. }
  53771. }
  53772. declare module "babylonjs/LensFlares/lensFlare" {
  53773. import { Nullable } from "babylonjs/types";
  53774. import { Color3 } from "babylonjs/Maths/math.color";
  53775. import { Texture } from "babylonjs/Materials/Textures/texture";
  53776. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53777. /**
  53778. * This represents one of the lens effect in a `lensFlareSystem`.
  53779. * It controls one of the indiviual texture used in the effect.
  53780. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53781. */
  53782. export class LensFlare {
  53783. /**
  53784. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53785. */
  53786. size: number;
  53787. /**
  53788. * 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.
  53789. */
  53790. position: number;
  53791. /**
  53792. * Define the lens color.
  53793. */
  53794. color: Color3;
  53795. /**
  53796. * Define the lens texture.
  53797. */
  53798. texture: Nullable<Texture>;
  53799. /**
  53800. * Define the alpha mode to render this particular lens.
  53801. */
  53802. alphaMode: number;
  53803. private _system;
  53804. /**
  53805. * Creates a new Lens Flare.
  53806. * This represents one of the lens effect in a `lensFlareSystem`.
  53807. * It controls one of the indiviual texture used in the effect.
  53808. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53809. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53810. * @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.
  53811. * @param color Define the lens color
  53812. * @param imgUrl Define the lens texture url
  53813. * @param system Define the `lensFlareSystem` this flare is part of
  53814. * @returns The newly created Lens Flare
  53815. */
  53816. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53817. /**
  53818. * Instantiates a new Lens Flare.
  53819. * This represents one of the lens effect in a `lensFlareSystem`.
  53820. * It controls one of the indiviual texture used in the effect.
  53821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53822. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53823. * @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.
  53824. * @param color Define the lens color
  53825. * @param imgUrl Define the lens texture url
  53826. * @param system Define the `lensFlareSystem` this flare is part of
  53827. */
  53828. constructor(
  53829. /**
  53830. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53831. */
  53832. size: number,
  53833. /**
  53834. * 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.
  53835. */
  53836. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53837. /**
  53838. * Dispose and release the lens flare with its associated resources.
  53839. */
  53840. dispose(): void;
  53841. }
  53842. }
  53843. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53844. import { Nullable } from "babylonjs/types";
  53845. import { Scene } from "babylonjs/scene";
  53846. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53847. import { AbstractScene } from "babylonjs/abstractScene";
  53848. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53849. module "babylonjs/abstractScene" {
  53850. interface AbstractScene {
  53851. /**
  53852. * The list of lens flare system added to the scene
  53853. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53854. */
  53855. lensFlareSystems: Array<LensFlareSystem>;
  53856. /**
  53857. * Removes the given lens flare system from this scene.
  53858. * @param toRemove The lens flare system to remove
  53859. * @returns The index of the removed lens flare system
  53860. */
  53861. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53862. /**
  53863. * Adds the given lens flare system to this scene
  53864. * @param newLensFlareSystem The lens flare system to add
  53865. */
  53866. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53867. /**
  53868. * Gets a lens flare system using its name
  53869. * @param name defines the name to look for
  53870. * @returns the lens flare system or null if not found
  53871. */
  53872. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53873. /**
  53874. * Gets a lens flare system using its id
  53875. * @param id defines the id to look for
  53876. * @returns the lens flare system or null if not found
  53877. */
  53878. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53879. }
  53880. }
  53881. /**
  53882. * Defines the lens flare scene component responsible to manage any lens flares
  53883. * in a given scene.
  53884. */
  53885. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53886. /**
  53887. * The component name helpfull to identify the component in the list of scene components.
  53888. */
  53889. readonly name: string;
  53890. /**
  53891. * The scene the component belongs to.
  53892. */
  53893. scene: Scene;
  53894. /**
  53895. * Creates a new instance of the component for the given scene
  53896. * @param scene Defines the scene to register the component in
  53897. */
  53898. constructor(scene: Scene);
  53899. /**
  53900. * Registers the component in a given scene
  53901. */
  53902. register(): void;
  53903. /**
  53904. * Rebuilds the elements related to this component in case of
  53905. * context lost for instance.
  53906. */
  53907. rebuild(): void;
  53908. /**
  53909. * Adds all the elements from the container to the scene
  53910. * @param container the container holding the elements
  53911. */
  53912. addFromContainer(container: AbstractScene): void;
  53913. /**
  53914. * Removes all the elements in the container from the scene
  53915. * @param container contains the elements to remove
  53916. * @param dispose if the removed element should be disposed (default: false)
  53917. */
  53918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53919. /**
  53920. * Serializes the component data to the specified json object
  53921. * @param serializationObject The object to serialize to
  53922. */
  53923. serialize(serializationObject: any): void;
  53924. /**
  53925. * Disposes the component and the associated ressources.
  53926. */
  53927. dispose(): void;
  53928. private _draw;
  53929. }
  53930. }
  53931. declare module "babylonjs/LensFlares/index" {
  53932. export * from "babylonjs/LensFlares/lensFlare";
  53933. export * from "babylonjs/LensFlares/lensFlareSystem";
  53934. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53935. }
  53936. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53937. import { Scene } from "babylonjs/scene";
  53938. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53939. import { AbstractScene } from "babylonjs/abstractScene";
  53940. /**
  53941. * Defines the shadow generator component responsible to manage any shadow generators
  53942. * in a given scene.
  53943. */
  53944. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53945. /**
  53946. * The component name helpfull to identify the component in the list of scene components.
  53947. */
  53948. readonly name: string;
  53949. /**
  53950. * The scene the component belongs to.
  53951. */
  53952. scene: Scene;
  53953. /**
  53954. * Creates a new instance of the component for the given scene
  53955. * @param scene Defines the scene to register the component in
  53956. */
  53957. constructor(scene: Scene);
  53958. /**
  53959. * Registers the component in a given scene
  53960. */
  53961. register(): void;
  53962. /**
  53963. * Rebuilds the elements related to this component in case of
  53964. * context lost for instance.
  53965. */
  53966. rebuild(): void;
  53967. /**
  53968. * Serializes the component data to the specified json object
  53969. * @param serializationObject The object to serialize to
  53970. */
  53971. serialize(serializationObject: any): void;
  53972. /**
  53973. * Adds all the elements from the container to the scene
  53974. * @param container the container holding the elements
  53975. */
  53976. addFromContainer(container: AbstractScene): void;
  53977. /**
  53978. * Removes all the elements in the container from the scene
  53979. * @param container contains the elements to remove
  53980. * @param dispose if the removed element should be disposed (default: false)
  53981. */
  53982. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53983. /**
  53984. * Rebuilds the elements related to this component in case of
  53985. * context lost for instance.
  53986. */
  53987. dispose(): void;
  53988. private _gatherRenderTargets;
  53989. }
  53990. }
  53991. declare module "babylonjs/Lights/Shadows/index" {
  53992. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53993. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53994. }
  53995. declare module "babylonjs/Lights/pointLight" {
  53996. import { Scene } from "babylonjs/scene";
  53997. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53999. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54000. import { Effect } from "babylonjs/Materials/effect";
  54001. /**
  54002. * A point light is a light defined by an unique point in world space.
  54003. * The light is emitted in every direction from this point.
  54004. * A good example of a point light is a standard light bulb.
  54005. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54006. */
  54007. export class PointLight extends ShadowLight {
  54008. private _shadowAngle;
  54009. /**
  54010. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54011. * This specifies what angle the shadow will use to be created.
  54012. *
  54013. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54014. */
  54015. /**
  54016. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54017. * This specifies what angle the shadow will use to be created.
  54018. *
  54019. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54020. */
  54021. shadowAngle: number;
  54022. /**
  54023. * Gets the direction if it has been set.
  54024. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54025. */
  54026. /**
  54027. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54028. */
  54029. direction: Vector3;
  54030. /**
  54031. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54032. * A PointLight emits the light in every direction.
  54033. * It can cast shadows.
  54034. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54035. * ```javascript
  54036. * var pointLight = new PointLight("pl", camera.position, scene);
  54037. * ```
  54038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54039. * @param name The light friendly name
  54040. * @param position The position of the point light in the scene
  54041. * @param scene The scene the lights belongs to
  54042. */
  54043. constructor(name: string, position: Vector3, scene: Scene);
  54044. /**
  54045. * Returns the string "PointLight"
  54046. * @returns the class name
  54047. */
  54048. getClassName(): string;
  54049. /**
  54050. * Returns the integer 0.
  54051. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54052. */
  54053. getTypeID(): number;
  54054. /**
  54055. * Specifies wether or not the shadowmap should be a cube texture.
  54056. * @returns true if the shadowmap needs to be a cube texture.
  54057. */
  54058. needCube(): boolean;
  54059. /**
  54060. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54063. */
  54064. getShadowDirection(faceIndex?: number): Vector3;
  54065. /**
  54066. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54067. * - fov = PI / 2
  54068. * - aspect ratio : 1.0
  54069. * - z-near and far equal to the active camera minZ and maxZ.
  54070. * Returns the PointLight.
  54071. */
  54072. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54073. protected _buildUniformLayout(): void;
  54074. /**
  54075. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54076. * @param effect The effect to update
  54077. * @param lightIndex The index of the light in the effect to update
  54078. * @returns The point light
  54079. */
  54080. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54081. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54082. /**
  54083. * Prepares the list of defines specific to the light type.
  54084. * @param defines the list of defines
  54085. * @param lightIndex defines the index of the light for the effect
  54086. */
  54087. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54088. }
  54089. }
  54090. declare module "babylonjs/Lights/index" {
  54091. export * from "babylonjs/Lights/light";
  54092. export * from "babylonjs/Lights/shadowLight";
  54093. export * from "babylonjs/Lights/Shadows/index";
  54094. export * from "babylonjs/Lights/directionalLight";
  54095. export * from "babylonjs/Lights/hemisphericLight";
  54096. export * from "babylonjs/Lights/pointLight";
  54097. export * from "babylonjs/Lights/spotLight";
  54098. }
  54099. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54100. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54101. /**
  54102. * Header information of HDR texture files.
  54103. */
  54104. export interface HDRInfo {
  54105. /**
  54106. * The height of the texture in pixels.
  54107. */
  54108. height: number;
  54109. /**
  54110. * The width of the texture in pixels.
  54111. */
  54112. width: number;
  54113. /**
  54114. * The index of the beginning of the data in the binary file.
  54115. */
  54116. dataPosition: number;
  54117. }
  54118. /**
  54119. * This groups tools to convert HDR texture to native colors array.
  54120. */
  54121. export class HDRTools {
  54122. private static Ldexp;
  54123. private static Rgbe2float;
  54124. private static readStringLine;
  54125. /**
  54126. * Reads header information from an RGBE texture stored in a native array.
  54127. * More information on this format are available here:
  54128. * https://en.wikipedia.org/wiki/RGBE_image_format
  54129. *
  54130. * @param uint8array The binary file stored in native array.
  54131. * @return The header information.
  54132. */
  54133. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54134. /**
  54135. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54136. * This RGBE texture needs to store the information as a panorama.
  54137. *
  54138. * More information on this format are available here:
  54139. * https://en.wikipedia.org/wiki/RGBE_image_format
  54140. *
  54141. * @param buffer The binary file stored in an array buffer.
  54142. * @param size The expected size of the extracted cubemap.
  54143. * @return The Cube Map information.
  54144. */
  54145. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54146. /**
  54147. * Returns the pixels data extracted from an RGBE texture.
  54148. * This pixels will be stored left to right up to down in the R G B order in one array.
  54149. *
  54150. * More information on this format are available here:
  54151. * https://en.wikipedia.org/wiki/RGBE_image_format
  54152. *
  54153. * @param uint8array The binary file stored in an array buffer.
  54154. * @param hdrInfo The header information of the file.
  54155. * @return The pixels data in RGB right to left up to down order.
  54156. */
  54157. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54158. private static RGBE_ReadPixels_RLE;
  54159. }
  54160. }
  54161. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54162. import { Nullable } from "babylonjs/types";
  54163. import { Scene } from "babylonjs/scene";
  54164. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54166. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54167. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54168. /**
  54169. * This represents a texture coming from an HDR input.
  54170. *
  54171. * The only supported format is currently panorama picture stored in RGBE format.
  54172. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54173. */
  54174. export class HDRCubeTexture extends BaseTexture {
  54175. private static _facesMapping;
  54176. private _generateHarmonics;
  54177. private _noMipmap;
  54178. private _textureMatrix;
  54179. private _size;
  54180. private _onLoad;
  54181. private _onError;
  54182. /**
  54183. * The texture URL.
  54184. */
  54185. url: string;
  54186. /**
  54187. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54188. */
  54189. coordinatesMode: number;
  54190. protected _isBlocking: boolean;
  54191. /**
  54192. * Sets wether or not the texture is blocking during loading.
  54193. */
  54194. /**
  54195. * Gets wether or not the texture is blocking during loading.
  54196. */
  54197. isBlocking: boolean;
  54198. protected _rotationY: number;
  54199. /**
  54200. * Sets texture matrix rotation angle around Y axis in radians.
  54201. */
  54202. /**
  54203. * Gets texture matrix rotation angle around Y axis radians.
  54204. */
  54205. rotationY: number;
  54206. /**
  54207. * Gets or sets the center of the bounding box associated with the cube texture
  54208. * It must define where the camera used to render the texture was set
  54209. */
  54210. boundingBoxPosition: Vector3;
  54211. private _boundingBoxSize;
  54212. /**
  54213. * Gets or sets the size of the bounding box associated with the cube texture
  54214. * When defined, the cubemap will switch to local mode
  54215. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54216. * @example https://www.babylonjs-playground.com/#RNASML
  54217. */
  54218. boundingBoxSize: Vector3;
  54219. /**
  54220. * Instantiates an HDRTexture from the following parameters.
  54221. *
  54222. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54223. * @param scene The scene the texture will be used in
  54224. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54225. * @param noMipmap Forces to not generate the mipmap if true
  54226. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54227. * @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)
  54228. * @param reserved Reserved flag for internal use.
  54229. */
  54230. 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>);
  54231. /**
  54232. * Get the current class name of the texture useful for serialization or dynamic coding.
  54233. * @returns "HDRCubeTexture"
  54234. */
  54235. getClassName(): string;
  54236. /**
  54237. * Occurs when the file is raw .hdr file.
  54238. */
  54239. private loadTexture;
  54240. clone(): HDRCubeTexture;
  54241. delayLoad(): void;
  54242. /**
  54243. * Get the texture reflection matrix used to rotate/transform the reflection.
  54244. * @returns the reflection matrix
  54245. */
  54246. getReflectionTextureMatrix(): Matrix;
  54247. /**
  54248. * Set the texture reflection matrix used to rotate/transform the reflection.
  54249. * @param value Define the reflection matrix to set
  54250. */
  54251. setReflectionTextureMatrix(value: Matrix): void;
  54252. /**
  54253. * Parses a JSON representation of an HDR Texture in order to create the texture
  54254. * @param parsedTexture Define the JSON representation
  54255. * @param scene Define the scene the texture should be created in
  54256. * @param rootUrl Define the root url in case we need to load relative dependencies
  54257. * @returns the newly created texture after parsing
  54258. */
  54259. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54260. serialize(): any;
  54261. }
  54262. }
  54263. declare module "babylonjs/Physics/physicsEngine" {
  54264. import { Nullable } from "babylonjs/types";
  54265. import { Vector3 } from "babylonjs/Maths/math.vector";
  54266. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54267. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54268. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54269. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54270. /**
  54271. * Class used to control physics engine
  54272. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54273. */
  54274. export class PhysicsEngine implements IPhysicsEngine {
  54275. private _physicsPlugin;
  54276. /**
  54277. * Global value used to control the smallest number supported by the simulation
  54278. */
  54279. static Epsilon: number;
  54280. private _impostors;
  54281. private _joints;
  54282. private _subTimeStep;
  54283. /**
  54284. * Gets the gravity vector used by the simulation
  54285. */
  54286. gravity: Vector3;
  54287. /**
  54288. * Factory used to create the default physics plugin.
  54289. * @returns The default physics plugin
  54290. */
  54291. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54292. /**
  54293. * Creates a new Physics Engine
  54294. * @param gravity defines the gravity vector used by the simulation
  54295. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54296. */
  54297. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54298. /**
  54299. * Sets the gravity vector used by the simulation
  54300. * @param gravity defines the gravity vector to use
  54301. */
  54302. setGravity(gravity: Vector3): void;
  54303. /**
  54304. * Set the time step of the physics engine.
  54305. * Default is 1/60.
  54306. * To slow it down, enter 1/600 for example.
  54307. * To speed it up, 1/30
  54308. * @param newTimeStep defines the new timestep to apply to this world.
  54309. */
  54310. setTimeStep(newTimeStep?: number): void;
  54311. /**
  54312. * Get the time step of the physics engine.
  54313. * @returns the current time step
  54314. */
  54315. getTimeStep(): number;
  54316. /**
  54317. * Set the sub time step of the physics engine.
  54318. * Default is 0 meaning there is no sub steps
  54319. * To increase physics resolution precision, set a small value (like 1 ms)
  54320. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54321. */
  54322. setSubTimeStep(subTimeStep?: number): void;
  54323. /**
  54324. * Get the sub time step of the physics engine.
  54325. * @returns the current sub time step
  54326. */
  54327. getSubTimeStep(): number;
  54328. /**
  54329. * Release all resources
  54330. */
  54331. dispose(): void;
  54332. /**
  54333. * Gets the name of the current physics plugin
  54334. * @returns the name of the plugin
  54335. */
  54336. getPhysicsPluginName(): string;
  54337. /**
  54338. * Adding a new impostor for the impostor tracking.
  54339. * This will be done by the impostor itself.
  54340. * @param impostor the impostor to add
  54341. */
  54342. addImpostor(impostor: PhysicsImpostor): void;
  54343. /**
  54344. * Remove an impostor from the engine.
  54345. * This impostor and its mesh will not longer be updated by the physics engine.
  54346. * @param impostor the impostor to remove
  54347. */
  54348. removeImpostor(impostor: PhysicsImpostor): void;
  54349. /**
  54350. * Add a joint to the physics engine
  54351. * @param mainImpostor defines the main impostor to which the joint is added.
  54352. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54353. * @param joint defines the joint that will connect both impostors.
  54354. */
  54355. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54356. /**
  54357. * Removes a joint from the simulation
  54358. * @param mainImpostor defines the impostor used with the joint
  54359. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54360. * @param joint defines the joint to remove
  54361. */
  54362. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54363. /**
  54364. * Called by the scene. No need to call it.
  54365. * @param delta defines the timespam between frames
  54366. */
  54367. _step(delta: number): void;
  54368. /**
  54369. * Gets the current plugin used to run the simulation
  54370. * @returns current plugin
  54371. */
  54372. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54373. /**
  54374. * Gets the list of physic impostors
  54375. * @returns an array of PhysicsImpostor
  54376. */
  54377. getImpostors(): Array<PhysicsImpostor>;
  54378. /**
  54379. * Gets the impostor for a physics enabled object
  54380. * @param object defines the object impersonated by the impostor
  54381. * @returns the PhysicsImpostor or null if not found
  54382. */
  54383. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54384. /**
  54385. * Gets the impostor for a physics body object
  54386. * @param body defines physics body used by the impostor
  54387. * @returns the PhysicsImpostor or null if not found
  54388. */
  54389. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54390. /**
  54391. * Does a raycast in the physics world
  54392. * @param from when should the ray start?
  54393. * @param to when should the ray end?
  54394. * @returns PhysicsRaycastResult
  54395. */
  54396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54397. }
  54398. }
  54399. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54400. import { Nullable } from "babylonjs/types";
  54401. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54403. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54404. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54405. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54406. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54407. /** @hidden */
  54408. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54409. private _useDeltaForWorldStep;
  54410. world: any;
  54411. name: string;
  54412. private _physicsMaterials;
  54413. private _fixedTimeStep;
  54414. private _cannonRaycastResult;
  54415. private _raycastResult;
  54416. private _physicsBodysToRemoveAfterStep;
  54417. BJSCANNON: any;
  54418. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54419. setGravity(gravity: Vector3): void;
  54420. setTimeStep(timeStep: number): void;
  54421. getTimeStep(): number;
  54422. executeStep(delta: number): void;
  54423. private _removeMarkedPhysicsBodiesFromWorld;
  54424. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54425. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54427. private _processChildMeshes;
  54428. removePhysicsBody(impostor: PhysicsImpostor): void;
  54429. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54430. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54431. private _addMaterial;
  54432. private _checkWithEpsilon;
  54433. private _createShape;
  54434. private _createHeightmap;
  54435. private _minus90X;
  54436. private _plus90X;
  54437. private _tmpPosition;
  54438. private _tmpDeltaPosition;
  54439. private _tmpUnityRotation;
  54440. private _updatePhysicsBodyTransformation;
  54441. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54442. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54443. isSupported(): boolean;
  54444. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54445. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54446. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54447. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54448. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54449. getBodyMass(impostor: PhysicsImpostor): number;
  54450. getBodyFriction(impostor: PhysicsImpostor): number;
  54451. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54452. getBodyRestitution(impostor: PhysicsImpostor): number;
  54453. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54454. sleepBody(impostor: PhysicsImpostor): void;
  54455. wakeUpBody(impostor: PhysicsImpostor): void;
  54456. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54457. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54459. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54460. getRadius(impostor: PhysicsImpostor): number;
  54461. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54462. dispose(): void;
  54463. private _extendNamespace;
  54464. /**
  54465. * Does a raycast in the physics world
  54466. * @param from when should the ray start?
  54467. * @param to when should the ray end?
  54468. * @returns PhysicsRaycastResult
  54469. */
  54470. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54471. }
  54472. }
  54473. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54474. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54475. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54476. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54478. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54479. import { Nullable } from "babylonjs/types";
  54480. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54481. /** @hidden */
  54482. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54483. world: any;
  54484. name: string;
  54485. BJSOIMO: any;
  54486. private _raycastResult;
  54487. constructor(iterations?: number, oimoInjection?: any);
  54488. setGravity(gravity: Vector3): void;
  54489. setTimeStep(timeStep: number): void;
  54490. getTimeStep(): number;
  54491. private _tmpImpostorsArray;
  54492. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54493. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54494. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54495. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54496. private _tmpPositionVector;
  54497. removePhysicsBody(impostor: PhysicsImpostor): void;
  54498. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54499. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54500. isSupported(): boolean;
  54501. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54502. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54503. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54504. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54505. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54506. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54507. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54508. getBodyMass(impostor: PhysicsImpostor): number;
  54509. getBodyFriction(impostor: PhysicsImpostor): number;
  54510. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54511. getBodyRestitution(impostor: PhysicsImpostor): number;
  54512. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54513. sleepBody(impostor: PhysicsImpostor): void;
  54514. wakeUpBody(impostor: PhysicsImpostor): void;
  54515. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54516. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54517. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54519. getRadius(impostor: PhysicsImpostor): number;
  54520. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54521. dispose(): void;
  54522. /**
  54523. * Does a raycast in the physics world
  54524. * @param from when should the ray start?
  54525. * @param to when should the ray end?
  54526. * @returns PhysicsRaycastResult
  54527. */
  54528. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54529. }
  54530. }
  54531. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54532. import { Nullable } from "babylonjs/types";
  54533. import { Scene } from "babylonjs/scene";
  54534. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54535. import { Color4 } from "babylonjs/Maths/math.color";
  54536. import { Mesh } from "babylonjs/Meshes/mesh";
  54537. /**
  54538. * Class containing static functions to help procedurally build meshes
  54539. */
  54540. export class RibbonBuilder {
  54541. /**
  54542. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54543. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54544. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54545. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54546. * * 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
  54547. * * 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
  54548. * * 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
  54549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54552. * * 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
  54553. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54554. * * 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
  54555. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54557. * @param name defines the name of the mesh
  54558. * @param options defines the options used to create the mesh
  54559. * @param scene defines the hosting scene
  54560. * @returns the ribbon mesh
  54561. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54563. */
  54564. static CreateRibbon(name: string, options: {
  54565. pathArray: Vector3[][];
  54566. closeArray?: boolean;
  54567. closePath?: boolean;
  54568. offset?: number;
  54569. updatable?: boolean;
  54570. sideOrientation?: number;
  54571. frontUVs?: Vector4;
  54572. backUVs?: Vector4;
  54573. instance?: Mesh;
  54574. invertUV?: boolean;
  54575. uvs?: Vector2[];
  54576. colors?: Color4[];
  54577. }, scene?: Nullable<Scene>): Mesh;
  54578. }
  54579. }
  54580. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54581. import { Nullable } from "babylonjs/types";
  54582. import { Scene } from "babylonjs/scene";
  54583. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54584. import { Mesh } from "babylonjs/Meshes/mesh";
  54585. /**
  54586. * Class containing static functions to help procedurally build meshes
  54587. */
  54588. export class ShapeBuilder {
  54589. /**
  54590. * 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.
  54591. * * 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.
  54592. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54593. * * 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.
  54594. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54595. * * 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
  54596. * * 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
  54597. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54602. * @param name defines the name of the mesh
  54603. * @param options defines the options used to create the mesh
  54604. * @param scene defines the hosting scene
  54605. * @returns the extruded shape mesh
  54606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54608. */
  54609. static ExtrudeShape(name: string, options: {
  54610. shape: Vector3[];
  54611. path: Vector3[];
  54612. scale?: number;
  54613. rotation?: number;
  54614. cap?: number;
  54615. updatable?: boolean;
  54616. sideOrientation?: number;
  54617. frontUVs?: Vector4;
  54618. backUVs?: Vector4;
  54619. instance?: Mesh;
  54620. invertUV?: boolean;
  54621. }, scene?: Nullable<Scene>): Mesh;
  54622. /**
  54623. * Creates an custom extruded shape mesh.
  54624. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54625. * * 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.
  54626. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54627. * * 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
  54628. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54629. * * 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
  54630. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54631. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54632. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54633. * * 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
  54634. * * 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
  54635. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54640. * @param name defines the name of the mesh
  54641. * @param options defines the options used to create the mesh
  54642. * @param scene defines the hosting scene
  54643. * @returns the custom extruded shape mesh
  54644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54647. */
  54648. static ExtrudeShapeCustom(name: string, options: {
  54649. shape: Vector3[];
  54650. path: Vector3[];
  54651. scaleFunction?: any;
  54652. rotationFunction?: any;
  54653. ribbonCloseArray?: boolean;
  54654. ribbonClosePath?: boolean;
  54655. cap?: number;
  54656. updatable?: boolean;
  54657. sideOrientation?: number;
  54658. frontUVs?: Vector4;
  54659. backUVs?: Vector4;
  54660. instance?: Mesh;
  54661. invertUV?: boolean;
  54662. }, scene?: Nullable<Scene>): Mesh;
  54663. private static _ExtrudeShapeGeneric;
  54664. }
  54665. }
  54666. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54667. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54668. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54669. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54670. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54671. import { Nullable } from "babylonjs/types";
  54672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54673. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54674. /**
  54675. * AmmoJS Physics plugin
  54676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54677. * @see https://github.com/kripken/ammo.js/
  54678. */
  54679. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54680. private _useDeltaForWorldStep;
  54681. /**
  54682. * Reference to the Ammo library
  54683. */
  54684. bjsAMMO: any;
  54685. /**
  54686. * Created ammoJS world which physics bodies are added to
  54687. */
  54688. world: any;
  54689. /**
  54690. * Name of the plugin
  54691. */
  54692. name: string;
  54693. private _timeStep;
  54694. private _fixedTimeStep;
  54695. private _maxSteps;
  54696. private _tmpQuaternion;
  54697. private _tmpAmmoTransform;
  54698. private _tmpAmmoQuaternion;
  54699. private _tmpAmmoConcreteContactResultCallback;
  54700. private _collisionConfiguration;
  54701. private _dispatcher;
  54702. private _overlappingPairCache;
  54703. private _solver;
  54704. private _softBodySolver;
  54705. private _tmpAmmoVectorA;
  54706. private _tmpAmmoVectorB;
  54707. private _tmpAmmoVectorC;
  54708. private _tmpAmmoVectorD;
  54709. private _tmpContactCallbackResult;
  54710. private _tmpAmmoVectorRCA;
  54711. private _tmpAmmoVectorRCB;
  54712. private _raycastResult;
  54713. private static readonly DISABLE_COLLISION_FLAG;
  54714. private static readonly KINEMATIC_FLAG;
  54715. private static readonly DISABLE_DEACTIVATION_FLAG;
  54716. /**
  54717. * Initializes the ammoJS plugin
  54718. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54719. * @param ammoInjection can be used to inject your own ammo reference
  54720. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54721. */
  54722. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54723. /**
  54724. * Sets the gravity of the physics world (m/(s^2))
  54725. * @param gravity Gravity to set
  54726. */
  54727. setGravity(gravity: Vector3): void;
  54728. /**
  54729. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54730. * @param timeStep timestep to use in seconds
  54731. */
  54732. setTimeStep(timeStep: number): void;
  54733. /**
  54734. * 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)
  54735. * @param fixedTimeStep fixedTimeStep to use in seconds
  54736. */
  54737. setFixedTimeStep(fixedTimeStep: number): void;
  54738. /**
  54739. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54740. * @param maxSteps the maximum number of steps by the physics engine per frame
  54741. */
  54742. setMaxSteps(maxSteps: number): void;
  54743. /**
  54744. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54745. * @returns the current timestep in seconds
  54746. */
  54747. getTimeStep(): number;
  54748. /**
  54749. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54750. */
  54751. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54752. private _isImpostorInContact;
  54753. private _isImpostorPairInContact;
  54754. private _stepSimulation;
  54755. /**
  54756. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54757. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54758. * After the step the babylon meshes are set to the position of the physics imposters
  54759. * @param delta amount of time to step forward
  54760. * @param impostors array of imposters to update before/after the step
  54761. */
  54762. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54763. /**
  54764. * Update babylon mesh to match physics world object
  54765. * @param impostor imposter to match
  54766. */
  54767. private _afterSoftStep;
  54768. /**
  54769. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54770. * @param impostor imposter to match
  54771. */
  54772. private _ropeStep;
  54773. /**
  54774. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54775. * @param impostor imposter to match
  54776. */
  54777. private _softbodyOrClothStep;
  54778. private _tmpVector;
  54779. private _tmpMatrix;
  54780. /**
  54781. * Applies an impulse on the imposter
  54782. * @param impostor imposter to apply impulse to
  54783. * @param force amount of force to be applied to the imposter
  54784. * @param contactPoint the location to apply the impulse on the imposter
  54785. */
  54786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54787. /**
  54788. * Applies a force on the imposter
  54789. * @param impostor imposter to apply force
  54790. * @param force amount of force to be applied to the imposter
  54791. * @param contactPoint the location to apply the force on the imposter
  54792. */
  54793. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54794. /**
  54795. * Creates a physics body using the plugin
  54796. * @param impostor the imposter to create the physics body on
  54797. */
  54798. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54799. /**
  54800. * Removes the physics body from the imposter and disposes of the body's memory
  54801. * @param impostor imposter to remove the physics body from
  54802. */
  54803. removePhysicsBody(impostor: PhysicsImpostor): void;
  54804. /**
  54805. * Generates a joint
  54806. * @param impostorJoint the imposter joint to create the joint with
  54807. */
  54808. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54809. /**
  54810. * Removes a joint
  54811. * @param impostorJoint the imposter joint to remove the joint from
  54812. */
  54813. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54814. private _addMeshVerts;
  54815. /**
  54816. * Initialise the soft body vertices to match its object's (mesh) vertices
  54817. * Softbody vertices (nodes) are in world space and to match this
  54818. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54819. * @param impostor to create the softbody for
  54820. */
  54821. private _softVertexData;
  54822. /**
  54823. * Create an impostor's soft body
  54824. * @param impostor to create the softbody for
  54825. */
  54826. private _createSoftbody;
  54827. /**
  54828. * Create cloth for an impostor
  54829. * @param impostor to create the softbody for
  54830. */
  54831. private _createCloth;
  54832. /**
  54833. * Create rope for an impostor
  54834. * @param impostor to create the softbody for
  54835. */
  54836. private _createRope;
  54837. /**
  54838. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  54839. * @param impostor to create the custom physics shape for
  54840. */
  54841. private _createCustom;
  54842. private _addHullVerts;
  54843. private _createShape;
  54844. /**
  54845. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54846. * @param impostor imposter containing the physics body and babylon object
  54847. */
  54848. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54849. /**
  54850. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54851. * @param impostor imposter containing the physics body and babylon object
  54852. * @param newPosition new position
  54853. * @param newRotation new rotation
  54854. */
  54855. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54856. /**
  54857. * If this plugin is supported
  54858. * @returns true if its supported
  54859. */
  54860. isSupported(): boolean;
  54861. /**
  54862. * Sets the linear velocity of the physics body
  54863. * @param impostor imposter to set the velocity on
  54864. * @param velocity velocity to set
  54865. */
  54866. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54867. /**
  54868. * Sets the angular velocity of the physics body
  54869. * @param impostor imposter to set the velocity on
  54870. * @param velocity velocity to set
  54871. */
  54872. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54873. /**
  54874. * gets the linear velocity
  54875. * @param impostor imposter to get linear velocity from
  54876. * @returns linear velocity
  54877. */
  54878. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54879. /**
  54880. * gets the angular velocity
  54881. * @param impostor imposter to get angular velocity from
  54882. * @returns angular velocity
  54883. */
  54884. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54885. /**
  54886. * Sets the mass of physics body
  54887. * @param impostor imposter to set the mass on
  54888. * @param mass mass to set
  54889. */
  54890. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54891. /**
  54892. * Gets the mass of the physics body
  54893. * @param impostor imposter to get the mass from
  54894. * @returns mass
  54895. */
  54896. getBodyMass(impostor: PhysicsImpostor): number;
  54897. /**
  54898. * Gets friction of the impostor
  54899. * @param impostor impostor to get friction from
  54900. * @returns friction value
  54901. */
  54902. getBodyFriction(impostor: PhysicsImpostor): number;
  54903. /**
  54904. * Sets friction of the impostor
  54905. * @param impostor impostor to set friction on
  54906. * @param friction friction value
  54907. */
  54908. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54909. /**
  54910. * Gets restitution of the impostor
  54911. * @param impostor impostor to get restitution from
  54912. * @returns restitution value
  54913. */
  54914. getBodyRestitution(impostor: PhysicsImpostor): number;
  54915. /**
  54916. * Sets resitution of the impostor
  54917. * @param impostor impostor to set resitution on
  54918. * @param restitution resitution value
  54919. */
  54920. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54921. /**
  54922. * Gets pressure inside the impostor
  54923. * @param impostor impostor to get pressure from
  54924. * @returns pressure value
  54925. */
  54926. getBodyPressure(impostor: PhysicsImpostor): number;
  54927. /**
  54928. * Sets pressure inside a soft body impostor
  54929. * Cloth and rope must remain 0 pressure
  54930. * @param impostor impostor to set pressure on
  54931. * @param pressure pressure value
  54932. */
  54933. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54934. /**
  54935. * Gets stiffness of the impostor
  54936. * @param impostor impostor to get stiffness from
  54937. * @returns pressure value
  54938. */
  54939. getBodyStiffness(impostor: PhysicsImpostor): number;
  54940. /**
  54941. * Sets stiffness of the impostor
  54942. * @param impostor impostor to set stiffness on
  54943. * @param stiffness stiffness value from 0 to 1
  54944. */
  54945. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54946. /**
  54947. * Gets velocityIterations of the impostor
  54948. * @param impostor impostor to get velocity iterations from
  54949. * @returns velocityIterations value
  54950. */
  54951. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54952. /**
  54953. * Sets velocityIterations of the impostor
  54954. * @param impostor impostor to set velocity iterations on
  54955. * @param velocityIterations velocityIterations value
  54956. */
  54957. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54958. /**
  54959. * Gets positionIterations of the impostor
  54960. * @param impostor impostor to get position iterations from
  54961. * @returns positionIterations value
  54962. */
  54963. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54964. /**
  54965. * Sets positionIterations of the impostor
  54966. * @param impostor impostor to set position on
  54967. * @param positionIterations positionIterations value
  54968. */
  54969. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54970. /**
  54971. * Append an anchor to a cloth object
  54972. * @param impostor is the cloth impostor to add anchor to
  54973. * @param otherImpostor is the rigid impostor to anchor to
  54974. * @param width ratio across width from 0 to 1
  54975. * @param height ratio up height from 0 to 1
  54976. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54977. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54978. */
  54979. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54980. /**
  54981. * Append an hook to a rope object
  54982. * @param impostor is the rope impostor to add hook to
  54983. * @param otherImpostor is the rigid impostor to hook to
  54984. * @param length ratio along the rope from 0 to 1
  54985. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54986. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54987. */
  54988. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54989. /**
  54990. * Sleeps the physics body and stops it from being active
  54991. * @param impostor impostor to sleep
  54992. */
  54993. sleepBody(impostor: PhysicsImpostor): void;
  54994. /**
  54995. * Activates the physics body
  54996. * @param impostor impostor to activate
  54997. */
  54998. wakeUpBody(impostor: PhysicsImpostor): void;
  54999. /**
  55000. * Updates the distance parameters of the joint
  55001. * @param joint joint to update
  55002. * @param maxDistance maximum distance of the joint
  55003. * @param minDistance minimum distance of the joint
  55004. */
  55005. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55006. /**
  55007. * Sets a motor on the joint
  55008. * @param joint joint to set motor on
  55009. * @param speed speed of the motor
  55010. * @param maxForce maximum force of the motor
  55011. * @param motorIndex index of the motor
  55012. */
  55013. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55014. /**
  55015. * Sets the motors limit
  55016. * @param joint joint to set limit on
  55017. * @param upperLimit upper limit
  55018. * @param lowerLimit lower limit
  55019. */
  55020. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55021. /**
  55022. * Syncs the position and rotation of a mesh with the impostor
  55023. * @param mesh mesh to sync
  55024. * @param impostor impostor to update the mesh with
  55025. */
  55026. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55027. /**
  55028. * Gets the radius of the impostor
  55029. * @param impostor impostor to get radius from
  55030. * @returns the radius
  55031. */
  55032. getRadius(impostor: PhysicsImpostor): number;
  55033. /**
  55034. * Gets the box size of the impostor
  55035. * @param impostor impostor to get box size from
  55036. * @param result the resulting box size
  55037. */
  55038. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55039. /**
  55040. * Disposes of the impostor
  55041. */
  55042. dispose(): void;
  55043. /**
  55044. * Does a raycast in the physics world
  55045. * @param from when should the ray start?
  55046. * @param to when should the ray end?
  55047. * @returns PhysicsRaycastResult
  55048. */
  55049. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55050. }
  55051. }
  55052. declare module "babylonjs/Probes/reflectionProbe" {
  55053. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55054. import { Vector3 } from "babylonjs/Maths/math.vector";
  55055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55056. import { Nullable } from "babylonjs/types";
  55057. import { Scene } from "babylonjs/scene";
  55058. module "babylonjs/abstractScene" {
  55059. interface AbstractScene {
  55060. /**
  55061. * The list of reflection probes added to the scene
  55062. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55063. */
  55064. reflectionProbes: Array<ReflectionProbe>;
  55065. /**
  55066. * Removes the given reflection probe from this scene.
  55067. * @param toRemove The reflection probe to remove
  55068. * @returns The index of the removed reflection probe
  55069. */
  55070. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55071. /**
  55072. * Adds the given reflection probe to this scene.
  55073. * @param newReflectionProbe The reflection probe to add
  55074. */
  55075. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55076. }
  55077. }
  55078. /**
  55079. * Class used to generate realtime reflection / refraction cube textures
  55080. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55081. */
  55082. export class ReflectionProbe {
  55083. /** defines the name of the probe */
  55084. name: string;
  55085. private _scene;
  55086. private _renderTargetTexture;
  55087. private _projectionMatrix;
  55088. private _viewMatrix;
  55089. private _target;
  55090. private _add;
  55091. private _attachedMesh;
  55092. private _invertYAxis;
  55093. /** Gets or sets probe position (center of the cube map) */
  55094. position: Vector3;
  55095. /**
  55096. * Creates a new reflection probe
  55097. * @param name defines the name of the probe
  55098. * @param size defines the texture resolution (for each face)
  55099. * @param scene defines the hosting scene
  55100. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55101. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55102. */
  55103. constructor(
  55104. /** defines the name of the probe */
  55105. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55106. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55107. samples: number;
  55108. /** Gets or sets the refresh rate to use (on every frame by default) */
  55109. refreshRate: number;
  55110. /**
  55111. * Gets the hosting scene
  55112. * @returns a Scene
  55113. */
  55114. getScene(): Scene;
  55115. /** Gets the internal CubeTexture used to render to */
  55116. readonly cubeTexture: RenderTargetTexture;
  55117. /** Gets the list of meshes to render */
  55118. readonly renderList: Nullable<AbstractMesh[]>;
  55119. /**
  55120. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55121. * @param mesh defines the mesh to attach to
  55122. */
  55123. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55124. /**
  55125. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55126. * @param renderingGroupId The rendering group id corresponding to its index
  55127. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55128. */
  55129. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55130. /**
  55131. * Clean all associated resources
  55132. */
  55133. dispose(): void;
  55134. /**
  55135. * Converts the reflection probe information to a readable string for debug purpose.
  55136. * @param fullDetails Supports for multiple levels of logging within scene loading
  55137. * @returns the human readable reflection probe info
  55138. */
  55139. toString(fullDetails?: boolean): string;
  55140. /**
  55141. * Get the class name of the relfection probe.
  55142. * @returns "ReflectionProbe"
  55143. */
  55144. getClassName(): string;
  55145. /**
  55146. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55147. * @returns The JSON representation of the texture
  55148. */
  55149. serialize(): any;
  55150. /**
  55151. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55152. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55153. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55154. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55155. * @returns The parsed reflection probe if successful
  55156. */
  55157. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55158. }
  55159. }
  55160. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55161. /** @hidden */
  55162. export var _BabylonLoaderRegistered: boolean;
  55163. /**
  55164. * Helps setting up some configuration for the babylon file loader.
  55165. */
  55166. export class BabylonFileLoaderConfiguration {
  55167. /**
  55168. * The loader does not allow injecting custom physix engine into the plugins.
  55169. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55170. * So you could set this variable to your engine import to make it work.
  55171. */
  55172. static LoaderInjectedPhysicsEngine: any;
  55173. }
  55174. }
  55175. declare module "babylonjs/Loading/Plugins/index" {
  55176. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55177. }
  55178. declare module "babylonjs/Loading/index" {
  55179. export * from "babylonjs/Loading/loadingScreen";
  55180. export * from "babylonjs/Loading/Plugins/index";
  55181. export * from "babylonjs/Loading/sceneLoader";
  55182. export * from "babylonjs/Loading/sceneLoaderFlags";
  55183. }
  55184. declare module "babylonjs/Materials/Background/index" {
  55185. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55186. }
  55187. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55188. import { Scene } from "babylonjs/scene";
  55189. import { Color3 } from "babylonjs/Maths/math.color";
  55190. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55192. /**
  55193. * The Physically based simple base material of BJS.
  55194. *
  55195. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55196. * It is used as the base class for both the specGloss and metalRough conventions.
  55197. */
  55198. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55199. /**
  55200. * Number of Simultaneous lights allowed on the material.
  55201. */
  55202. maxSimultaneousLights: number;
  55203. /**
  55204. * If sets to true, disables all the lights affecting the material.
  55205. */
  55206. disableLighting: boolean;
  55207. /**
  55208. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55209. */
  55210. environmentTexture: BaseTexture;
  55211. /**
  55212. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55213. */
  55214. invertNormalMapX: boolean;
  55215. /**
  55216. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55217. */
  55218. invertNormalMapY: boolean;
  55219. /**
  55220. * Normal map used in the model.
  55221. */
  55222. normalTexture: BaseTexture;
  55223. /**
  55224. * Emissivie color used to self-illuminate the model.
  55225. */
  55226. emissiveColor: Color3;
  55227. /**
  55228. * Emissivie texture used to self-illuminate the model.
  55229. */
  55230. emissiveTexture: BaseTexture;
  55231. /**
  55232. * Occlusion Channel Strenght.
  55233. */
  55234. occlusionStrength: number;
  55235. /**
  55236. * Occlusion Texture of the material (adding extra occlusion effects).
  55237. */
  55238. occlusionTexture: BaseTexture;
  55239. /**
  55240. * Defines the alpha limits in alpha test mode.
  55241. */
  55242. alphaCutOff: number;
  55243. /**
  55244. * Gets the current double sided mode.
  55245. */
  55246. /**
  55247. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55248. */
  55249. doubleSided: boolean;
  55250. /**
  55251. * Stores the pre-calculated light information of a mesh in a texture.
  55252. */
  55253. lightmapTexture: BaseTexture;
  55254. /**
  55255. * If true, the light map contains occlusion information instead of lighting info.
  55256. */
  55257. useLightmapAsShadowmap: boolean;
  55258. /**
  55259. * Instantiates a new PBRMaterial instance.
  55260. *
  55261. * @param name The material name
  55262. * @param scene The scene the material will be use in.
  55263. */
  55264. constructor(name: string, scene: Scene);
  55265. getClassName(): string;
  55266. }
  55267. }
  55268. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55269. import { Scene } from "babylonjs/scene";
  55270. import { Color3 } from "babylonjs/Maths/math.color";
  55271. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55272. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55273. /**
  55274. * The PBR material of BJS following the metal roughness convention.
  55275. *
  55276. * This fits to the PBR convention in the GLTF definition:
  55277. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55278. */
  55279. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55280. /**
  55281. * The base color has two different interpretations depending on the value of metalness.
  55282. * When the material is a metal, the base color is the specific measured reflectance value
  55283. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55284. * of the material.
  55285. */
  55286. baseColor: Color3;
  55287. /**
  55288. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55289. * well as opacity information in the alpha channel.
  55290. */
  55291. baseTexture: BaseTexture;
  55292. /**
  55293. * Specifies the metallic scalar value of the material.
  55294. * Can also be used to scale the metalness values of the metallic texture.
  55295. */
  55296. metallic: number;
  55297. /**
  55298. * Specifies the roughness scalar value of the material.
  55299. * Can also be used to scale the roughness values of the metallic texture.
  55300. */
  55301. roughness: number;
  55302. /**
  55303. * Texture containing both the metallic value in the B channel and the
  55304. * roughness value in the G channel to keep better precision.
  55305. */
  55306. metallicRoughnessTexture: BaseTexture;
  55307. /**
  55308. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55309. *
  55310. * @param name The material name
  55311. * @param scene The scene the material will be use in.
  55312. */
  55313. constructor(name: string, scene: Scene);
  55314. /**
  55315. * Return the currrent class name of the material.
  55316. */
  55317. getClassName(): string;
  55318. /**
  55319. * Makes a duplicate of the current material.
  55320. * @param name - name to use for the new material.
  55321. */
  55322. clone(name: string): PBRMetallicRoughnessMaterial;
  55323. /**
  55324. * Serialize the material to a parsable JSON object.
  55325. */
  55326. serialize(): any;
  55327. /**
  55328. * Parses a JSON object correponding to the serialize function.
  55329. */
  55330. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55331. }
  55332. }
  55333. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55334. import { Scene } from "babylonjs/scene";
  55335. import { Color3 } from "babylonjs/Maths/math.color";
  55336. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55337. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55338. /**
  55339. * The PBR material of BJS following the specular glossiness convention.
  55340. *
  55341. * This fits to the PBR convention in the GLTF definition:
  55342. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55343. */
  55344. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55345. /**
  55346. * Specifies the diffuse color of the material.
  55347. */
  55348. diffuseColor: Color3;
  55349. /**
  55350. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55351. * channel.
  55352. */
  55353. diffuseTexture: BaseTexture;
  55354. /**
  55355. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55356. */
  55357. specularColor: Color3;
  55358. /**
  55359. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55360. */
  55361. glossiness: number;
  55362. /**
  55363. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55364. */
  55365. specularGlossinessTexture: BaseTexture;
  55366. /**
  55367. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55368. *
  55369. * @param name The material name
  55370. * @param scene The scene the material will be use in.
  55371. */
  55372. constructor(name: string, scene: Scene);
  55373. /**
  55374. * Return the currrent class name of the material.
  55375. */
  55376. getClassName(): string;
  55377. /**
  55378. * Makes a duplicate of the current material.
  55379. * @param name - name to use for the new material.
  55380. */
  55381. clone(name: string): PBRSpecularGlossinessMaterial;
  55382. /**
  55383. * Serialize the material to a parsable JSON object.
  55384. */
  55385. serialize(): any;
  55386. /**
  55387. * Parses a JSON object correponding to the serialize function.
  55388. */
  55389. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55390. }
  55391. }
  55392. declare module "babylonjs/Materials/PBR/index" {
  55393. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55394. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55395. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55396. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55397. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55398. }
  55399. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55400. import { Nullable } from "babylonjs/types";
  55401. import { Scene } from "babylonjs/scene";
  55402. import { Matrix } from "babylonjs/Maths/math.vector";
  55403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55404. /**
  55405. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55406. * It can help converting any input color in a desired output one. This can then be used to create effects
  55407. * from sepia, black and white to sixties or futuristic rendering...
  55408. *
  55409. * The only supported format is currently 3dl.
  55410. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55411. */
  55412. export class ColorGradingTexture extends BaseTexture {
  55413. /**
  55414. * The current texture matrix. (will always be identity in color grading texture)
  55415. */
  55416. private _textureMatrix;
  55417. /**
  55418. * The texture URL.
  55419. */
  55420. url: string;
  55421. /**
  55422. * Empty line regex stored for GC.
  55423. */
  55424. private static _noneEmptyLineRegex;
  55425. private _engine;
  55426. /**
  55427. * Instantiates a ColorGradingTexture from the following parameters.
  55428. *
  55429. * @param url The location of the color gradind data (currently only supporting 3dl)
  55430. * @param scene The scene the texture will be used in
  55431. */
  55432. constructor(url: string, scene: Scene);
  55433. /**
  55434. * Returns the texture matrix used in most of the material.
  55435. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55436. */
  55437. getTextureMatrix(): Matrix;
  55438. /**
  55439. * Occurs when the file being loaded is a .3dl LUT file.
  55440. */
  55441. private load3dlTexture;
  55442. /**
  55443. * Starts the loading process of the texture.
  55444. */
  55445. private loadTexture;
  55446. /**
  55447. * Clones the color gradind texture.
  55448. */
  55449. clone(): ColorGradingTexture;
  55450. /**
  55451. * Called during delayed load for textures.
  55452. */
  55453. delayLoad(): void;
  55454. /**
  55455. * Parses a color grading texture serialized by Babylon.
  55456. * @param parsedTexture The texture information being parsedTexture
  55457. * @param scene The scene to load the texture in
  55458. * @param rootUrl The root url of the data assets to load
  55459. * @return A color gradind texture
  55460. */
  55461. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55462. /**
  55463. * Serializes the LUT texture to json format.
  55464. */
  55465. serialize(): any;
  55466. }
  55467. }
  55468. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55470. import { Scene } from "babylonjs/scene";
  55471. import { Nullable } from "babylonjs/types";
  55472. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55473. /**
  55474. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55475. */
  55476. export class EquiRectangularCubeTexture extends BaseTexture {
  55477. /** The six faces of the cube. */
  55478. private static _FacesMapping;
  55479. private _noMipmap;
  55480. private _onLoad;
  55481. private _onError;
  55482. /** The size of the cubemap. */
  55483. private _size;
  55484. /** The buffer of the image. */
  55485. private _buffer;
  55486. /** The width of the input image. */
  55487. private _width;
  55488. /** The height of the input image. */
  55489. private _height;
  55490. /** The URL to the image. */
  55491. url: string;
  55492. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55493. coordinatesMode: number;
  55494. /**
  55495. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55496. * @param url The location of the image
  55497. * @param scene The scene the texture will be used in
  55498. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55499. * @param noMipmap Forces to not generate the mipmap if true
  55500. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55501. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55502. * @param onLoad — defines a callback called when texture is loaded
  55503. * @param onError — defines a callback called if there is an error
  55504. */
  55505. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55506. /**
  55507. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55508. */
  55509. private loadImage;
  55510. /**
  55511. * Convert the image buffer into a cubemap and create a CubeTexture.
  55512. */
  55513. private loadTexture;
  55514. /**
  55515. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55516. * @param buffer The ArrayBuffer that should be converted.
  55517. * @returns The buffer as Float32Array.
  55518. */
  55519. private getFloat32ArrayFromArrayBuffer;
  55520. /**
  55521. * Get the current class name of the texture useful for serialization or dynamic coding.
  55522. * @returns "EquiRectangularCubeTexture"
  55523. */
  55524. getClassName(): string;
  55525. /**
  55526. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55527. * @returns A clone of the current EquiRectangularCubeTexture.
  55528. */
  55529. clone(): EquiRectangularCubeTexture;
  55530. }
  55531. }
  55532. declare module "babylonjs/Misc/tga" {
  55533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55534. /**
  55535. * Based on jsTGALoader - Javascript loader for TGA file
  55536. * By Vincent Thibault
  55537. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55538. */
  55539. export class TGATools {
  55540. private static _TYPE_INDEXED;
  55541. private static _TYPE_RGB;
  55542. private static _TYPE_GREY;
  55543. private static _TYPE_RLE_INDEXED;
  55544. private static _TYPE_RLE_RGB;
  55545. private static _TYPE_RLE_GREY;
  55546. private static _ORIGIN_MASK;
  55547. private static _ORIGIN_SHIFT;
  55548. private static _ORIGIN_BL;
  55549. private static _ORIGIN_BR;
  55550. private static _ORIGIN_UL;
  55551. private static _ORIGIN_UR;
  55552. /**
  55553. * Gets the header of a TGA file
  55554. * @param data defines the TGA data
  55555. * @returns the header
  55556. */
  55557. static GetTGAHeader(data: Uint8Array): any;
  55558. /**
  55559. * Uploads TGA content to a Babylon Texture
  55560. * @hidden
  55561. */
  55562. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55563. /** @hidden */
  55564. 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;
  55565. /** @hidden */
  55566. 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;
  55567. /** @hidden */
  55568. 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;
  55569. /** @hidden */
  55570. 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;
  55571. /** @hidden */
  55572. 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;
  55573. /** @hidden */
  55574. 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;
  55575. }
  55576. }
  55577. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55578. import { Nullable } from "babylonjs/types";
  55579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55580. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55581. /**
  55582. * Implementation of the TGA Texture Loader.
  55583. * @hidden
  55584. */
  55585. export class _TGATextureLoader implements IInternalTextureLoader {
  55586. /**
  55587. * Defines wether the loader supports cascade loading the different faces.
  55588. */
  55589. readonly supportCascades: boolean;
  55590. /**
  55591. * This returns if the loader support the current file information.
  55592. * @param extension defines the file extension of the file being loaded
  55593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55594. * @param fallback defines the fallback internal texture if any
  55595. * @param isBase64 defines whether the texture is encoded as a base64
  55596. * @param isBuffer defines whether the texture data are stored as a buffer
  55597. * @returns true if the loader can load the specified file
  55598. */
  55599. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55600. /**
  55601. * Transform the url before loading if required.
  55602. * @param rootUrl the url of the texture
  55603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55604. * @returns the transformed texture
  55605. */
  55606. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55607. /**
  55608. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55609. * @param rootUrl the url of the texture
  55610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55611. * @returns the fallback texture
  55612. */
  55613. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55614. /**
  55615. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55616. * @param data contains the texture data
  55617. * @param texture defines the BabylonJS internal texture
  55618. * @param createPolynomials will be true if polynomials have been requested
  55619. * @param onLoad defines the callback to trigger once the texture is ready
  55620. * @param onError defines the callback to trigger in case of error
  55621. */
  55622. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55623. /**
  55624. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55625. * @param data contains the texture data
  55626. * @param texture defines the BabylonJS internal texture
  55627. * @param callback defines the method to call once ready to upload
  55628. */
  55629. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55630. }
  55631. }
  55632. declare module "babylonjs/Misc/basis" {
  55633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55634. /**
  55635. * Info about the .basis files
  55636. */
  55637. class BasisFileInfo {
  55638. /**
  55639. * If the file has alpha
  55640. */
  55641. hasAlpha: boolean;
  55642. /**
  55643. * Info about each image of the basis file
  55644. */
  55645. images: Array<{
  55646. levels: Array<{
  55647. width: number;
  55648. height: number;
  55649. transcodedPixels: ArrayBufferView;
  55650. }>;
  55651. }>;
  55652. }
  55653. /**
  55654. * Result of transcoding a basis file
  55655. */
  55656. class TranscodeResult {
  55657. /**
  55658. * Info about the .basis file
  55659. */
  55660. fileInfo: BasisFileInfo;
  55661. /**
  55662. * Format to use when loading the file
  55663. */
  55664. format: number;
  55665. }
  55666. /**
  55667. * Configuration options for the Basis transcoder
  55668. */
  55669. export class BasisTranscodeConfiguration {
  55670. /**
  55671. * Supported compression formats used to determine the supported output format of the transcoder
  55672. */
  55673. supportedCompressionFormats?: {
  55674. /**
  55675. * etc1 compression format
  55676. */
  55677. etc1?: boolean;
  55678. /**
  55679. * s3tc compression format
  55680. */
  55681. s3tc?: boolean;
  55682. /**
  55683. * pvrtc compression format
  55684. */
  55685. pvrtc?: boolean;
  55686. /**
  55687. * etc2 compression format
  55688. */
  55689. etc2?: boolean;
  55690. };
  55691. /**
  55692. * If mipmap levels should be loaded for transcoded images (Default: true)
  55693. */
  55694. loadMipmapLevels?: boolean;
  55695. /**
  55696. * Index of a single image to load (Default: all images)
  55697. */
  55698. loadSingleImage?: number;
  55699. }
  55700. /**
  55701. * Used to load .Basis files
  55702. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55703. */
  55704. export class BasisTools {
  55705. private static _IgnoreSupportedFormats;
  55706. /**
  55707. * URL to use when loading the basis transcoder
  55708. */
  55709. static JSModuleURL: string;
  55710. /**
  55711. * URL to use when loading the wasm module for the transcoder
  55712. */
  55713. static WasmModuleURL: string;
  55714. /**
  55715. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55716. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55717. * @returns internal format corresponding to the Basis format
  55718. */
  55719. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55720. private static _WorkerPromise;
  55721. private static _Worker;
  55722. private static _actionId;
  55723. private static _CreateWorkerAsync;
  55724. /**
  55725. * Transcodes a loaded image file to compressed pixel data
  55726. * @param imageData image data to transcode
  55727. * @param config configuration options for the transcoding
  55728. * @returns a promise resulting in the transcoded image
  55729. */
  55730. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55731. /**
  55732. * Loads a texture from the transcode result
  55733. * @param texture texture load to
  55734. * @param transcodeResult the result of transcoding the basis file to load from
  55735. */
  55736. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55737. }
  55738. }
  55739. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55740. import { Nullable } from "babylonjs/types";
  55741. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55742. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55743. /**
  55744. * Loader for .basis file format
  55745. */
  55746. export class _BasisTextureLoader implements IInternalTextureLoader {
  55747. /**
  55748. * Defines whether the loader supports cascade loading the different faces.
  55749. */
  55750. readonly supportCascades: boolean;
  55751. /**
  55752. * This returns if the loader support the current file information.
  55753. * @param extension defines the file extension of the file being loaded
  55754. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55755. * @param fallback defines the fallback internal texture if any
  55756. * @param isBase64 defines whether the texture is encoded as a base64
  55757. * @param isBuffer defines whether the texture data are stored as a buffer
  55758. * @returns true if the loader can load the specified file
  55759. */
  55760. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55761. /**
  55762. * Transform the url before loading if required.
  55763. * @param rootUrl the url of the texture
  55764. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55765. * @returns the transformed texture
  55766. */
  55767. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55768. /**
  55769. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55770. * @param rootUrl the url of the texture
  55771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55772. * @returns the fallback texture
  55773. */
  55774. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55775. /**
  55776. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55777. * @param data contains the texture data
  55778. * @param texture defines the BabylonJS internal texture
  55779. * @param createPolynomials will be true if polynomials have been requested
  55780. * @param onLoad defines the callback to trigger once the texture is ready
  55781. * @param onError defines the callback to trigger in case of error
  55782. */
  55783. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55784. /**
  55785. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55786. * @param data contains the texture data
  55787. * @param texture defines the BabylonJS internal texture
  55788. * @param callback defines the method to call once ready to upload
  55789. */
  55790. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55791. }
  55792. }
  55793. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55794. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55795. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55796. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55797. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55798. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55799. }
  55800. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55801. import { Scene } from "babylonjs/scene";
  55802. import { Texture } from "babylonjs/Materials/Textures/texture";
  55803. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55804. /**
  55805. * 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.
  55806. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55808. */
  55809. export class CustomProceduralTexture extends ProceduralTexture {
  55810. private _animate;
  55811. private _time;
  55812. private _config;
  55813. private _texturePath;
  55814. /**
  55815. * Instantiates a new Custom Procedural Texture.
  55816. * 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.
  55817. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55818. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55819. * @param name Define the name of the texture
  55820. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55821. * @param size Define the size of the texture to create
  55822. * @param scene Define the scene the texture belongs to
  55823. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55824. * @param generateMipMaps Define if the texture should creates mip maps or not
  55825. */
  55826. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55827. private _loadJson;
  55828. /**
  55829. * Is the texture ready to be used ? (rendered at least once)
  55830. * @returns true if ready, otherwise, false.
  55831. */
  55832. isReady(): boolean;
  55833. /**
  55834. * Render the texture to its associated render target.
  55835. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55836. */
  55837. render(useCameraPostProcess?: boolean): void;
  55838. /**
  55839. * Update the list of dependant textures samplers in the shader.
  55840. */
  55841. updateTextures(): void;
  55842. /**
  55843. * Update the uniform values of the procedural texture in the shader.
  55844. */
  55845. updateShaderUniforms(): void;
  55846. /**
  55847. * Define if the texture animates or not.
  55848. */
  55849. animate: boolean;
  55850. }
  55851. }
  55852. declare module "babylonjs/Shaders/noise.fragment" {
  55853. /** @hidden */
  55854. export var noisePixelShader: {
  55855. name: string;
  55856. shader: string;
  55857. };
  55858. }
  55859. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55860. import { Nullable } from "babylonjs/types";
  55861. import { Scene } from "babylonjs/scene";
  55862. import { Texture } from "babylonjs/Materials/Textures/texture";
  55863. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55864. import "babylonjs/Shaders/noise.fragment";
  55865. /**
  55866. * Class used to generate noise procedural textures
  55867. */
  55868. export class NoiseProceduralTexture extends ProceduralTexture {
  55869. private _time;
  55870. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55871. brightness: number;
  55872. /** Defines the number of octaves to process */
  55873. octaves: number;
  55874. /** Defines the level of persistence (0.8 by default) */
  55875. persistence: number;
  55876. /** Gets or sets animation speed factor (default is 1) */
  55877. animationSpeedFactor: number;
  55878. /**
  55879. * Creates a new NoiseProceduralTexture
  55880. * @param name defines the name fo the texture
  55881. * @param size defines the size of the texture (default is 256)
  55882. * @param scene defines the hosting scene
  55883. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55884. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55885. */
  55886. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55887. private _updateShaderUniforms;
  55888. protected _getDefines(): string;
  55889. /** Generate the current state of the procedural texture */
  55890. render(useCameraPostProcess?: boolean): void;
  55891. /**
  55892. * Serializes this noise procedural texture
  55893. * @returns a serialized noise procedural texture object
  55894. */
  55895. serialize(): any;
  55896. /**
  55897. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55898. * @param parsedTexture defines parsed texture data
  55899. * @param scene defines the current scene
  55900. * @param rootUrl defines the root URL containing noise procedural texture information
  55901. * @returns a parsed NoiseProceduralTexture
  55902. */
  55903. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55904. }
  55905. }
  55906. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55907. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55908. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55909. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55910. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55911. }
  55912. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55913. import { Nullable } from "babylonjs/types";
  55914. import { Scene } from "babylonjs/scene";
  55915. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55917. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55918. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55919. /**
  55920. * Raw cube texture where the raw buffers are passed in
  55921. */
  55922. export class RawCubeTexture extends CubeTexture {
  55923. /**
  55924. * Creates a cube texture where the raw buffers are passed in.
  55925. * @param scene defines the scene the texture is attached to
  55926. * @param data defines the array of data to use to create each face
  55927. * @param size defines the size of the textures
  55928. * @param format defines the format of the data
  55929. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55930. * @param generateMipMaps defines if the engine should generate the mip levels
  55931. * @param invertY defines if data must be stored with Y axis inverted
  55932. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55933. * @param compression defines the compression used (null by default)
  55934. */
  55935. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55936. /**
  55937. * Updates the raw cube texture.
  55938. * @param data defines the data to store
  55939. * @param format defines the data format
  55940. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55941. * @param invertY defines if data must be stored with Y axis inverted
  55942. * @param compression defines the compression used (null by default)
  55943. * @param level defines which level of the texture to update
  55944. */
  55945. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55946. /**
  55947. * Updates a raw cube texture with RGBD encoded data.
  55948. * @param data defines the array of data [mipmap][face] to use to create each face
  55949. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55950. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55951. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55952. * @returns a promsie that resolves when the operation is complete
  55953. */
  55954. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55955. /**
  55956. * Clones the raw cube texture.
  55957. * @return a new cube texture
  55958. */
  55959. clone(): CubeTexture;
  55960. /** @hidden */
  55961. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55962. }
  55963. }
  55964. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55965. import { Scene } from "babylonjs/scene";
  55966. import { Texture } from "babylonjs/Materials/Textures/texture";
  55967. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55968. /**
  55969. * Class used to store 3D textures containing user data
  55970. */
  55971. export class RawTexture3D extends Texture {
  55972. /** Gets or sets the texture format to use */
  55973. format: number;
  55974. private _engine;
  55975. /**
  55976. * Create a new RawTexture3D
  55977. * @param data defines the data of the texture
  55978. * @param width defines the width of the texture
  55979. * @param height defines the height of the texture
  55980. * @param depth defines the depth of the texture
  55981. * @param format defines the texture format to use
  55982. * @param scene defines the hosting scene
  55983. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55984. * @param invertY defines if texture must be stored with Y axis inverted
  55985. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55986. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55987. */
  55988. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55989. /** Gets or sets the texture format to use */
  55990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55991. /**
  55992. * Update the texture with new data
  55993. * @param data defines the data to store in the texture
  55994. */
  55995. update(data: ArrayBufferView): void;
  55996. }
  55997. }
  55998. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55999. import { Scene } from "babylonjs/scene";
  56000. import { Texture } from "babylonjs/Materials/Textures/texture";
  56001. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56002. /**
  56003. * Class used to store 2D array textures containing user data
  56004. */
  56005. export class RawTexture2DArray extends Texture {
  56006. /** Gets or sets the texture format to use */
  56007. format: number;
  56008. private _engine;
  56009. /**
  56010. * Create a new RawTexture2DArray
  56011. * @param data defines the data of the texture
  56012. * @param width defines the width of the texture
  56013. * @param height defines the height of the texture
  56014. * @param depth defines the number of layers of the texture
  56015. * @param format defines the texture format to use
  56016. * @param scene defines the hosting scene
  56017. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56018. * @param invertY defines if texture must be stored with Y axis inverted
  56019. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56020. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56021. */
  56022. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56023. /** Gets or sets the texture format to use */
  56024. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56025. /**
  56026. * Update the texture with new data
  56027. * @param data defines the data to store in the texture
  56028. */
  56029. update(data: ArrayBufferView): void;
  56030. }
  56031. }
  56032. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56033. import { Scene } from "babylonjs/scene";
  56034. import { Plane } from "babylonjs/Maths/math.plane";
  56035. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56036. /**
  56037. * Creates a refraction texture used by refraction channel of the standard material.
  56038. * It is like a mirror but to see through a material.
  56039. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56040. */
  56041. export class RefractionTexture extends RenderTargetTexture {
  56042. /**
  56043. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56044. * 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.
  56045. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56046. */
  56047. refractionPlane: Plane;
  56048. /**
  56049. * Define how deep under the surface we should see.
  56050. */
  56051. depth: number;
  56052. /**
  56053. * Creates a refraction texture used by refraction channel of the standard material.
  56054. * It is like a mirror but to see through a material.
  56055. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56056. * @param name Define the texture name
  56057. * @param size Define the size of the underlying texture
  56058. * @param scene Define the scene the refraction belongs to
  56059. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56060. */
  56061. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56062. /**
  56063. * Clone the refraction texture.
  56064. * @returns the cloned texture
  56065. */
  56066. clone(): RefractionTexture;
  56067. /**
  56068. * Serialize the texture to a JSON representation you could use in Parse later on
  56069. * @returns the serialized JSON representation
  56070. */
  56071. serialize(): any;
  56072. }
  56073. }
  56074. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56075. import { Nullable } from "babylonjs/types";
  56076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56077. import { Matrix } from "babylonjs/Maths/math.vector";
  56078. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56079. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56080. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56081. import { Scene } from "babylonjs/scene";
  56082. /**
  56083. * Defines the options related to the creation of an HtmlElementTexture
  56084. */
  56085. export interface IHtmlElementTextureOptions {
  56086. /**
  56087. * Defines wether mip maps should be created or not.
  56088. */
  56089. generateMipMaps?: boolean;
  56090. /**
  56091. * Defines the sampling mode of the texture.
  56092. */
  56093. samplingMode?: number;
  56094. /**
  56095. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56096. */
  56097. engine: Nullable<ThinEngine>;
  56098. /**
  56099. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56100. */
  56101. scene: Nullable<Scene>;
  56102. }
  56103. /**
  56104. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56105. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56106. * is automatically managed.
  56107. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56108. * in your application.
  56109. *
  56110. * As the update is not automatic, you need to call them manually.
  56111. */
  56112. export class HtmlElementTexture extends BaseTexture {
  56113. /**
  56114. * The texture URL.
  56115. */
  56116. element: HTMLVideoElement | HTMLCanvasElement;
  56117. private static readonly DefaultOptions;
  56118. private _textureMatrix;
  56119. private _engine;
  56120. private _isVideo;
  56121. private _generateMipMaps;
  56122. private _samplingMode;
  56123. /**
  56124. * Instantiates a HtmlElementTexture from the following parameters.
  56125. *
  56126. * @param name Defines the name of the texture
  56127. * @param element Defines the video or canvas the texture is filled with
  56128. * @param options Defines the other none mandatory texture creation options
  56129. */
  56130. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56131. private _createInternalTexture;
  56132. /**
  56133. * Returns the texture matrix used in most of the material.
  56134. */
  56135. getTextureMatrix(): Matrix;
  56136. /**
  56137. * Updates the content of the texture.
  56138. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56139. */
  56140. update(invertY?: Nullable<boolean>): void;
  56141. }
  56142. }
  56143. declare module "babylonjs/Materials/Textures/index" {
  56144. export * from "babylonjs/Materials/Textures/baseTexture";
  56145. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56146. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56147. export * from "babylonjs/Materials/Textures/cubeTexture";
  56148. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56149. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56150. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56151. export * from "babylonjs/Materials/Textures/internalTexture";
  56152. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56153. export * from "babylonjs/Materials/Textures/Loaders/index";
  56154. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56155. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56156. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56157. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56158. export * from "babylonjs/Materials/Textures/rawTexture";
  56159. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56160. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56161. export * from "babylonjs/Materials/Textures/refractionTexture";
  56162. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56163. export * from "babylonjs/Materials/Textures/texture";
  56164. export * from "babylonjs/Materials/Textures/videoTexture";
  56165. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56166. }
  56167. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56168. /**
  56169. * Enum used to define the target of a block
  56170. */
  56171. export enum NodeMaterialBlockTargets {
  56172. /** Vertex shader */
  56173. Vertex = 1,
  56174. /** Fragment shader */
  56175. Fragment = 2,
  56176. /** Neutral */
  56177. Neutral = 4,
  56178. /** Vertex and Fragment */
  56179. VertexAndFragment = 3
  56180. }
  56181. }
  56182. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56183. /**
  56184. * Defines the kind of connection point for node based material
  56185. */
  56186. export enum NodeMaterialBlockConnectionPointTypes {
  56187. /** Float */
  56188. Float = 1,
  56189. /** Int */
  56190. Int = 2,
  56191. /** Vector2 */
  56192. Vector2 = 4,
  56193. /** Vector3 */
  56194. Vector3 = 8,
  56195. /** Vector4 */
  56196. Vector4 = 16,
  56197. /** Color3 */
  56198. Color3 = 32,
  56199. /** Color4 */
  56200. Color4 = 64,
  56201. /** Matrix */
  56202. Matrix = 128,
  56203. /** Detect type based on connection */
  56204. AutoDetect = 1024,
  56205. /** Output type that will be defined by input type */
  56206. BasedOnInput = 2048
  56207. }
  56208. }
  56209. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56210. /**
  56211. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56212. */
  56213. export enum NodeMaterialBlockConnectionPointMode {
  56214. /** Value is an uniform */
  56215. Uniform = 0,
  56216. /** Value is a mesh attribute */
  56217. Attribute = 1,
  56218. /** Value is a varying between vertex and fragment shaders */
  56219. Varying = 2,
  56220. /** Mode is undefined */
  56221. Undefined = 3
  56222. }
  56223. }
  56224. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56225. /**
  56226. * Enum used to define system values e.g. values automatically provided by the system
  56227. */
  56228. export enum NodeMaterialSystemValues {
  56229. /** World */
  56230. World = 1,
  56231. /** View */
  56232. View = 2,
  56233. /** Projection */
  56234. Projection = 3,
  56235. /** ViewProjection */
  56236. ViewProjection = 4,
  56237. /** WorldView */
  56238. WorldView = 5,
  56239. /** WorldViewProjection */
  56240. WorldViewProjection = 6,
  56241. /** CameraPosition */
  56242. CameraPosition = 7,
  56243. /** Fog Color */
  56244. FogColor = 8,
  56245. /** Delta time */
  56246. DeltaTime = 9
  56247. }
  56248. }
  56249. declare module "babylonjs/Materials/Node/Enums/index" {
  56250. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56251. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56252. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56253. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56254. }
  56255. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56257. /**
  56258. * Root class for all node material optimizers
  56259. */
  56260. export class NodeMaterialOptimizer {
  56261. /**
  56262. * Function used to optimize a NodeMaterial graph
  56263. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56264. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56265. */
  56266. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56267. }
  56268. }
  56269. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56273. import { Scene } from "babylonjs/scene";
  56274. /**
  56275. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56276. */
  56277. export class TransformBlock extends NodeMaterialBlock {
  56278. /**
  56279. * Defines the value to use to complement W value to transform it to a Vector4
  56280. */
  56281. complementW: number;
  56282. /**
  56283. * Defines the value to use to complement z value to transform it to a Vector4
  56284. */
  56285. complementZ: number;
  56286. /**
  56287. * Creates a new TransformBlock
  56288. * @param name defines the block name
  56289. */
  56290. constructor(name: string);
  56291. /**
  56292. * Gets the current class name
  56293. * @returns the class name
  56294. */
  56295. getClassName(): string;
  56296. /**
  56297. * Gets the vector input
  56298. */
  56299. readonly vector: NodeMaterialConnectionPoint;
  56300. /**
  56301. * Gets the output component
  56302. */
  56303. readonly output: NodeMaterialConnectionPoint;
  56304. /**
  56305. * Gets the matrix transform input
  56306. */
  56307. readonly transform: NodeMaterialConnectionPoint;
  56308. protected _buildBlock(state: NodeMaterialBuildState): this;
  56309. serialize(): any;
  56310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56311. protected _dumpPropertiesCode(): string;
  56312. }
  56313. }
  56314. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56318. /**
  56319. * Block used to output the vertex position
  56320. */
  56321. export class VertexOutputBlock extends NodeMaterialBlock {
  56322. /**
  56323. * Creates a new VertexOutputBlock
  56324. * @param name defines the block name
  56325. */
  56326. constructor(name: string);
  56327. /**
  56328. * Gets the current class name
  56329. * @returns the class name
  56330. */
  56331. getClassName(): string;
  56332. /**
  56333. * Gets the vector input component
  56334. */
  56335. readonly vector: NodeMaterialConnectionPoint;
  56336. protected _buildBlock(state: NodeMaterialBuildState): this;
  56337. }
  56338. }
  56339. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56340. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56341. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56342. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56343. /**
  56344. * Block used to output the final color
  56345. */
  56346. export class FragmentOutputBlock extends NodeMaterialBlock {
  56347. /**
  56348. * Create a new FragmentOutputBlock
  56349. * @param name defines the block name
  56350. */
  56351. constructor(name: string);
  56352. /**
  56353. * Gets the current class name
  56354. * @returns the class name
  56355. */
  56356. getClassName(): string;
  56357. /**
  56358. * Gets the rgba input component
  56359. */
  56360. readonly rgba: NodeMaterialConnectionPoint;
  56361. /**
  56362. * Gets the rgb input component
  56363. */
  56364. readonly rgb: NodeMaterialConnectionPoint;
  56365. /**
  56366. * Gets the a input component
  56367. */
  56368. readonly a: NodeMaterialConnectionPoint;
  56369. protected _buildBlock(state: NodeMaterialBuildState): this;
  56370. }
  56371. }
  56372. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56373. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56374. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56375. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56378. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56379. import { Effect } from "babylonjs/Materials/effect";
  56380. import { Mesh } from "babylonjs/Meshes/mesh";
  56381. import { Nullable } from "babylonjs/types";
  56382. import { Scene } from "babylonjs/scene";
  56383. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56384. /**
  56385. * Block used to read a reflection texture from a sampler
  56386. */
  56387. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56388. private _define3DName;
  56389. private _defineCubicName;
  56390. private _defineExplicitName;
  56391. private _defineProjectionName;
  56392. private _defineLocalCubicName;
  56393. private _defineSphericalName;
  56394. private _definePlanarName;
  56395. private _defineEquirectangularName;
  56396. private _defineMirroredEquirectangularFixedName;
  56397. private _defineEquirectangularFixedName;
  56398. private _defineSkyboxName;
  56399. private _cubeSamplerName;
  56400. private _2DSamplerName;
  56401. private _positionUVWName;
  56402. private _directionWName;
  56403. private _reflectionCoordsName;
  56404. private _reflection2DCoordsName;
  56405. private _reflectionColorName;
  56406. private _reflectionMatrixName;
  56407. /**
  56408. * Gets or sets the texture associated with the node
  56409. */
  56410. texture: Nullable<BaseTexture>;
  56411. /**
  56412. * Create a new TextureBlock
  56413. * @param name defines the block name
  56414. */
  56415. constructor(name: string);
  56416. /**
  56417. * Gets the current class name
  56418. * @returns the class name
  56419. */
  56420. getClassName(): string;
  56421. /**
  56422. * Gets the world position input component
  56423. */
  56424. readonly position: NodeMaterialConnectionPoint;
  56425. /**
  56426. * Gets the world position input component
  56427. */
  56428. readonly worldPosition: NodeMaterialConnectionPoint;
  56429. /**
  56430. * Gets the world normal input component
  56431. */
  56432. readonly worldNormal: NodeMaterialConnectionPoint;
  56433. /**
  56434. * Gets the world input component
  56435. */
  56436. readonly world: NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the camera (or eye) position component
  56439. */
  56440. readonly cameraPosition: NodeMaterialConnectionPoint;
  56441. /**
  56442. * Gets the view input component
  56443. */
  56444. readonly view: NodeMaterialConnectionPoint;
  56445. /**
  56446. * Gets the rgb output component
  56447. */
  56448. readonly rgb: NodeMaterialConnectionPoint;
  56449. /**
  56450. * Gets the r output component
  56451. */
  56452. readonly r: NodeMaterialConnectionPoint;
  56453. /**
  56454. * Gets the g output component
  56455. */
  56456. readonly g: NodeMaterialConnectionPoint;
  56457. /**
  56458. * Gets the b output component
  56459. */
  56460. readonly b: NodeMaterialConnectionPoint;
  56461. autoConfigure(material: NodeMaterial): void;
  56462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56463. isReady(): boolean;
  56464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56465. private _injectVertexCode;
  56466. private _writeOutput;
  56467. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56468. protected _dumpPropertiesCode(): string;
  56469. serialize(): any;
  56470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56471. }
  56472. }
  56473. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56475. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56476. import { Scene } from "babylonjs/scene";
  56477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56478. import { Matrix } from "babylonjs/Maths/math.vector";
  56479. import { Mesh } from "babylonjs/Meshes/mesh";
  56480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56481. import { Observable } from "babylonjs/Misc/observable";
  56482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56483. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56484. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56485. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56486. import { Nullable } from "babylonjs/types";
  56487. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56488. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56489. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56490. /**
  56491. * Interface used to configure the node material editor
  56492. */
  56493. export interface INodeMaterialEditorOptions {
  56494. /** Define the URl to load node editor script */
  56495. editorURL?: string;
  56496. }
  56497. /** @hidden */
  56498. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56499. /** BONES */
  56500. NUM_BONE_INFLUENCERS: number;
  56501. BonesPerMesh: number;
  56502. BONETEXTURE: boolean;
  56503. /** MORPH TARGETS */
  56504. MORPHTARGETS: boolean;
  56505. MORPHTARGETS_NORMAL: boolean;
  56506. MORPHTARGETS_TANGENT: boolean;
  56507. MORPHTARGETS_UV: boolean;
  56508. NUM_MORPH_INFLUENCERS: number;
  56509. /** IMAGE PROCESSING */
  56510. IMAGEPROCESSING: boolean;
  56511. VIGNETTE: boolean;
  56512. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56513. VIGNETTEBLENDMODEOPAQUE: boolean;
  56514. TONEMAPPING: boolean;
  56515. TONEMAPPING_ACES: boolean;
  56516. CONTRAST: boolean;
  56517. EXPOSURE: boolean;
  56518. COLORCURVES: boolean;
  56519. COLORGRADING: boolean;
  56520. COLORGRADING3D: boolean;
  56521. SAMPLER3DGREENDEPTH: boolean;
  56522. SAMPLER3DBGRMAP: boolean;
  56523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56524. /** MISC. */
  56525. BUMPDIRECTUV: number;
  56526. constructor();
  56527. setValue(name: string, value: boolean): void;
  56528. }
  56529. /**
  56530. * Class used to configure NodeMaterial
  56531. */
  56532. export interface INodeMaterialOptions {
  56533. /**
  56534. * Defines if blocks should emit comments
  56535. */
  56536. emitComments: boolean;
  56537. }
  56538. /**
  56539. * Class used to create a node based material built by assembling shader blocks
  56540. */
  56541. export class NodeMaterial extends PushMaterial {
  56542. private static _BuildIdGenerator;
  56543. private _options;
  56544. private _vertexCompilationState;
  56545. private _fragmentCompilationState;
  56546. private _sharedData;
  56547. private _buildId;
  56548. private _buildWasSuccessful;
  56549. private _cachedWorldViewMatrix;
  56550. private _cachedWorldViewProjectionMatrix;
  56551. private _optimizers;
  56552. private _animationFrame;
  56553. /** Define the URl to load node editor script */
  56554. static EditorURL: string;
  56555. private BJSNODEMATERIALEDITOR;
  56556. /** Get the inspector from bundle or global */
  56557. private _getGlobalNodeMaterialEditor;
  56558. /**
  56559. * Gets or sets data used by visual editor
  56560. * @see https://nme.babylonjs.com
  56561. */
  56562. editorData: any;
  56563. /**
  56564. * 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)
  56565. */
  56566. ignoreAlpha: boolean;
  56567. /**
  56568. * Defines the maximum number of lights that can be used in the material
  56569. */
  56570. maxSimultaneousLights: number;
  56571. /**
  56572. * Observable raised when the material is built
  56573. */
  56574. onBuildObservable: Observable<NodeMaterial>;
  56575. /**
  56576. * Gets or sets the root nodes of the material vertex shader
  56577. */
  56578. _vertexOutputNodes: NodeMaterialBlock[];
  56579. /**
  56580. * Gets or sets the root nodes of the material fragment (pixel) shader
  56581. */
  56582. _fragmentOutputNodes: NodeMaterialBlock[];
  56583. /** Gets or sets options to control the node material overall behavior */
  56584. options: INodeMaterialOptions;
  56585. /**
  56586. * Default configuration related to image processing available in the standard Material.
  56587. */
  56588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56589. /**
  56590. * Gets the image processing configuration used either in this material.
  56591. */
  56592. /**
  56593. * Sets the Default image processing configuration used either in the this material.
  56594. *
  56595. * If sets to null, the scene one is in use.
  56596. */
  56597. imageProcessingConfiguration: ImageProcessingConfiguration;
  56598. /**
  56599. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56600. */
  56601. attachedBlocks: NodeMaterialBlock[];
  56602. /**
  56603. * Create a new node based material
  56604. * @param name defines the material name
  56605. * @param scene defines the hosting scene
  56606. * @param options defines creation option
  56607. */
  56608. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56609. /**
  56610. * Gets the current class name of the material e.g. "NodeMaterial"
  56611. * @returns the class name
  56612. */
  56613. getClassName(): string;
  56614. /**
  56615. * Keep track of the image processing observer to allow dispose and replace.
  56616. */
  56617. private _imageProcessingObserver;
  56618. /**
  56619. * Attaches a new image processing configuration to the Standard Material.
  56620. * @param configuration
  56621. */
  56622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56623. /**
  56624. * Get a block by its name
  56625. * @param name defines the name of the block to retrieve
  56626. * @returns the required block or null if not found
  56627. */
  56628. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56629. /**
  56630. * Get a block by its name
  56631. * @param predicate defines the predicate used to find the good candidate
  56632. * @returns the required block or null if not found
  56633. */
  56634. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56635. /**
  56636. * Get an input block by its name
  56637. * @param predicate defines the predicate used to find the good candidate
  56638. * @returns the required input block or null if not found
  56639. */
  56640. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56641. /**
  56642. * Gets the list of input blocks attached to this material
  56643. * @returns an array of InputBlocks
  56644. */
  56645. getInputBlocks(): InputBlock[];
  56646. /**
  56647. * Adds a new optimizer to the list of optimizers
  56648. * @param optimizer defines the optimizers to add
  56649. * @returns the current material
  56650. */
  56651. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56652. /**
  56653. * Remove an optimizer from the list of optimizers
  56654. * @param optimizer defines the optimizers to remove
  56655. * @returns the current material
  56656. */
  56657. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56658. /**
  56659. * Add a new block to the list of output nodes
  56660. * @param node defines the node to add
  56661. * @returns the current material
  56662. */
  56663. addOutputNode(node: NodeMaterialBlock): this;
  56664. /**
  56665. * Remove a block from the list of root nodes
  56666. * @param node defines the node to remove
  56667. * @returns the current material
  56668. */
  56669. removeOutputNode(node: NodeMaterialBlock): this;
  56670. private _addVertexOutputNode;
  56671. private _removeVertexOutputNode;
  56672. private _addFragmentOutputNode;
  56673. private _removeFragmentOutputNode;
  56674. /**
  56675. * Specifies if the material will require alpha blending
  56676. * @returns a boolean specifying if alpha blending is needed
  56677. */
  56678. needAlphaBlending(): boolean;
  56679. /**
  56680. * Specifies if this material should be rendered in alpha test mode
  56681. * @returns a boolean specifying if an alpha test is needed.
  56682. */
  56683. needAlphaTesting(): boolean;
  56684. private _initializeBlock;
  56685. private _resetDualBlocks;
  56686. /**
  56687. * Remove a block from the current node material
  56688. * @param block defines the block to remove
  56689. */
  56690. removeBlock(block: NodeMaterialBlock): void;
  56691. /**
  56692. * Build the material and generates the inner effect
  56693. * @param verbose defines if the build should log activity
  56694. */
  56695. build(verbose?: boolean): void;
  56696. /**
  56697. * Runs an otpimization phase to try to improve the shader code
  56698. */
  56699. optimize(): void;
  56700. private _prepareDefinesForAttributes;
  56701. /**
  56702. * Get if the submesh is ready to be used and all its information available.
  56703. * Child classes can use it to update shaders
  56704. * @param mesh defines the mesh to check
  56705. * @param subMesh defines which submesh to check
  56706. * @param useInstances specifies that instances should be used
  56707. * @returns a boolean indicating that the submesh is ready or not
  56708. */
  56709. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56710. /**
  56711. * Get a string representing the shaders built by the current node graph
  56712. */
  56713. readonly compiledShaders: string;
  56714. /**
  56715. * Binds the world matrix to the material
  56716. * @param world defines the world transformation matrix
  56717. */
  56718. bindOnlyWorldMatrix(world: Matrix): void;
  56719. /**
  56720. * Binds the submesh to this material by preparing the effect and shader to draw
  56721. * @param world defines the world transformation matrix
  56722. * @param mesh defines the mesh containing the submesh
  56723. * @param subMesh defines the submesh to bind the material to
  56724. */
  56725. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56726. /**
  56727. * Gets the active textures from the material
  56728. * @returns an array of textures
  56729. */
  56730. getActiveTextures(): BaseTexture[];
  56731. /**
  56732. * Gets the list of texture blocks
  56733. * @returns an array of texture blocks
  56734. */
  56735. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56736. /**
  56737. * Specifies if the material uses a texture
  56738. * @param texture defines the texture to check against the material
  56739. * @returns a boolean specifying if the material uses the texture
  56740. */
  56741. hasTexture(texture: BaseTexture): boolean;
  56742. /**
  56743. * Disposes the material
  56744. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56745. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56746. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56747. */
  56748. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56749. /** Creates the node editor window. */
  56750. private _createNodeEditor;
  56751. /**
  56752. * Launch the node material editor
  56753. * @param config Define the configuration of the editor
  56754. * @return a promise fulfilled when the node editor is visible
  56755. */
  56756. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56757. /**
  56758. * Clear the current material
  56759. */
  56760. clear(): void;
  56761. /**
  56762. * Clear the current material and set it to a default state
  56763. */
  56764. setToDefault(): void;
  56765. /**
  56766. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56767. * @param url defines the url to load from
  56768. * @returns a promise that will fullfil when the material is fully loaded
  56769. */
  56770. loadAsync(url: string): Promise<void>;
  56771. private _gatherBlocks;
  56772. /**
  56773. * Generate a string containing the code declaration required to create an equivalent of this material
  56774. * @returns a string
  56775. */
  56776. generateCode(): string;
  56777. /**
  56778. * Serializes this material in a JSON representation
  56779. * @returns the serialized material object
  56780. */
  56781. serialize(): any;
  56782. private _restoreConnections;
  56783. /**
  56784. * Clear the current graph and load a new one from a serialization object
  56785. * @param source defines the JSON representation of the material
  56786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56787. */
  56788. loadFromSerialization(source: any, rootUrl?: string): void;
  56789. /**
  56790. * Creates a node material from parsed material data
  56791. * @param source defines the JSON representation of the material
  56792. * @param scene defines the hosting scene
  56793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56794. * @returns a new node material
  56795. */
  56796. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56797. /**
  56798. * Creates a new node material set to default basic configuration
  56799. * @param name defines the name of the material
  56800. * @param scene defines the hosting scene
  56801. * @returns a new NodeMaterial
  56802. */
  56803. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56804. }
  56805. }
  56806. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56812. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56813. import { Effect } from "babylonjs/Materials/effect";
  56814. import { Mesh } from "babylonjs/Meshes/mesh";
  56815. import { Nullable } from "babylonjs/types";
  56816. import { Texture } from "babylonjs/Materials/Textures/texture";
  56817. import { Scene } from "babylonjs/scene";
  56818. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56819. /**
  56820. * Block used to read a texture from a sampler
  56821. */
  56822. export class TextureBlock extends NodeMaterialBlock {
  56823. private _defineName;
  56824. private _linearDefineName;
  56825. private _tempTextureRead;
  56826. private _samplerName;
  56827. private _transformedUVName;
  56828. private _textureTransformName;
  56829. private _textureInfoName;
  56830. private _mainUVName;
  56831. private _mainUVDefineName;
  56832. /**
  56833. * Gets or sets the texture associated with the node
  56834. */
  56835. texture: Nullable<Texture>;
  56836. /**
  56837. * Create a new TextureBlock
  56838. * @param name defines the block name
  56839. */
  56840. constructor(name: string);
  56841. /**
  56842. * Gets the current class name
  56843. * @returns the class name
  56844. */
  56845. getClassName(): string;
  56846. /**
  56847. * Gets the uv input component
  56848. */
  56849. readonly uv: NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the rgba output component
  56852. */
  56853. readonly rgba: NodeMaterialConnectionPoint;
  56854. /**
  56855. * Gets the rgb output component
  56856. */
  56857. readonly rgb: NodeMaterialConnectionPoint;
  56858. /**
  56859. * Gets the r output component
  56860. */
  56861. readonly r: NodeMaterialConnectionPoint;
  56862. /**
  56863. * Gets the g output component
  56864. */
  56865. readonly g: NodeMaterialConnectionPoint;
  56866. /**
  56867. * Gets the b output component
  56868. */
  56869. readonly b: NodeMaterialConnectionPoint;
  56870. /**
  56871. * Gets the a output component
  56872. */
  56873. readonly a: NodeMaterialConnectionPoint;
  56874. readonly target: NodeMaterialBlockTargets;
  56875. autoConfigure(material: NodeMaterial): void;
  56876. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56878. private _getTextureBase;
  56879. isReady(): boolean;
  56880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56881. private readonly _isMixed;
  56882. private _injectVertexCode;
  56883. private _writeTextureRead;
  56884. private _writeOutput;
  56885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56886. protected _dumpPropertiesCode(): string;
  56887. serialize(): any;
  56888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56889. }
  56890. }
  56891. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56894. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56895. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56896. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56897. import { Scene } from "babylonjs/scene";
  56898. /**
  56899. * Class used to store shared data between 2 NodeMaterialBuildState
  56900. */
  56901. export class NodeMaterialBuildStateSharedData {
  56902. /**
  56903. * Gets the list of emitted varyings
  56904. */
  56905. temps: string[];
  56906. /**
  56907. * Gets the list of emitted varyings
  56908. */
  56909. varyings: string[];
  56910. /**
  56911. * Gets the varying declaration string
  56912. */
  56913. varyingDeclaration: string;
  56914. /**
  56915. * Input blocks
  56916. */
  56917. inputBlocks: InputBlock[];
  56918. /**
  56919. * Input blocks
  56920. */
  56921. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56922. /**
  56923. * Bindable blocks (Blocks that need to set data to the effect)
  56924. */
  56925. bindableBlocks: NodeMaterialBlock[];
  56926. /**
  56927. * List of blocks that can provide a compilation fallback
  56928. */
  56929. blocksWithFallbacks: NodeMaterialBlock[];
  56930. /**
  56931. * List of blocks that can provide a define update
  56932. */
  56933. blocksWithDefines: NodeMaterialBlock[];
  56934. /**
  56935. * List of blocks that can provide a repeatable content
  56936. */
  56937. repeatableContentBlocks: NodeMaterialBlock[];
  56938. /**
  56939. * List of blocks that can provide a dynamic list of uniforms
  56940. */
  56941. dynamicUniformBlocks: NodeMaterialBlock[];
  56942. /**
  56943. * List of blocks that can block the isReady function for the material
  56944. */
  56945. blockingBlocks: NodeMaterialBlock[];
  56946. /**
  56947. * Gets the list of animated inputs
  56948. */
  56949. animatedInputs: InputBlock[];
  56950. /**
  56951. * Build Id used to avoid multiple recompilations
  56952. */
  56953. buildId: number;
  56954. /** List of emitted variables */
  56955. variableNames: {
  56956. [key: string]: number;
  56957. };
  56958. /** List of emitted defines */
  56959. defineNames: {
  56960. [key: string]: number;
  56961. };
  56962. /** Should emit comments? */
  56963. emitComments: boolean;
  56964. /** Emit build activity */
  56965. verbose: boolean;
  56966. /** Gets or sets the hosting scene */
  56967. scene: Scene;
  56968. /**
  56969. * Gets the compilation hints emitted at compilation time
  56970. */
  56971. hints: {
  56972. needWorldViewMatrix: boolean;
  56973. needWorldViewProjectionMatrix: boolean;
  56974. needAlphaBlending: boolean;
  56975. needAlphaTesting: boolean;
  56976. };
  56977. /**
  56978. * List of compilation checks
  56979. */
  56980. checks: {
  56981. emitVertex: boolean;
  56982. emitFragment: boolean;
  56983. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56984. };
  56985. /** Creates a new shared data */
  56986. constructor();
  56987. /**
  56988. * Emits console errors and exceptions if there is a failing check
  56989. */
  56990. emitErrors(): void;
  56991. }
  56992. }
  56993. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56994. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56995. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56996. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56997. /**
  56998. * Class used to store node based material build state
  56999. */
  57000. export class NodeMaterialBuildState {
  57001. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57002. supportUniformBuffers: boolean;
  57003. /**
  57004. * Gets the list of emitted attributes
  57005. */
  57006. attributes: string[];
  57007. /**
  57008. * Gets the list of emitted uniforms
  57009. */
  57010. uniforms: string[];
  57011. /**
  57012. * Gets the list of emitted constants
  57013. */
  57014. constants: string[];
  57015. /**
  57016. * Gets the list of emitted samplers
  57017. */
  57018. samplers: string[];
  57019. /**
  57020. * Gets the list of emitted functions
  57021. */
  57022. functions: {
  57023. [key: string]: string;
  57024. };
  57025. /**
  57026. * Gets the list of emitted extensions
  57027. */
  57028. extensions: {
  57029. [key: string]: string;
  57030. };
  57031. /**
  57032. * Gets the target of the compilation state
  57033. */
  57034. target: NodeMaterialBlockTargets;
  57035. /**
  57036. * Gets the list of emitted counters
  57037. */
  57038. counters: {
  57039. [key: string]: number;
  57040. };
  57041. /**
  57042. * Shared data between multiple NodeMaterialBuildState instances
  57043. */
  57044. sharedData: NodeMaterialBuildStateSharedData;
  57045. /** @hidden */
  57046. _vertexState: NodeMaterialBuildState;
  57047. /** @hidden */
  57048. _attributeDeclaration: string;
  57049. /** @hidden */
  57050. _uniformDeclaration: string;
  57051. /** @hidden */
  57052. _constantDeclaration: string;
  57053. /** @hidden */
  57054. _samplerDeclaration: string;
  57055. /** @hidden */
  57056. _varyingTransfer: string;
  57057. private _repeatableContentAnchorIndex;
  57058. /** @hidden */
  57059. _builtCompilationString: string;
  57060. /**
  57061. * Gets the emitted compilation strings
  57062. */
  57063. compilationString: string;
  57064. /**
  57065. * Finalize the compilation strings
  57066. * @param state defines the current compilation state
  57067. */
  57068. finalize(state: NodeMaterialBuildState): void;
  57069. /** @hidden */
  57070. readonly _repeatableContentAnchor: string;
  57071. /** @hidden */
  57072. _getFreeVariableName(prefix: string): string;
  57073. /** @hidden */
  57074. _getFreeDefineName(prefix: string): string;
  57075. /** @hidden */
  57076. _excludeVariableName(name: string): void;
  57077. /** @hidden */
  57078. _emit2DSampler(name: string): void;
  57079. /** @hidden */
  57080. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57081. /** @hidden */
  57082. _emitExtension(name: string, extension: string): void;
  57083. /** @hidden */
  57084. _emitFunction(name: string, code: string, comments: string): void;
  57085. /** @hidden */
  57086. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57087. replaceStrings?: {
  57088. search: RegExp;
  57089. replace: string;
  57090. }[];
  57091. repeatKey?: string;
  57092. }): string;
  57093. /** @hidden */
  57094. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57095. repeatKey?: string;
  57096. removeAttributes?: boolean;
  57097. removeUniforms?: boolean;
  57098. removeVaryings?: boolean;
  57099. removeIfDef?: boolean;
  57100. replaceStrings?: {
  57101. search: RegExp;
  57102. replace: string;
  57103. }[];
  57104. }, storeKey?: string): void;
  57105. /** @hidden */
  57106. _registerTempVariable(name: string): boolean;
  57107. /** @hidden */
  57108. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57109. /** @hidden */
  57110. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57111. /** @hidden */
  57112. _emitFloat(value: number): string;
  57113. }
  57114. }
  57115. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57116. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57118. import { Nullable } from "babylonjs/types";
  57119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57120. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57121. import { Effect } from "babylonjs/Materials/effect";
  57122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57123. import { Mesh } from "babylonjs/Meshes/mesh";
  57124. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57125. import { Scene } from "babylonjs/scene";
  57126. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57127. /**
  57128. * Defines a block that can be used inside a node based material
  57129. */
  57130. export class NodeMaterialBlock {
  57131. private _buildId;
  57132. private _buildTarget;
  57133. private _target;
  57134. private _isFinalMerger;
  57135. private _isInput;
  57136. protected _isUnique: boolean;
  57137. /** @hidden */
  57138. _codeVariableName: string;
  57139. /** @hidden */
  57140. _inputs: NodeMaterialConnectionPoint[];
  57141. /** @hidden */
  57142. _outputs: NodeMaterialConnectionPoint[];
  57143. /** @hidden */
  57144. _preparationId: number;
  57145. /**
  57146. * Gets or sets the name of the block
  57147. */
  57148. name: string;
  57149. /**
  57150. * Gets or sets the unique id of the node
  57151. */
  57152. uniqueId: number;
  57153. /**
  57154. * Gets or sets the comments associated with this block
  57155. */
  57156. comments: string;
  57157. /**
  57158. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57159. */
  57160. readonly isUnique: boolean;
  57161. /**
  57162. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57163. */
  57164. readonly isFinalMerger: boolean;
  57165. /**
  57166. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57167. */
  57168. readonly isInput: boolean;
  57169. /**
  57170. * Gets or sets the build Id
  57171. */
  57172. buildId: number;
  57173. /**
  57174. * Gets or sets the target of the block
  57175. */
  57176. target: NodeMaterialBlockTargets;
  57177. /**
  57178. * Gets the list of input points
  57179. */
  57180. readonly inputs: NodeMaterialConnectionPoint[];
  57181. /** Gets the list of output points */
  57182. readonly outputs: NodeMaterialConnectionPoint[];
  57183. /**
  57184. * Find an input by its name
  57185. * @param name defines the name of the input to look for
  57186. * @returns the input or null if not found
  57187. */
  57188. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57189. /**
  57190. * Find an output by its name
  57191. * @param name defines the name of the outputto look for
  57192. * @returns the output or null if not found
  57193. */
  57194. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57195. /**
  57196. * Creates a new NodeMaterialBlock
  57197. * @param name defines the block name
  57198. * @param target defines the target of that block (Vertex by default)
  57199. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57200. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57201. */
  57202. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57203. /**
  57204. * Initialize the block and prepare the context for build
  57205. * @param state defines the state that will be used for the build
  57206. */
  57207. initialize(state: NodeMaterialBuildState): void;
  57208. /**
  57209. * Bind data to effect. Will only be called for blocks with isBindable === true
  57210. * @param effect defines the effect to bind data to
  57211. * @param nodeMaterial defines the hosting NodeMaterial
  57212. * @param mesh defines the mesh that will be rendered
  57213. */
  57214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57215. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57216. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57217. protected _writeFloat(value: number): string;
  57218. /**
  57219. * Gets the current class name e.g. "NodeMaterialBlock"
  57220. * @returns the class name
  57221. */
  57222. getClassName(): string;
  57223. /**
  57224. * Register a new input. Must be called inside a block constructor
  57225. * @param name defines the connection point name
  57226. * @param type defines the connection point type
  57227. * @param isOptional defines a boolean indicating that this input can be omitted
  57228. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57229. * @returns the current block
  57230. */
  57231. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57232. /**
  57233. * Register a new output. Must be called inside a block constructor
  57234. * @param name defines the connection point name
  57235. * @param type defines the connection point type
  57236. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57237. * @returns the current block
  57238. */
  57239. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57240. /**
  57241. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57242. * @param forOutput defines an optional connection point to check compatibility with
  57243. * @returns the first available input or null
  57244. */
  57245. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57246. /**
  57247. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57248. * @param forBlock defines an optional block to check compatibility with
  57249. * @returns the first available input or null
  57250. */
  57251. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57252. /**
  57253. * Gets the sibling of the given output
  57254. * @param current defines the current output
  57255. * @returns the next output in the list or null
  57256. */
  57257. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57258. /**
  57259. * Connect current block with another block
  57260. * @param other defines the block to connect with
  57261. * @param options define the various options to help pick the right connections
  57262. * @returns the current block
  57263. */
  57264. connectTo(other: NodeMaterialBlock, options?: {
  57265. input?: string;
  57266. output?: string;
  57267. outputSwizzle?: string;
  57268. }): this | undefined;
  57269. protected _buildBlock(state: NodeMaterialBuildState): void;
  57270. /**
  57271. * Add uniforms, samplers and uniform buffers at compilation time
  57272. * @param state defines the state to update
  57273. * @param nodeMaterial defines the node material requesting the update
  57274. * @param defines defines the material defines to update
  57275. * @param uniformBuffers defines the list of uniform buffer names
  57276. */
  57277. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57278. /**
  57279. * Add potential fallbacks if shader compilation fails
  57280. * @param mesh defines the mesh to be rendered
  57281. * @param fallbacks defines the current prioritized list of fallbacks
  57282. */
  57283. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57284. /**
  57285. * Initialize defines for shader compilation
  57286. * @param mesh defines the mesh to be rendered
  57287. * @param nodeMaterial defines the node material requesting the update
  57288. * @param defines defines the material defines to update
  57289. * @param useInstances specifies that instances should be used
  57290. */
  57291. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57292. /**
  57293. * Update defines for shader compilation
  57294. * @param mesh defines the mesh to be rendered
  57295. * @param nodeMaterial defines the node material requesting the update
  57296. * @param defines defines the material defines to update
  57297. * @param useInstances specifies that instances should be used
  57298. */
  57299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57300. /**
  57301. * Lets the block try to connect some inputs automatically
  57302. * @param material defines the hosting NodeMaterial
  57303. */
  57304. autoConfigure(material: NodeMaterial): void;
  57305. /**
  57306. * Function called when a block is declared as repeatable content generator
  57307. * @param vertexShaderState defines the current compilation state for the vertex shader
  57308. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57309. * @param mesh defines the mesh to be rendered
  57310. * @param defines defines the material defines to update
  57311. */
  57312. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57313. /**
  57314. * Checks if the block is ready
  57315. * @param mesh defines the mesh to be rendered
  57316. * @param nodeMaterial defines the node material requesting the update
  57317. * @param defines defines the material defines to update
  57318. * @param useInstances specifies that instances should be used
  57319. * @returns true if the block is ready
  57320. */
  57321. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57322. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57323. private _processBuild;
  57324. /**
  57325. * Compile the current node and generate the shader code
  57326. * @param state defines the current compilation state (uniforms, samplers, current string)
  57327. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57328. * @returns true if already built
  57329. */
  57330. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57331. protected _inputRename(name: string): string;
  57332. protected _outputRename(name: string): string;
  57333. protected _dumpPropertiesCode(): string;
  57334. /** @hidden */
  57335. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57336. /** @hidden */
  57337. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57338. /**
  57339. * Clone the current block to a new identical block
  57340. * @param scene defines the hosting scene
  57341. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57342. * @returns a copy of the current block
  57343. */
  57344. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57345. /**
  57346. * Serializes this block in a JSON representation
  57347. * @returns the serialized block object
  57348. */
  57349. serialize(): any;
  57350. /** @hidden */
  57351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57352. /**
  57353. * Release resources
  57354. */
  57355. dispose(): void;
  57356. }
  57357. }
  57358. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57359. /**
  57360. * Enum defining the type of animations supported by InputBlock
  57361. */
  57362. export enum AnimatedInputBlockTypes {
  57363. /** No animation */
  57364. None = 0,
  57365. /** Time based animation. Will only work for floats */
  57366. Time = 1
  57367. }
  57368. }
  57369. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57371. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57372. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57373. import { Nullable } from "babylonjs/types";
  57374. import { Effect } from "babylonjs/Materials/effect";
  57375. import { Matrix } from "babylonjs/Maths/math.vector";
  57376. import { Scene } from "babylonjs/scene";
  57377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57379. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57380. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57381. /**
  57382. * Block used to expose an input value
  57383. */
  57384. export class InputBlock extends NodeMaterialBlock {
  57385. private _mode;
  57386. private _associatedVariableName;
  57387. private _storedValue;
  57388. private _valueCallback;
  57389. private _type;
  57390. private _animationType;
  57391. /** Gets or set a value used to limit the range of float values */
  57392. min: number;
  57393. /** Gets or set a value used to limit the range of float values */
  57394. max: number;
  57395. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57396. matrixMode: number;
  57397. /** @hidden */
  57398. _systemValue: Nullable<NodeMaterialSystemValues>;
  57399. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57400. visibleInInspector: boolean;
  57401. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57402. isConstant: boolean;
  57403. /**
  57404. * Gets or sets the connection point type (default is float)
  57405. */
  57406. readonly type: NodeMaterialBlockConnectionPointTypes;
  57407. /**
  57408. * Creates a new InputBlock
  57409. * @param name defines the block name
  57410. * @param target defines the target of that block (Vertex by default)
  57411. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57412. */
  57413. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57414. /**
  57415. * Gets the output component
  57416. */
  57417. readonly output: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Set the source of this connection point to a vertex attribute
  57420. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57421. * @returns the current connection point
  57422. */
  57423. setAsAttribute(attributeName?: string): InputBlock;
  57424. /**
  57425. * Set the source of this connection point to a system value
  57426. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57427. * @returns the current connection point
  57428. */
  57429. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57430. /**
  57431. * Gets or sets the value of that point.
  57432. * Please note that this value will be ignored if valueCallback is defined
  57433. */
  57434. value: any;
  57435. /**
  57436. * Gets or sets a callback used to get the value of that point.
  57437. * Please note that setting this value will force the connection point to ignore the value property
  57438. */
  57439. valueCallback: () => any;
  57440. /**
  57441. * Gets or sets the associated variable name in the shader
  57442. */
  57443. associatedVariableName: string;
  57444. /** Gets or sets the type of animation applied to the input */
  57445. animationType: AnimatedInputBlockTypes;
  57446. /**
  57447. * Gets a boolean indicating that this connection point not defined yet
  57448. */
  57449. readonly isUndefined: boolean;
  57450. /**
  57451. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57452. * In this case the connection point name must be the name of the uniform to use.
  57453. * Can only be set on inputs
  57454. */
  57455. isUniform: boolean;
  57456. /**
  57457. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57458. * In this case the connection point name must be the name of the attribute to use
  57459. * Can only be set on inputs
  57460. */
  57461. isAttribute: boolean;
  57462. /**
  57463. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57464. * Can only be set on exit points
  57465. */
  57466. isVarying: boolean;
  57467. /**
  57468. * Gets a boolean indicating that the current connection point is a system value
  57469. */
  57470. readonly isSystemValue: boolean;
  57471. /**
  57472. * Gets or sets the current well known value or null if not defined as a system value
  57473. */
  57474. systemValue: Nullable<NodeMaterialSystemValues>;
  57475. /**
  57476. * Gets the current class name
  57477. * @returns the class name
  57478. */
  57479. getClassName(): string;
  57480. /**
  57481. * Animate the input if animationType !== None
  57482. * @param scene defines the rendering scene
  57483. */
  57484. animate(scene: Scene): void;
  57485. private _emitDefine;
  57486. initialize(state: NodeMaterialBuildState): void;
  57487. /**
  57488. * Set the input block to its default value (based on its type)
  57489. */
  57490. setDefaultValue(): void;
  57491. private _emitConstant;
  57492. private _emit;
  57493. /** @hidden */
  57494. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57495. /** @hidden */
  57496. _transmit(effect: Effect, scene: Scene): void;
  57497. protected _buildBlock(state: NodeMaterialBuildState): void;
  57498. protected _dumpPropertiesCode(): string;
  57499. serialize(): any;
  57500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57501. }
  57502. }
  57503. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57504. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57505. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57506. import { Nullable } from "babylonjs/types";
  57507. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57508. import { Observable } from "babylonjs/Misc/observable";
  57509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57510. /**
  57511. * Enum used to define the compatibility state between two connection points
  57512. */
  57513. export enum NodeMaterialConnectionPointCompatibilityStates {
  57514. /** Points are compatibles */
  57515. Compatible = 0,
  57516. /** Points are incompatible because of their types */
  57517. TypeIncompatible = 1,
  57518. /** Points are incompatible because of their targets (vertex vs fragment) */
  57519. TargetIncompatible = 2
  57520. }
  57521. /**
  57522. * Defines the direction of a connection point
  57523. */
  57524. export enum NodeMaterialConnectionPointDirection {
  57525. /** Input */
  57526. Input = 0,
  57527. /** Output */
  57528. Output = 1
  57529. }
  57530. /**
  57531. * Defines a connection point for a block
  57532. */
  57533. export class NodeMaterialConnectionPoint {
  57534. /** @hidden */
  57535. _ownerBlock: NodeMaterialBlock;
  57536. /** @hidden */
  57537. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57538. private _endpoints;
  57539. private _associatedVariableName;
  57540. private _direction;
  57541. /** @hidden */
  57542. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57543. /** @hidden */
  57544. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57545. private _type;
  57546. /** @hidden */
  57547. _enforceAssociatedVariableName: boolean;
  57548. /** Gets the direction of the point */
  57549. readonly direction: NodeMaterialConnectionPointDirection;
  57550. /**
  57551. * Gets or sets the additional types supported by this connection point
  57552. */
  57553. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57554. /**
  57555. * Gets or sets the additional types excluded by this connection point
  57556. */
  57557. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57558. /**
  57559. * Observable triggered when this point is connected
  57560. */
  57561. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57562. /**
  57563. * Gets or sets the associated variable name in the shader
  57564. */
  57565. associatedVariableName: string;
  57566. /**
  57567. * Gets or sets the connection point type (default is float)
  57568. */
  57569. type: NodeMaterialBlockConnectionPointTypes;
  57570. /**
  57571. * Gets or sets the connection point name
  57572. */
  57573. name: string;
  57574. /**
  57575. * Gets or sets a boolean indicating that this connection point can be omitted
  57576. */
  57577. isOptional: boolean;
  57578. /**
  57579. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57580. */
  57581. define: string;
  57582. /** @hidden */
  57583. _prioritizeVertex: boolean;
  57584. private _target;
  57585. /** Gets or sets the target of that connection point */
  57586. target: NodeMaterialBlockTargets;
  57587. /**
  57588. * Gets a boolean indicating that the current point is connected
  57589. */
  57590. readonly isConnected: boolean;
  57591. /**
  57592. * Gets a boolean indicating that the current point is connected to an input block
  57593. */
  57594. readonly isConnectedToInputBlock: boolean;
  57595. /**
  57596. * Gets a the connected input block (if any)
  57597. */
  57598. readonly connectInputBlock: Nullable<InputBlock>;
  57599. /** Get the other side of the connection (if any) */
  57600. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57601. /** Get the block that owns this connection point */
  57602. readonly ownerBlock: NodeMaterialBlock;
  57603. /** Get the block connected on the other side of this connection (if any) */
  57604. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57605. /** Get the block connected on the endpoints of this connection (if any) */
  57606. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57607. /** Gets the list of connected endpoints */
  57608. readonly endpoints: NodeMaterialConnectionPoint[];
  57609. /** Gets a boolean indicating if that output point is connected to at least one input */
  57610. readonly hasEndpoints: boolean;
  57611. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57612. readonly isConnectedInVertexShader: boolean;
  57613. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57614. readonly isConnectedInFragmentShader: boolean;
  57615. /**
  57616. * Creates a new connection point
  57617. * @param name defines the connection point name
  57618. * @param ownerBlock defines the block hosting this connection point
  57619. * @param direction defines the direction of the connection point
  57620. */
  57621. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57622. /**
  57623. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57624. * @returns the class name
  57625. */
  57626. getClassName(): string;
  57627. /**
  57628. * Gets a boolean indicating if the current point can be connected to another point
  57629. * @param connectionPoint defines the other connection point
  57630. * @returns a boolean
  57631. */
  57632. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57633. /**
  57634. * Gets a number indicating if the current point can be connected to another point
  57635. * @param connectionPoint defines the other connection point
  57636. * @returns a number defining the compatibility state
  57637. */
  57638. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57639. /**
  57640. * Connect this point to another connection point
  57641. * @param connectionPoint defines the other connection point
  57642. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57643. * @returns the current connection point
  57644. */
  57645. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57646. /**
  57647. * Disconnect this point from one of his endpoint
  57648. * @param endpoint defines the other connection point
  57649. * @returns the current connection point
  57650. */
  57651. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57652. /**
  57653. * Serializes this point in a JSON representation
  57654. * @returns the serialized point object
  57655. */
  57656. serialize(): any;
  57657. /**
  57658. * Release resources
  57659. */
  57660. dispose(): void;
  57661. }
  57662. }
  57663. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57667. import { Mesh } from "babylonjs/Meshes/mesh";
  57668. import { Effect } from "babylonjs/Materials/effect";
  57669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57670. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57671. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57672. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57673. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57674. /**
  57675. * Block used to add support for vertex skinning (bones)
  57676. */
  57677. export class BonesBlock extends NodeMaterialBlock {
  57678. /**
  57679. * Creates a new BonesBlock
  57680. * @param name defines the block name
  57681. */
  57682. constructor(name: string);
  57683. /**
  57684. * Initialize the block and prepare the context for build
  57685. * @param state defines the state that will be used for the build
  57686. */
  57687. initialize(state: NodeMaterialBuildState): void;
  57688. /**
  57689. * Gets the current class name
  57690. * @returns the class name
  57691. */
  57692. getClassName(): string;
  57693. /**
  57694. * Gets the matrix indices input component
  57695. */
  57696. readonly matricesIndices: NodeMaterialConnectionPoint;
  57697. /**
  57698. * Gets the matrix weights input component
  57699. */
  57700. readonly matricesWeights: NodeMaterialConnectionPoint;
  57701. /**
  57702. * Gets the extra matrix indices input component
  57703. */
  57704. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57705. /**
  57706. * Gets the extra matrix weights input component
  57707. */
  57708. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57709. /**
  57710. * Gets the world input component
  57711. */
  57712. readonly world: NodeMaterialConnectionPoint;
  57713. /**
  57714. * Gets the output component
  57715. */
  57716. readonly output: NodeMaterialConnectionPoint;
  57717. autoConfigure(material: NodeMaterial): void;
  57718. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57721. protected _buildBlock(state: NodeMaterialBuildState): this;
  57722. }
  57723. }
  57724. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57729. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57730. /**
  57731. * Block used to add support for instances
  57732. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57733. */
  57734. export class InstancesBlock extends NodeMaterialBlock {
  57735. /**
  57736. * Creates a new InstancesBlock
  57737. * @param name defines the block name
  57738. */
  57739. constructor(name: string);
  57740. /**
  57741. * Gets the current class name
  57742. * @returns the class name
  57743. */
  57744. getClassName(): string;
  57745. /**
  57746. * Gets the first world row input component
  57747. */
  57748. readonly world0: NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the second world row input component
  57751. */
  57752. readonly world1: NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the third world row input component
  57755. */
  57756. readonly world2: NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the forth world row input component
  57759. */
  57760. readonly world3: NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the world input component
  57763. */
  57764. readonly world: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the output component
  57767. */
  57768. readonly output: NodeMaterialConnectionPoint;
  57769. autoConfigure(material: NodeMaterial): void;
  57770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57771. protected _buildBlock(state: NodeMaterialBuildState): this;
  57772. }
  57773. }
  57774. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57779. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57780. import { Effect } from "babylonjs/Materials/effect";
  57781. import { Mesh } from "babylonjs/Meshes/mesh";
  57782. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57784. /**
  57785. * Block used to add morph targets support to vertex shader
  57786. */
  57787. export class MorphTargetsBlock extends NodeMaterialBlock {
  57788. private _repeatableContentAnchor;
  57789. private _repeatebleContentGenerated;
  57790. /**
  57791. * Create a new MorphTargetsBlock
  57792. * @param name defines the block name
  57793. */
  57794. constructor(name: string);
  57795. /**
  57796. * Gets the current class name
  57797. * @returns the class name
  57798. */
  57799. getClassName(): string;
  57800. /**
  57801. * Gets the position input component
  57802. */
  57803. readonly position: NodeMaterialConnectionPoint;
  57804. /**
  57805. * Gets the normal input component
  57806. */
  57807. readonly normal: NodeMaterialConnectionPoint;
  57808. /**
  57809. * Gets the tangent input component
  57810. */
  57811. readonly tangent: NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the tangent input component
  57814. */
  57815. readonly uv: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the position output component
  57818. */
  57819. readonly positionOutput: NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the normal output component
  57822. */
  57823. readonly normalOutput: NodeMaterialConnectionPoint;
  57824. /**
  57825. * Gets the tangent output component
  57826. */
  57827. readonly tangentOutput: NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the tangent output component
  57830. */
  57831. readonly uvOutput: NodeMaterialConnectionPoint;
  57832. initialize(state: NodeMaterialBuildState): void;
  57833. autoConfigure(material: NodeMaterial): void;
  57834. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57836. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57837. protected _buildBlock(state: NodeMaterialBuildState): this;
  57838. }
  57839. }
  57840. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57844. import { Nullable } from "babylonjs/types";
  57845. import { Scene } from "babylonjs/scene";
  57846. import { Effect } from "babylonjs/Materials/effect";
  57847. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57848. import { Mesh } from "babylonjs/Meshes/mesh";
  57849. import { Light } from "babylonjs/Lights/light";
  57850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57851. /**
  57852. * Block used to get data information from a light
  57853. */
  57854. export class LightInformationBlock extends NodeMaterialBlock {
  57855. private _lightDataUniformName;
  57856. private _lightColorUniformName;
  57857. private _lightTypeDefineName;
  57858. /**
  57859. * Gets or sets the light associated with this block
  57860. */
  57861. light: Nullable<Light>;
  57862. /**
  57863. * Creates a new LightInformationBlock
  57864. * @param name defines the block name
  57865. */
  57866. constructor(name: string);
  57867. /**
  57868. * Gets the current class name
  57869. * @returns the class name
  57870. */
  57871. getClassName(): string;
  57872. /**
  57873. * Gets the world position input component
  57874. */
  57875. readonly worldPosition: NodeMaterialConnectionPoint;
  57876. /**
  57877. * Gets the direction output component
  57878. */
  57879. readonly direction: NodeMaterialConnectionPoint;
  57880. /**
  57881. * Gets the direction output component
  57882. */
  57883. readonly color: NodeMaterialConnectionPoint;
  57884. /**
  57885. * Gets the direction output component
  57886. */
  57887. readonly intensity: NodeMaterialConnectionPoint;
  57888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57890. protected _buildBlock(state: NodeMaterialBuildState): this;
  57891. serialize(): any;
  57892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57893. }
  57894. }
  57895. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57896. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57897. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57898. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57899. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57900. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57901. }
  57902. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57903. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57904. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57905. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57907. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57908. import { Effect } from "babylonjs/Materials/effect";
  57909. import { Mesh } from "babylonjs/Meshes/mesh";
  57910. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57911. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57912. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57913. /**
  57914. * Block used to add image processing support to fragment shader
  57915. */
  57916. export class ImageProcessingBlock extends NodeMaterialBlock {
  57917. /**
  57918. * Create a new ImageProcessingBlock
  57919. * @param name defines the block name
  57920. */
  57921. constructor(name: string);
  57922. /**
  57923. * Gets the current class name
  57924. * @returns the class name
  57925. */
  57926. getClassName(): string;
  57927. /**
  57928. * Gets the color input component
  57929. */
  57930. readonly color: NodeMaterialConnectionPoint;
  57931. /**
  57932. * Gets the output component
  57933. */
  57934. readonly output: NodeMaterialConnectionPoint;
  57935. /**
  57936. * Initialize the block and prepare the context for build
  57937. * @param state defines the state that will be used for the build
  57938. */
  57939. initialize(state: NodeMaterialBuildState): void;
  57940. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57941. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57942. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57943. protected _buildBlock(state: NodeMaterialBuildState): this;
  57944. }
  57945. }
  57946. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57950. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57952. import { Effect } from "babylonjs/Materials/effect";
  57953. import { Mesh } from "babylonjs/Meshes/mesh";
  57954. import { Scene } from "babylonjs/scene";
  57955. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57956. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57957. /**
  57958. * Block used to pertub normals based on a normal map
  57959. */
  57960. export class PerturbNormalBlock extends NodeMaterialBlock {
  57961. private _tangentSpaceParameterName;
  57962. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57963. invertX: boolean;
  57964. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57965. invertY: boolean;
  57966. /**
  57967. * Create a new PerturbNormalBlock
  57968. * @param name defines the block name
  57969. */
  57970. constructor(name: string);
  57971. /**
  57972. * Gets the current class name
  57973. * @returns the class name
  57974. */
  57975. getClassName(): string;
  57976. /**
  57977. * Gets the world position input component
  57978. */
  57979. readonly worldPosition: NodeMaterialConnectionPoint;
  57980. /**
  57981. * Gets the world normal input component
  57982. */
  57983. readonly worldNormal: NodeMaterialConnectionPoint;
  57984. /**
  57985. * Gets the uv input component
  57986. */
  57987. readonly uv: NodeMaterialConnectionPoint;
  57988. /**
  57989. * Gets the normal map color input component
  57990. */
  57991. readonly normalMapColor: NodeMaterialConnectionPoint;
  57992. /**
  57993. * Gets the strength input component
  57994. */
  57995. readonly strength: NodeMaterialConnectionPoint;
  57996. /**
  57997. * Gets the output component
  57998. */
  57999. readonly output: NodeMaterialConnectionPoint;
  58000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58001. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58002. autoConfigure(material: NodeMaterial): void;
  58003. protected _buildBlock(state: NodeMaterialBuildState): this;
  58004. protected _dumpPropertiesCode(): string;
  58005. serialize(): any;
  58006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58007. }
  58008. }
  58009. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58013. /**
  58014. * Block used to discard a pixel if a value is smaller than a cutoff
  58015. */
  58016. export class DiscardBlock extends NodeMaterialBlock {
  58017. /**
  58018. * Create a new DiscardBlock
  58019. * @param name defines the block name
  58020. */
  58021. constructor(name: string);
  58022. /**
  58023. * Gets the current class name
  58024. * @returns the class name
  58025. */
  58026. getClassName(): string;
  58027. /**
  58028. * Gets the color input component
  58029. */
  58030. readonly value: NodeMaterialConnectionPoint;
  58031. /**
  58032. * Gets the cutoff input component
  58033. */
  58034. readonly cutoff: NodeMaterialConnectionPoint;
  58035. protected _buildBlock(state: NodeMaterialBuildState): this;
  58036. }
  58037. }
  58038. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58042. /**
  58043. * Block used to test if the fragment shader is front facing
  58044. */
  58045. export class FrontFacingBlock extends NodeMaterialBlock {
  58046. /**
  58047. * Creates a new FrontFacingBlock
  58048. * @param name defines the block name
  58049. */
  58050. constructor(name: string);
  58051. /**
  58052. * Gets the current class name
  58053. * @returns the class name
  58054. */
  58055. getClassName(): string;
  58056. /**
  58057. * Gets the output component
  58058. */
  58059. readonly output: NodeMaterialConnectionPoint;
  58060. protected _buildBlock(state: NodeMaterialBuildState): this;
  58061. }
  58062. }
  58063. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58067. /**
  58068. * Block used to get the derivative value on x and y of a given input
  58069. */
  58070. export class DerivativeBlock extends NodeMaterialBlock {
  58071. /**
  58072. * Create a new DerivativeBlock
  58073. * @param name defines the block name
  58074. */
  58075. constructor(name: string);
  58076. /**
  58077. * Gets the current class name
  58078. * @returns the class name
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * Gets the input component
  58083. */
  58084. readonly input: NodeMaterialConnectionPoint;
  58085. /**
  58086. * Gets the derivative output on x
  58087. */
  58088. readonly dx: NodeMaterialConnectionPoint;
  58089. /**
  58090. * Gets the derivative output on y
  58091. */
  58092. readonly dy: NodeMaterialConnectionPoint;
  58093. protected _buildBlock(state: NodeMaterialBuildState): this;
  58094. }
  58095. }
  58096. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58097. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58098. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58099. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58100. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58101. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58102. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58103. }
  58104. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58107. import { Mesh } from "babylonjs/Meshes/mesh";
  58108. import { Effect } from "babylonjs/Materials/effect";
  58109. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58111. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58112. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58113. /**
  58114. * Block used to add support for scene fog
  58115. */
  58116. export class FogBlock extends NodeMaterialBlock {
  58117. private _fogDistanceName;
  58118. private _fogParameters;
  58119. /**
  58120. * Create a new FogBlock
  58121. * @param name defines the block name
  58122. */
  58123. constructor(name: string);
  58124. /**
  58125. * Gets the current class name
  58126. * @returns the class name
  58127. */
  58128. getClassName(): string;
  58129. /**
  58130. * Gets the world position input component
  58131. */
  58132. readonly worldPosition: NodeMaterialConnectionPoint;
  58133. /**
  58134. * Gets the view input component
  58135. */
  58136. readonly view: NodeMaterialConnectionPoint;
  58137. /**
  58138. * Gets the color input component
  58139. */
  58140. readonly input: NodeMaterialConnectionPoint;
  58141. /**
  58142. * Gets the fog color input component
  58143. */
  58144. readonly fogColor: NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the output component
  58147. */
  58148. readonly output: NodeMaterialConnectionPoint;
  58149. autoConfigure(material: NodeMaterial): void;
  58150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58152. protected _buildBlock(state: NodeMaterialBuildState): this;
  58153. }
  58154. }
  58155. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58160. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58161. import { Effect } from "babylonjs/Materials/effect";
  58162. import { Mesh } from "babylonjs/Meshes/mesh";
  58163. import { Light } from "babylonjs/Lights/light";
  58164. import { Nullable } from "babylonjs/types";
  58165. import { Scene } from "babylonjs/scene";
  58166. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58167. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58168. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58170. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58171. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58172. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58173. /**
  58174. * Block used to add light in the fragment shader
  58175. */
  58176. export class LightBlock extends NodeMaterialBlock {
  58177. private _lightId;
  58178. /**
  58179. * Gets or sets the light associated with this block
  58180. */
  58181. light: Nullable<Light>;
  58182. /**
  58183. * Create a new LightBlock
  58184. * @param name defines the block name
  58185. */
  58186. constructor(name: string);
  58187. /**
  58188. * Gets the current class name
  58189. * @returns the class name
  58190. */
  58191. getClassName(): string;
  58192. /**
  58193. * Gets the world position input component
  58194. */
  58195. readonly worldPosition: NodeMaterialConnectionPoint;
  58196. /**
  58197. * Gets the world normal input component
  58198. */
  58199. readonly worldNormal: NodeMaterialConnectionPoint;
  58200. /**
  58201. * Gets the camera (or eye) position component
  58202. */
  58203. readonly cameraPosition: NodeMaterialConnectionPoint;
  58204. /**
  58205. * Gets the glossiness component
  58206. */
  58207. readonly glossiness: NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the glossinness power component
  58210. */
  58211. readonly glossPower: NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the diffuse color component
  58214. */
  58215. readonly diffuseColor: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the specular color component
  58218. */
  58219. readonly specularColor: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the diffuse output component
  58222. */
  58223. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the specular output component
  58226. */
  58227. readonly specularOutput: NodeMaterialConnectionPoint;
  58228. autoConfigure(material: NodeMaterial): void;
  58229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58230. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58231. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58232. private _injectVertexCode;
  58233. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58234. serialize(): any;
  58235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58239. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58240. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58241. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58242. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58243. }
  58244. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58245. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58246. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58247. }
  58248. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58249. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58250. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58251. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58252. /**
  58253. * Block used to multiply 2 values
  58254. */
  58255. export class MultiplyBlock extends NodeMaterialBlock {
  58256. /**
  58257. * Creates a new MultiplyBlock
  58258. * @param name defines the block name
  58259. */
  58260. constructor(name: string);
  58261. /**
  58262. * Gets the current class name
  58263. * @returns the class name
  58264. */
  58265. getClassName(): string;
  58266. /**
  58267. * Gets the left operand input component
  58268. */
  58269. readonly left: NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the right operand input component
  58272. */
  58273. readonly right: NodeMaterialConnectionPoint;
  58274. /**
  58275. * Gets the output component
  58276. */
  58277. readonly output: NodeMaterialConnectionPoint;
  58278. protected _buildBlock(state: NodeMaterialBuildState): this;
  58279. }
  58280. }
  58281. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58282. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58283. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58284. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58285. /**
  58286. * Block used to add 2 vectors
  58287. */
  58288. export class AddBlock extends NodeMaterialBlock {
  58289. /**
  58290. * Creates a new AddBlock
  58291. * @param name defines the block name
  58292. */
  58293. constructor(name: string);
  58294. /**
  58295. * Gets the current class name
  58296. * @returns the class name
  58297. */
  58298. getClassName(): string;
  58299. /**
  58300. * Gets the left operand input component
  58301. */
  58302. readonly left: NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the right operand input component
  58305. */
  58306. readonly right: NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the output component
  58309. */
  58310. readonly output: NodeMaterialConnectionPoint;
  58311. protected _buildBlock(state: NodeMaterialBuildState): this;
  58312. }
  58313. }
  58314. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58318. /**
  58319. * Block used to scale a vector by a float
  58320. */
  58321. export class ScaleBlock extends NodeMaterialBlock {
  58322. /**
  58323. * Creates a new ScaleBlock
  58324. * @param name defines the block name
  58325. */
  58326. constructor(name: string);
  58327. /**
  58328. * Gets the current class name
  58329. * @returns the class name
  58330. */
  58331. getClassName(): string;
  58332. /**
  58333. * Gets the input component
  58334. */
  58335. readonly input: NodeMaterialConnectionPoint;
  58336. /**
  58337. * Gets the factor input component
  58338. */
  58339. readonly factor: NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the output component
  58342. */
  58343. readonly output: NodeMaterialConnectionPoint;
  58344. protected _buildBlock(state: NodeMaterialBuildState): this;
  58345. }
  58346. }
  58347. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58351. import { Scene } from "babylonjs/scene";
  58352. /**
  58353. * Block used to clamp a float
  58354. */
  58355. export class ClampBlock extends NodeMaterialBlock {
  58356. /** Gets or sets the minimum range */
  58357. minimum: number;
  58358. /** Gets or sets the maximum range */
  58359. maximum: number;
  58360. /**
  58361. * Creates a new ClampBlock
  58362. * @param name defines the block name
  58363. */
  58364. constructor(name: string);
  58365. /**
  58366. * Gets the current class name
  58367. * @returns the class name
  58368. */
  58369. getClassName(): string;
  58370. /**
  58371. * Gets the value input component
  58372. */
  58373. readonly value: NodeMaterialConnectionPoint;
  58374. /**
  58375. * Gets the output component
  58376. */
  58377. readonly output: NodeMaterialConnectionPoint;
  58378. protected _buildBlock(state: NodeMaterialBuildState): this;
  58379. protected _dumpPropertiesCode(): string;
  58380. serialize(): any;
  58381. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58382. }
  58383. }
  58384. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58388. /**
  58389. * Block used to apply a cross product between 2 vectors
  58390. */
  58391. export class CrossBlock extends NodeMaterialBlock {
  58392. /**
  58393. * Creates a new CrossBlock
  58394. * @param name defines the block name
  58395. */
  58396. constructor(name: string);
  58397. /**
  58398. * Gets the current class name
  58399. * @returns the class name
  58400. */
  58401. getClassName(): string;
  58402. /**
  58403. * Gets the left operand input component
  58404. */
  58405. readonly left: NodeMaterialConnectionPoint;
  58406. /**
  58407. * Gets the right operand input component
  58408. */
  58409. readonly right: NodeMaterialConnectionPoint;
  58410. /**
  58411. * Gets the output component
  58412. */
  58413. readonly output: NodeMaterialConnectionPoint;
  58414. protected _buildBlock(state: NodeMaterialBuildState): this;
  58415. }
  58416. }
  58417. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58421. /**
  58422. * Block used to apply a dot product between 2 vectors
  58423. */
  58424. export class DotBlock extends NodeMaterialBlock {
  58425. /**
  58426. * Creates a new DotBlock
  58427. * @param name defines the block name
  58428. */
  58429. constructor(name: string);
  58430. /**
  58431. * Gets the current class name
  58432. * @returns the class name
  58433. */
  58434. getClassName(): string;
  58435. /**
  58436. * Gets the left operand input component
  58437. */
  58438. readonly left: NodeMaterialConnectionPoint;
  58439. /**
  58440. * Gets the right operand input component
  58441. */
  58442. readonly right: NodeMaterialConnectionPoint;
  58443. /**
  58444. * Gets the output component
  58445. */
  58446. readonly output: NodeMaterialConnectionPoint;
  58447. protected _buildBlock(state: NodeMaterialBuildState): this;
  58448. }
  58449. }
  58450. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58454. import { Vector2 } from "babylonjs/Maths/math.vector";
  58455. import { Scene } from "babylonjs/scene";
  58456. /**
  58457. * Block used to remap a float from a range to a new one
  58458. */
  58459. export class RemapBlock extends NodeMaterialBlock {
  58460. /**
  58461. * Gets or sets the source range
  58462. */
  58463. sourceRange: Vector2;
  58464. /**
  58465. * Gets or sets the target range
  58466. */
  58467. targetRange: Vector2;
  58468. /**
  58469. * Creates a new RemapBlock
  58470. * @param name defines the block name
  58471. */
  58472. constructor(name: string);
  58473. /**
  58474. * Gets the current class name
  58475. * @returns the class name
  58476. */
  58477. getClassName(): string;
  58478. /**
  58479. * Gets the input component
  58480. */
  58481. readonly input: NodeMaterialConnectionPoint;
  58482. /**
  58483. * Gets the source min input component
  58484. */
  58485. readonly sourceMin: NodeMaterialConnectionPoint;
  58486. /**
  58487. * Gets the source max input component
  58488. */
  58489. readonly sourceMax: NodeMaterialConnectionPoint;
  58490. /**
  58491. * Gets the target min input component
  58492. */
  58493. readonly targetMin: NodeMaterialConnectionPoint;
  58494. /**
  58495. * Gets the target max input component
  58496. */
  58497. readonly targetMax: NodeMaterialConnectionPoint;
  58498. /**
  58499. * Gets the output component
  58500. */
  58501. readonly output: NodeMaterialConnectionPoint;
  58502. protected _buildBlock(state: NodeMaterialBuildState): this;
  58503. protected _dumpPropertiesCode(): string;
  58504. serialize(): any;
  58505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58506. }
  58507. }
  58508. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58510. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58512. /**
  58513. * Block used to normalize a vector
  58514. */
  58515. export class NormalizeBlock extends NodeMaterialBlock {
  58516. /**
  58517. * Creates a new NormalizeBlock
  58518. * @param name defines the block name
  58519. */
  58520. constructor(name: string);
  58521. /**
  58522. * Gets the current class name
  58523. * @returns the class name
  58524. */
  58525. getClassName(): string;
  58526. /**
  58527. * Gets the input component
  58528. */
  58529. readonly input: NodeMaterialConnectionPoint;
  58530. /**
  58531. * Gets the output component
  58532. */
  58533. readonly output: NodeMaterialConnectionPoint;
  58534. protected _buildBlock(state: NodeMaterialBuildState): this;
  58535. }
  58536. }
  58537. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58541. import { Scene } from "babylonjs/scene";
  58542. /**
  58543. * Operations supported by the Trigonometry block
  58544. */
  58545. export enum TrigonometryBlockOperations {
  58546. /** Cos */
  58547. Cos = 0,
  58548. /** Sin */
  58549. Sin = 1,
  58550. /** Abs */
  58551. Abs = 2,
  58552. /** Exp */
  58553. Exp = 3,
  58554. /** Exp2 */
  58555. Exp2 = 4,
  58556. /** Round */
  58557. Round = 5,
  58558. /** Floor */
  58559. Floor = 6,
  58560. /** Ceiling */
  58561. Ceiling = 7,
  58562. /** Square root */
  58563. Sqrt = 8,
  58564. /** Log */
  58565. Log = 9,
  58566. /** Tangent */
  58567. Tan = 10,
  58568. /** Arc tangent */
  58569. ArcTan = 11,
  58570. /** Arc cosinus */
  58571. ArcCos = 12,
  58572. /** Arc sinus */
  58573. ArcSin = 13,
  58574. /** Fraction */
  58575. Fract = 14,
  58576. /** Sign */
  58577. Sign = 15,
  58578. /** To radians (from degrees) */
  58579. Radians = 16,
  58580. /** To degrees (from radians) */
  58581. Degrees = 17
  58582. }
  58583. /**
  58584. * Block used to apply trigonometry operation to floats
  58585. */
  58586. export class TrigonometryBlock extends NodeMaterialBlock {
  58587. /**
  58588. * Gets or sets the operation applied by the block
  58589. */
  58590. operation: TrigonometryBlockOperations;
  58591. /**
  58592. * Creates a new TrigonometryBlock
  58593. * @param name defines the block name
  58594. */
  58595. constructor(name: string);
  58596. /**
  58597. * Gets the current class name
  58598. * @returns the class name
  58599. */
  58600. getClassName(): string;
  58601. /**
  58602. * Gets the input component
  58603. */
  58604. readonly input: NodeMaterialConnectionPoint;
  58605. /**
  58606. * Gets the output component
  58607. */
  58608. readonly output: NodeMaterialConnectionPoint;
  58609. protected _buildBlock(state: NodeMaterialBuildState): this;
  58610. serialize(): any;
  58611. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58612. protected _dumpPropertiesCode(): string;
  58613. }
  58614. }
  58615. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58619. /**
  58620. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58621. */
  58622. export class ColorMergerBlock extends NodeMaterialBlock {
  58623. /**
  58624. * Create a new ColorMergerBlock
  58625. * @param name defines the block name
  58626. */
  58627. constructor(name: string);
  58628. /**
  58629. * Gets the current class name
  58630. * @returns the class name
  58631. */
  58632. getClassName(): string;
  58633. /**
  58634. * Gets the rgb component (input)
  58635. */
  58636. readonly rgbIn: NodeMaterialConnectionPoint;
  58637. /**
  58638. * Gets the r component (input)
  58639. */
  58640. readonly r: NodeMaterialConnectionPoint;
  58641. /**
  58642. * Gets the g component (input)
  58643. */
  58644. readonly g: NodeMaterialConnectionPoint;
  58645. /**
  58646. * Gets the b component (input)
  58647. */
  58648. readonly b: NodeMaterialConnectionPoint;
  58649. /**
  58650. * Gets the a component (input)
  58651. */
  58652. readonly a: NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the rgba component (output)
  58655. */
  58656. readonly rgba: NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the rgb component (output)
  58659. */
  58660. readonly rgbOut: NodeMaterialConnectionPoint;
  58661. /**
  58662. * Gets the rgb component (output)
  58663. * @deprecated Please use rgbOut instead.
  58664. */
  58665. readonly rgb: NodeMaterialConnectionPoint;
  58666. protected _buildBlock(state: NodeMaterialBuildState): this;
  58667. }
  58668. }
  58669. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58673. /**
  58674. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58675. */
  58676. export class VectorMergerBlock extends NodeMaterialBlock {
  58677. /**
  58678. * Create a new VectorMergerBlock
  58679. * @param name defines the block name
  58680. */
  58681. constructor(name: string);
  58682. /**
  58683. * Gets the current class name
  58684. * @returns the class name
  58685. */
  58686. getClassName(): string;
  58687. /**
  58688. * Gets the xyz component (input)
  58689. */
  58690. readonly xyzIn: NodeMaterialConnectionPoint;
  58691. /**
  58692. * Gets the xy component (input)
  58693. */
  58694. readonly xyIn: NodeMaterialConnectionPoint;
  58695. /**
  58696. * Gets the x component (input)
  58697. */
  58698. readonly x: NodeMaterialConnectionPoint;
  58699. /**
  58700. * Gets the y component (input)
  58701. */
  58702. readonly y: NodeMaterialConnectionPoint;
  58703. /**
  58704. * Gets the z component (input)
  58705. */
  58706. readonly z: NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the w component (input)
  58709. */
  58710. readonly w: NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the xyzw component (output)
  58713. */
  58714. readonly xyzw: NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the xyz component (output)
  58717. */
  58718. readonly xyzOut: NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the xy component (output)
  58721. */
  58722. readonly xyOut: NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the xy component (output)
  58725. * @deprecated Please use xyOut instead.
  58726. */
  58727. readonly xy: NodeMaterialConnectionPoint;
  58728. /**
  58729. * Gets the xyz component (output)
  58730. * @deprecated Please use xyzOut instead.
  58731. */
  58732. readonly xyz: NodeMaterialConnectionPoint;
  58733. protected _buildBlock(state: NodeMaterialBuildState): this;
  58734. }
  58735. }
  58736. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58740. /**
  58741. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58742. */
  58743. export class ColorSplitterBlock extends NodeMaterialBlock {
  58744. /**
  58745. * Create a new ColorSplitterBlock
  58746. * @param name defines the block name
  58747. */
  58748. constructor(name: string);
  58749. /**
  58750. * Gets the current class name
  58751. * @returns the class name
  58752. */
  58753. getClassName(): string;
  58754. /**
  58755. * Gets the rgba component (input)
  58756. */
  58757. readonly rgba: NodeMaterialConnectionPoint;
  58758. /**
  58759. * Gets the rgb component (input)
  58760. */
  58761. readonly rgbIn: NodeMaterialConnectionPoint;
  58762. /**
  58763. * Gets the rgb component (output)
  58764. */
  58765. readonly rgbOut: NodeMaterialConnectionPoint;
  58766. /**
  58767. * Gets the r component (output)
  58768. */
  58769. readonly r: NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the g component (output)
  58772. */
  58773. readonly g: NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the b component (output)
  58776. */
  58777. readonly b: NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the a component (output)
  58780. */
  58781. readonly a: NodeMaterialConnectionPoint;
  58782. protected _inputRename(name: string): string;
  58783. protected _outputRename(name: string): string;
  58784. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58785. }
  58786. }
  58787. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58791. /**
  58792. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58793. */
  58794. export class VectorSplitterBlock extends NodeMaterialBlock {
  58795. /**
  58796. * Create a new VectorSplitterBlock
  58797. * @param name defines the block name
  58798. */
  58799. constructor(name: string);
  58800. /**
  58801. * Gets the current class name
  58802. * @returns the class name
  58803. */
  58804. getClassName(): string;
  58805. /**
  58806. * Gets the xyzw component (input)
  58807. */
  58808. readonly xyzw: NodeMaterialConnectionPoint;
  58809. /**
  58810. * Gets the xyz component (input)
  58811. */
  58812. readonly xyzIn: NodeMaterialConnectionPoint;
  58813. /**
  58814. * Gets the xy component (input)
  58815. */
  58816. readonly xyIn: NodeMaterialConnectionPoint;
  58817. /**
  58818. * Gets the xyz component (output)
  58819. */
  58820. readonly xyzOut: NodeMaterialConnectionPoint;
  58821. /**
  58822. * Gets the xy component (output)
  58823. */
  58824. readonly xyOut: NodeMaterialConnectionPoint;
  58825. /**
  58826. * Gets the x component (output)
  58827. */
  58828. readonly x: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the y component (output)
  58831. */
  58832. readonly y: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the z component (output)
  58835. */
  58836. readonly z: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the w component (output)
  58839. */
  58840. readonly w: NodeMaterialConnectionPoint;
  58841. protected _inputRename(name: string): string;
  58842. protected _outputRename(name: string): string;
  58843. protected _buildBlock(state: NodeMaterialBuildState): this;
  58844. }
  58845. }
  58846. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58850. /**
  58851. * Block used to lerp between 2 values
  58852. */
  58853. export class LerpBlock extends NodeMaterialBlock {
  58854. /**
  58855. * Creates a new LerpBlock
  58856. * @param name defines the block name
  58857. */
  58858. constructor(name: string);
  58859. /**
  58860. * Gets the current class name
  58861. * @returns the class name
  58862. */
  58863. getClassName(): string;
  58864. /**
  58865. * Gets the left operand input component
  58866. */
  58867. readonly left: NodeMaterialConnectionPoint;
  58868. /**
  58869. * Gets the right operand input component
  58870. */
  58871. readonly right: NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the gradient operand input component
  58874. */
  58875. readonly gradient: NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the output component
  58878. */
  58879. readonly output: NodeMaterialConnectionPoint;
  58880. protected _buildBlock(state: NodeMaterialBuildState): this;
  58881. }
  58882. }
  58883. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58887. /**
  58888. * Block used to divide 2 vectors
  58889. */
  58890. export class DivideBlock extends NodeMaterialBlock {
  58891. /**
  58892. * Creates a new DivideBlock
  58893. * @param name defines the block name
  58894. */
  58895. constructor(name: string);
  58896. /**
  58897. * Gets the current class name
  58898. * @returns the class name
  58899. */
  58900. getClassName(): string;
  58901. /**
  58902. * Gets the left operand input component
  58903. */
  58904. readonly left: NodeMaterialConnectionPoint;
  58905. /**
  58906. * Gets the right operand input component
  58907. */
  58908. readonly right: NodeMaterialConnectionPoint;
  58909. /**
  58910. * Gets the output component
  58911. */
  58912. readonly output: NodeMaterialConnectionPoint;
  58913. protected _buildBlock(state: NodeMaterialBuildState): this;
  58914. }
  58915. }
  58916. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58920. /**
  58921. * Block used to subtract 2 vectors
  58922. */
  58923. export class SubtractBlock extends NodeMaterialBlock {
  58924. /**
  58925. * Creates a new SubtractBlock
  58926. * @param name defines the block name
  58927. */
  58928. constructor(name: string);
  58929. /**
  58930. * Gets the current class name
  58931. * @returns the class name
  58932. */
  58933. getClassName(): string;
  58934. /**
  58935. * Gets the left operand input component
  58936. */
  58937. readonly left: NodeMaterialConnectionPoint;
  58938. /**
  58939. * Gets the right operand input component
  58940. */
  58941. readonly right: NodeMaterialConnectionPoint;
  58942. /**
  58943. * Gets the output component
  58944. */
  58945. readonly output: NodeMaterialConnectionPoint;
  58946. protected _buildBlock(state: NodeMaterialBuildState): this;
  58947. }
  58948. }
  58949. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58953. /**
  58954. * Block used to step a value
  58955. */
  58956. export class StepBlock extends NodeMaterialBlock {
  58957. /**
  58958. * Creates a new StepBlock
  58959. * @param name defines the block name
  58960. */
  58961. constructor(name: string);
  58962. /**
  58963. * Gets the current class name
  58964. * @returns the class name
  58965. */
  58966. getClassName(): string;
  58967. /**
  58968. * Gets the value operand input component
  58969. */
  58970. readonly value: NodeMaterialConnectionPoint;
  58971. /**
  58972. * Gets the edge operand input component
  58973. */
  58974. readonly edge: NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the output component
  58977. */
  58978. readonly output: NodeMaterialConnectionPoint;
  58979. protected _buildBlock(state: NodeMaterialBuildState): this;
  58980. }
  58981. }
  58982. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58986. /**
  58987. * Block used to get the opposite (1 - x) of a value
  58988. */
  58989. export class OneMinusBlock extends NodeMaterialBlock {
  58990. /**
  58991. * Creates a new OneMinusBlock
  58992. * @param name defines the block name
  58993. */
  58994. constructor(name: string);
  58995. /**
  58996. * Gets the current class name
  58997. * @returns the class name
  58998. */
  58999. getClassName(): string;
  59000. /**
  59001. * Gets the input component
  59002. */
  59003. readonly input: NodeMaterialConnectionPoint;
  59004. /**
  59005. * Gets the output component
  59006. */
  59007. readonly output: NodeMaterialConnectionPoint;
  59008. protected _buildBlock(state: NodeMaterialBuildState): this;
  59009. }
  59010. }
  59011. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59015. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59016. /**
  59017. * Block used to get the view direction
  59018. */
  59019. export class ViewDirectionBlock extends NodeMaterialBlock {
  59020. /**
  59021. * Creates a new ViewDirectionBlock
  59022. * @param name defines the block name
  59023. */
  59024. constructor(name: string);
  59025. /**
  59026. * Gets the current class name
  59027. * @returns the class name
  59028. */
  59029. getClassName(): string;
  59030. /**
  59031. * Gets the world position component
  59032. */
  59033. readonly worldPosition: NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the camera position component
  59036. */
  59037. readonly cameraPosition: NodeMaterialConnectionPoint;
  59038. /**
  59039. * Gets the output component
  59040. */
  59041. readonly output: NodeMaterialConnectionPoint;
  59042. autoConfigure(material: NodeMaterial): void;
  59043. protected _buildBlock(state: NodeMaterialBuildState): this;
  59044. }
  59045. }
  59046. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59050. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59051. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59052. /**
  59053. * Block used to compute fresnel value
  59054. */
  59055. export class FresnelBlock extends NodeMaterialBlock {
  59056. /**
  59057. * Create a new FresnelBlock
  59058. * @param name defines the block name
  59059. */
  59060. constructor(name: string);
  59061. /**
  59062. * Gets the current class name
  59063. * @returns the class name
  59064. */
  59065. getClassName(): string;
  59066. /**
  59067. * Gets the world normal input component
  59068. */
  59069. readonly worldNormal: NodeMaterialConnectionPoint;
  59070. /**
  59071. * Gets the view direction input component
  59072. */
  59073. readonly viewDirection: NodeMaterialConnectionPoint;
  59074. /**
  59075. * Gets the bias input component
  59076. */
  59077. readonly bias: NodeMaterialConnectionPoint;
  59078. /**
  59079. * Gets the camera (or eye) position component
  59080. */
  59081. readonly power: NodeMaterialConnectionPoint;
  59082. /**
  59083. * Gets the fresnel output component
  59084. */
  59085. readonly fresnel: NodeMaterialConnectionPoint;
  59086. autoConfigure(material: NodeMaterial): void;
  59087. protected _buildBlock(state: NodeMaterialBuildState): this;
  59088. }
  59089. }
  59090. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59094. /**
  59095. * Block used to get the max of 2 values
  59096. */
  59097. export class MaxBlock extends NodeMaterialBlock {
  59098. /**
  59099. * Creates a new MaxBlock
  59100. * @param name defines the block name
  59101. */
  59102. constructor(name: string);
  59103. /**
  59104. * Gets the current class name
  59105. * @returns the class name
  59106. */
  59107. getClassName(): string;
  59108. /**
  59109. * Gets the left operand input component
  59110. */
  59111. readonly left: NodeMaterialConnectionPoint;
  59112. /**
  59113. * Gets the right operand input component
  59114. */
  59115. readonly right: NodeMaterialConnectionPoint;
  59116. /**
  59117. * Gets the output component
  59118. */
  59119. readonly output: NodeMaterialConnectionPoint;
  59120. protected _buildBlock(state: NodeMaterialBuildState): this;
  59121. }
  59122. }
  59123. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59127. /**
  59128. * Block used to get the min of 2 values
  59129. */
  59130. export class MinBlock extends NodeMaterialBlock {
  59131. /**
  59132. * Creates a new MinBlock
  59133. * @param name defines the block name
  59134. */
  59135. constructor(name: string);
  59136. /**
  59137. * Gets the current class name
  59138. * @returns the class name
  59139. */
  59140. getClassName(): string;
  59141. /**
  59142. * Gets the left operand input component
  59143. */
  59144. readonly left: NodeMaterialConnectionPoint;
  59145. /**
  59146. * Gets the right operand input component
  59147. */
  59148. readonly right: NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the output component
  59151. */
  59152. readonly output: NodeMaterialConnectionPoint;
  59153. protected _buildBlock(state: NodeMaterialBuildState): this;
  59154. }
  59155. }
  59156. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59160. /**
  59161. * Block used to get the distance between 2 values
  59162. */
  59163. export class DistanceBlock extends NodeMaterialBlock {
  59164. /**
  59165. * Creates a new DistanceBlock
  59166. * @param name defines the block name
  59167. */
  59168. constructor(name: string);
  59169. /**
  59170. * Gets the current class name
  59171. * @returns the class name
  59172. */
  59173. getClassName(): string;
  59174. /**
  59175. * Gets the left operand input component
  59176. */
  59177. readonly left: NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the right operand input component
  59180. */
  59181. readonly right: NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the output component
  59184. */
  59185. readonly output: NodeMaterialConnectionPoint;
  59186. protected _buildBlock(state: NodeMaterialBuildState): this;
  59187. }
  59188. }
  59189. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59193. /**
  59194. * Block used to get the length of a vector
  59195. */
  59196. export class LengthBlock extends NodeMaterialBlock {
  59197. /**
  59198. * Creates a new LengthBlock
  59199. * @param name defines the block name
  59200. */
  59201. constructor(name: string);
  59202. /**
  59203. * Gets the current class name
  59204. * @returns the class name
  59205. */
  59206. getClassName(): string;
  59207. /**
  59208. * Gets the value input component
  59209. */
  59210. readonly value: NodeMaterialConnectionPoint;
  59211. /**
  59212. * Gets the output component
  59213. */
  59214. readonly output: NodeMaterialConnectionPoint;
  59215. protected _buildBlock(state: NodeMaterialBuildState): this;
  59216. }
  59217. }
  59218. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59222. /**
  59223. * Block used to get negative version of a value (i.e. x * -1)
  59224. */
  59225. export class NegateBlock extends NodeMaterialBlock {
  59226. /**
  59227. * Creates a new NegateBlock
  59228. * @param name defines the block name
  59229. */
  59230. constructor(name: string);
  59231. /**
  59232. * Gets the current class name
  59233. * @returns the class name
  59234. */
  59235. getClassName(): string;
  59236. /**
  59237. * Gets the value input component
  59238. */
  59239. readonly value: NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the output component
  59242. */
  59243. readonly output: NodeMaterialConnectionPoint;
  59244. protected _buildBlock(state: NodeMaterialBuildState): this;
  59245. }
  59246. }
  59247. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59248. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59249. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59250. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59251. /**
  59252. * Block used to get the value of the first parameter raised to the power of the second
  59253. */
  59254. export class PowBlock extends NodeMaterialBlock {
  59255. /**
  59256. * Creates a new PowBlock
  59257. * @param name defines the block name
  59258. */
  59259. constructor(name: string);
  59260. /**
  59261. * Gets the current class name
  59262. * @returns the class name
  59263. */
  59264. getClassName(): string;
  59265. /**
  59266. * Gets the value operand input component
  59267. */
  59268. readonly value: NodeMaterialConnectionPoint;
  59269. /**
  59270. * Gets the power operand input component
  59271. */
  59272. readonly power: NodeMaterialConnectionPoint;
  59273. /**
  59274. * Gets the output component
  59275. */
  59276. readonly output: NodeMaterialConnectionPoint;
  59277. protected _buildBlock(state: NodeMaterialBuildState): this;
  59278. }
  59279. }
  59280. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59285. /**
  59286. * Block used to get a random number
  59287. */
  59288. export class RandomNumberBlock extends NodeMaterialBlock {
  59289. /**
  59290. * Creates a new RandomNumberBlock
  59291. * @param name defines the block name
  59292. */
  59293. constructor(name: string);
  59294. /**
  59295. * Gets the current class name
  59296. * @returns the class name
  59297. */
  59298. getClassName(): string;
  59299. /**
  59300. * Gets the seed input component
  59301. */
  59302. readonly seed: NodeMaterialConnectionPoint;
  59303. /**
  59304. * Gets the output component
  59305. */
  59306. readonly output: NodeMaterialConnectionPoint;
  59307. protected _buildBlock(state: NodeMaterialBuildState): this;
  59308. }
  59309. }
  59310. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59314. /**
  59315. * Block used to compute arc tangent of 2 values
  59316. */
  59317. export class ArcTan2Block extends NodeMaterialBlock {
  59318. /**
  59319. * Creates a new ArcTan2Block
  59320. * @param name defines the block name
  59321. */
  59322. constructor(name: string);
  59323. /**
  59324. * Gets the current class name
  59325. * @returns the class name
  59326. */
  59327. getClassName(): string;
  59328. /**
  59329. * Gets the x operand input component
  59330. */
  59331. readonly x: NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the y operand input component
  59334. */
  59335. readonly y: NodeMaterialConnectionPoint;
  59336. /**
  59337. * Gets the output component
  59338. */
  59339. readonly output: NodeMaterialConnectionPoint;
  59340. protected _buildBlock(state: NodeMaterialBuildState): this;
  59341. }
  59342. }
  59343. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59347. /**
  59348. * Block used to smooth step a value
  59349. */
  59350. export class SmoothStepBlock extends NodeMaterialBlock {
  59351. /**
  59352. * Creates a new SmoothStepBlock
  59353. * @param name defines the block name
  59354. */
  59355. constructor(name: string);
  59356. /**
  59357. * Gets the current class name
  59358. * @returns the class name
  59359. */
  59360. getClassName(): string;
  59361. /**
  59362. * Gets the value operand input component
  59363. */
  59364. readonly value: NodeMaterialConnectionPoint;
  59365. /**
  59366. * Gets the first edge operand input component
  59367. */
  59368. readonly edge0: NodeMaterialConnectionPoint;
  59369. /**
  59370. * Gets the second edge operand input component
  59371. */
  59372. readonly edge1: NodeMaterialConnectionPoint;
  59373. /**
  59374. * Gets the output component
  59375. */
  59376. readonly output: NodeMaterialConnectionPoint;
  59377. protected _buildBlock(state: NodeMaterialBuildState): this;
  59378. }
  59379. }
  59380. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59384. /**
  59385. * Block used to get the reciprocal (1 / x) of a value
  59386. */
  59387. export class ReciprocalBlock extends NodeMaterialBlock {
  59388. /**
  59389. * Creates a new ReciprocalBlock
  59390. * @param name defines the block name
  59391. */
  59392. constructor(name: string);
  59393. /**
  59394. * Gets the current class name
  59395. * @returns the class name
  59396. */
  59397. getClassName(): string;
  59398. /**
  59399. * Gets the input component
  59400. */
  59401. readonly input: NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the output component
  59404. */
  59405. readonly output: NodeMaterialConnectionPoint;
  59406. protected _buildBlock(state: NodeMaterialBuildState): this;
  59407. }
  59408. }
  59409. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59413. /**
  59414. * Block used to replace a color by another one
  59415. */
  59416. export class ReplaceColorBlock extends NodeMaterialBlock {
  59417. /**
  59418. * Creates a new ReplaceColorBlock
  59419. * @param name defines the block name
  59420. */
  59421. constructor(name: string);
  59422. /**
  59423. * Gets the current class name
  59424. * @returns the class name
  59425. */
  59426. getClassName(): string;
  59427. /**
  59428. * Gets the value input component
  59429. */
  59430. readonly value: NodeMaterialConnectionPoint;
  59431. /**
  59432. * Gets the reference input component
  59433. */
  59434. readonly reference: NodeMaterialConnectionPoint;
  59435. /**
  59436. * Gets the distance input component
  59437. */
  59438. readonly distance: NodeMaterialConnectionPoint;
  59439. /**
  59440. * Gets the replacement input component
  59441. */
  59442. readonly replacement: NodeMaterialConnectionPoint;
  59443. /**
  59444. * Gets the output component
  59445. */
  59446. readonly output: NodeMaterialConnectionPoint;
  59447. protected _buildBlock(state: NodeMaterialBuildState): this;
  59448. }
  59449. }
  59450. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59454. /**
  59455. * Block used to posterize a value
  59456. * @see https://en.wikipedia.org/wiki/Posterization
  59457. */
  59458. export class PosterizeBlock extends NodeMaterialBlock {
  59459. /**
  59460. * Creates a new PosterizeBlock
  59461. * @param name defines the block name
  59462. */
  59463. constructor(name: string);
  59464. /**
  59465. * Gets the current class name
  59466. * @returns the class name
  59467. */
  59468. getClassName(): string;
  59469. /**
  59470. * Gets the value input component
  59471. */
  59472. readonly value: NodeMaterialConnectionPoint;
  59473. /**
  59474. * Gets the steps input component
  59475. */
  59476. readonly steps: NodeMaterialConnectionPoint;
  59477. /**
  59478. * Gets the output component
  59479. */
  59480. readonly output: NodeMaterialConnectionPoint;
  59481. protected _buildBlock(state: NodeMaterialBuildState): this;
  59482. }
  59483. }
  59484. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59488. import { Scene } from "babylonjs/scene";
  59489. /**
  59490. * Operations supported by the Wave block
  59491. */
  59492. export enum WaveBlockKind {
  59493. /** SawTooth */
  59494. SawTooth = 0,
  59495. /** Square */
  59496. Square = 1,
  59497. /** Triangle */
  59498. Triangle = 2
  59499. }
  59500. /**
  59501. * Block used to apply wave operation to floats
  59502. */
  59503. export class WaveBlock extends NodeMaterialBlock {
  59504. /**
  59505. * Gets or sets the kibnd of wave to be applied by the block
  59506. */
  59507. kind: WaveBlockKind;
  59508. /**
  59509. * Creates a new WaveBlock
  59510. * @param name defines the block name
  59511. */
  59512. constructor(name: string);
  59513. /**
  59514. * Gets the current class name
  59515. * @returns the class name
  59516. */
  59517. getClassName(): string;
  59518. /**
  59519. * Gets the input component
  59520. */
  59521. readonly input: NodeMaterialConnectionPoint;
  59522. /**
  59523. * Gets the output component
  59524. */
  59525. readonly output: NodeMaterialConnectionPoint;
  59526. protected _buildBlock(state: NodeMaterialBuildState): this;
  59527. serialize(): any;
  59528. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59529. }
  59530. }
  59531. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59535. import { Color3 } from "babylonjs/Maths/math.color";
  59536. import { Scene } from "babylonjs/scene";
  59537. /**
  59538. * Class used to store a color step for the GradientBlock
  59539. */
  59540. export class GradientBlockColorStep {
  59541. /**
  59542. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59543. */
  59544. step: number;
  59545. /**
  59546. * Gets or sets the color associated with this step
  59547. */
  59548. color: Color3;
  59549. /**
  59550. * Creates a new GradientBlockColorStep
  59551. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59552. * @param color defines the color associated with this step
  59553. */
  59554. constructor(
  59555. /**
  59556. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59557. */
  59558. step: number,
  59559. /**
  59560. * Gets or sets the color associated with this step
  59561. */
  59562. color: Color3);
  59563. }
  59564. /**
  59565. * Block used to return a color from a gradient based on an input value between 0 and 1
  59566. */
  59567. export class GradientBlock extends NodeMaterialBlock {
  59568. /**
  59569. * Gets or sets the list of color steps
  59570. */
  59571. colorSteps: GradientBlockColorStep[];
  59572. /**
  59573. * Creates a new GradientBlock
  59574. * @param name defines the block name
  59575. */
  59576. constructor(name: string);
  59577. /**
  59578. * Gets the current class name
  59579. * @returns the class name
  59580. */
  59581. getClassName(): string;
  59582. /**
  59583. * Gets the gradient input component
  59584. */
  59585. readonly gradient: NodeMaterialConnectionPoint;
  59586. /**
  59587. * Gets the output component
  59588. */
  59589. readonly output: NodeMaterialConnectionPoint;
  59590. private _writeColorConstant;
  59591. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59592. serialize(): any;
  59593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59594. protected _dumpPropertiesCode(): string;
  59595. }
  59596. }
  59597. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59601. /**
  59602. * Block used to normalize lerp between 2 values
  59603. */
  59604. export class NLerpBlock extends NodeMaterialBlock {
  59605. /**
  59606. * Creates a new NLerpBlock
  59607. * @param name defines the block name
  59608. */
  59609. constructor(name: string);
  59610. /**
  59611. * Gets the current class name
  59612. * @returns the class name
  59613. */
  59614. getClassName(): string;
  59615. /**
  59616. * Gets the left operand input component
  59617. */
  59618. readonly left: NodeMaterialConnectionPoint;
  59619. /**
  59620. * Gets the right operand input component
  59621. */
  59622. readonly right: NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the gradient operand input component
  59625. */
  59626. readonly gradient: NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the output component
  59629. */
  59630. readonly output: NodeMaterialConnectionPoint;
  59631. protected _buildBlock(state: NodeMaterialBuildState): this;
  59632. }
  59633. }
  59634. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59638. import { Scene } from "babylonjs/scene";
  59639. /**
  59640. * block used to Generate a Worley Noise 3D Noise Pattern
  59641. */
  59642. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59643. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59644. manhattanDistance: boolean;
  59645. /**
  59646. * Creates a new WorleyNoise3DBlock
  59647. * @param name defines the block name
  59648. */
  59649. constructor(name: string);
  59650. /**
  59651. * Gets the current class name
  59652. * @returns the class name
  59653. */
  59654. getClassName(): string;
  59655. /**
  59656. * Gets the seed input component
  59657. */
  59658. readonly seed: NodeMaterialConnectionPoint;
  59659. /**
  59660. * Gets the jitter input component
  59661. */
  59662. readonly jitter: NodeMaterialConnectionPoint;
  59663. /**
  59664. * Gets the output component
  59665. */
  59666. readonly output: NodeMaterialConnectionPoint;
  59667. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59668. /**
  59669. * Exposes the properties to the UI?
  59670. */
  59671. protected _dumpPropertiesCode(): string;
  59672. /**
  59673. * Exposes the properties to the Seralize?
  59674. */
  59675. serialize(): any;
  59676. /**
  59677. * Exposes the properties to the deseralize?
  59678. */
  59679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59680. }
  59681. }
  59682. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59686. /**
  59687. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59688. */
  59689. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59690. /**
  59691. * Creates a new SimplexPerlin3DBlock
  59692. * @param name defines the block name
  59693. */
  59694. constructor(name: string);
  59695. /**
  59696. * Gets the current class name
  59697. * @returns the class name
  59698. */
  59699. getClassName(): string;
  59700. /**
  59701. * Gets the seed operand input component
  59702. */
  59703. readonly seed: NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the output component
  59706. */
  59707. readonly output: NodeMaterialConnectionPoint;
  59708. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59709. }
  59710. }
  59711. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59715. /**
  59716. * Block used to blend normals
  59717. */
  59718. export class NormalBlendBlock extends NodeMaterialBlock {
  59719. /**
  59720. * Creates a new NormalBlendBlock
  59721. * @param name defines the block name
  59722. */
  59723. constructor(name: string);
  59724. /**
  59725. * Gets the current class name
  59726. * @returns the class name
  59727. */
  59728. getClassName(): string;
  59729. /**
  59730. * Gets the first input component
  59731. */
  59732. readonly normalMap0: NodeMaterialConnectionPoint;
  59733. /**
  59734. * Gets the second input component
  59735. */
  59736. readonly normalMap1: NodeMaterialConnectionPoint;
  59737. /**
  59738. * Gets the output component
  59739. */
  59740. readonly output: NodeMaterialConnectionPoint;
  59741. protected _buildBlock(state: NodeMaterialBuildState): this;
  59742. }
  59743. }
  59744. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59745. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59746. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59747. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59748. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59749. /**
  59750. * Block used to rotate a 2d vector by a given angle
  59751. */
  59752. export class Rotate2dBlock extends NodeMaterialBlock {
  59753. /**
  59754. * Creates a new Rotate2dBlock
  59755. * @param name defines the block name
  59756. */
  59757. constructor(name: string);
  59758. /**
  59759. * Gets the current class name
  59760. * @returns the class name
  59761. */
  59762. getClassName(): string;
  59763. /**
  59764. * Gets the input vector
  59765. */
  59766. readonly input: NodeMaterialConnectionPoint;
  59767. /**
  59768. * Gets the input angle
  59769. */
  59770. readonly angle: NodeMaterialConnectionPoint;
  59771. /**
  59772. * Gets the output component
  59773. */
  59774. readonly output: NodeMaterialConnectionPoint;
  59775. autoConfigure(material: NodeMaterial): void;
  59776. protected _buildBlock(state: NodeMaterialBuildState): this;
  59777. }
  59778. }
  59779. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59783. /**
  59784. * Block used to get the reflected vector from a direction and a normal
  59785. */
  59786. export class ReflectBlock extends NodeMaterialBlock {
  59787. /**
  59788. * Creates a new ReflectBlock
  59789. * @param name defines the block name
  59790. */
  59791. constructor(name: string);
  59792. /**
  59793. * Gets the current class name
  59794. * @returns the class name
  59795. */
  59796. getClassName(): string;
  59797. /**
  59798. * Gets the incident component
  59799. */
  59800. readonly incident: NodeMaterialConnectionPoint;
  59801. /**
  59802. * Gets the normal component
  59803. */
  59804. readonly normal: NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the output component
  59807. */
  59808. readonly output: NodeMaterialConnectionPoint;
  59809. protected _buildBlock(state: NodeMaterialBuildState): this;
  59810. }
  59811. }
  59812. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  59813. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59816. /**
  59817. * Block used to get the refracted vector from a direction and a normal
  59818. */
  59819. export class RefractBlock extends NodeMaterialBlock {
  59820. /**
  59821. * Creates a new RefractBlock
  59822. * @param name defines the block name
  59823. */
  59824. constructor(name: string);
  59825. /**
  59826. * Gets the current class name
  59827. * @returns the class name
  59828. */
  59829. getClassName(): string;
  59830. /**
  59831. * Gets the incident component
  59832. */
  59833. readonly incident: NodeMaterialConnectionPoint;
  59834. /**
  59835. * Gets the normal component
  59836. */
  59837. readonly normal: NodeMaterialConnectionPoint;
  59838. /**
  59839. * Gets the index of refraction component
  59840. */
  59841. readonly ior: NodeMaterialConnectionPoint;
  59842. /**
  59843. * Gets the output component
  59844. */
  59845. readonly output: NodeMaterialConnectionPoint;
  59846. protected _buildBlock(state: NodeMaterialBuildState): this;
  59847. }
  59848. }
  59849. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  59850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59853. /**
  59854. * Block used to desaturate a color
  59855. */
  59856. export class DesaturateBlock extends NodeMaterialBlock {
  59857. /**
  59858. * Creates a new DesaturateBlock
  59859. * @param name defines the block name
  59860. */
  59861. constructor(name: string);
  59862. /**
  59863. * Gets the current class name
  59864. * @returns the class name
  59865. */
  59866. getClassName(): string;
  59867. /**
  59868. * Gets the color operand input component
  59869. */
  59870. readonly color: NodeMaterialConnectionPoint;
  59871. /**
  59872. * Gets the level operand input component
  59873. */
  59874. readonly level: NodeMaterialConnectionPoint;
  59875. /**
  59876. * Gets the output component
  59877. */
  59878. readonly output: NodeMaterialConnectionPoint;
  59879. protected _buildBlock(state: NodeMaterialBuildState): this;
  59880. }
  59881. }
  59882. declare module "babylonjs/Materials/Node/Blocks/index" {
  59883. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59884. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59885. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59886. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59887. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59888. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59889. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59890. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59891. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59892. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59893. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59894. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59895. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59896. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59897. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59898. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59899. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59900. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59901. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59902. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59903. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59904. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59905. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59906. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59907. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59908. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59909. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59910. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59911. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59912. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59913. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59914. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59915. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59916. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59917. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59918. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59919. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59920. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59921. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59922. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59923. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59924. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59925. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59926. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59927. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  59928. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  59929. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  59930. }
  59931. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59932. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59933. }
  59934. declare module "babylonjs/Materials/Node/index" {
  59935. export * from "babylonjs/Materials/Node/Enums/index";
  59936. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59937. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59938. export * from "babylonjs/Materials/Node/nodeMaterial";
  59939. export * from "babylonjs/Materials/Node/Blocks/index";
  59940. export * from "babylonjs/Materials/Node/Optimizers/index";
  59941. }
  59942. declare module "babylonjs/Materials/effectRenderer" {
  59943. import { Nullable } from "babylonjs/types";
  59944. import { Texture } from "babylonjs/Materials/Textures/texture";
  59945. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59946. import { Viewport } from "babylonjs/Maths/math.viewport";
  59947. import { Observable } from "babylonjs/Misc/observable";
  59948. import { Effect } from "babylonjs/Materials/effect";
  59949. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59950. import "babylonjs/Shaders/postprocess.vertex";
  59951. /**
  59952. * Effect Render Options
  59953. */
  59954. export interface IEffectRendererOptions {
  59955. /**
  59956. * Defines the vertices positions.
  59957. */
  59958. positions?: number[];
  59959. /**
  59960. * Defines the indices.
  59961. */
  59962. indices?: number[];
  59963. }
  59964. /**
  59965. * Helper class to render one or more effects
  59966. */
  59967. export class EffectRenderer {
  59968. private engine;
  59969. private static _DefaultOptions;
  59970. private _vertexBuffers;
  59971. private _indexBuffer;
  59972. private _ringBufferIndex;
  59973. private _ringScreenBuffer;
  59974. private _fullscreenViewport;
  59975. private _getNextFrameBuffer;
  59976. /**
  59977. * Creates an effect renderer
  59978. * @param engine the engine to use for rendering
  59979. * @param options defines the options of the effect renderer
  59980. */
  59981. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59982. /**
  59983. * Sets the current viewport in normalized coordinates 0-1
  59984. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59985. */
  59986. setViewport(viewport?: Viewport): void;
  59987. /**
  59988. * Binds the embedded attributes buffer to the effect.
  59989. * @param effect Defines the effect to bind the attributes for
  59990. */
  59991. bindBuffers(effect: Effect): void;
  59992. /**
  59993. * Sets the current effect wrapper to use during draw.
  59994. * The effect needs to be ready before calling this api.
  59995. * This also sets the default full screen position attribute.
  59996. * @param effectWrapper Defines the effect to draw with
  59997. */
  59998. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59999. /**
  60000. * Draws a full screen quad.
  60001. */
  60002. draw(): void;
  60003. /**
  60004. * renders one or more effects to a specified texture
  60005. * @param effectWrappers list of effects to renderer
  60006. * @param outputTexture texture to draw to, if null it will render to the screen
  60007. */
  60008. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60009. /**
  60010. * Disposes of the effect renderer
  60011. */
  60012. dispose(): void;
  60013. }
  60014. /**
  60015. * Options to create an EffectWrapper
  60016. */
  60017. interface EffectWrapperCreationOptions {
  60018. /**
  60019. * Engine to use to create the effect
  60020. */
  60021. engine: ThinEngine;
  60022. /**
  60023. * Fragment shader for the effect
  60024. */
  60025. fragmentShader: string;
  60026. /**
  60027. * Vertex shader for the effect
  60028. */
  60029. vertexShader?: string;
  60030. /**
  60031. * Attributes to use in the shader
  60032. */
  60033. attributeNames?: Array<string>;
  60034. /**
  60035. * Uniforms to use in the shader
  60036. */
  60037. uniformNames?: Array<string>;
  60038. /**
  60039. * Texture sampler names to use in the shader
  60040. */
  60041. samplerNames?: Array<string>;
  60042. /**
  60043. * The friendly name of the effect displayed in Spector.
  60044. */
  60045. name?: string;
  60046. }
  60047. /**
  60048. * Wraps an effect to be used for rendering
  60049. */
  60050. export class EffectWrapper {
  60051. /**
  60052. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60053. */
  60054. onApplyObservable: Observable<{}>;
  60055. /**
  60056. * The underlying effect
  60057. */
  60058. effect: Effect;
  60059. /**
  60060. * Creates an effect to be renderer
  60061. * @param creationOptions options to create the effect
  60062. */
  60063. constructor(creationOptions: EffectWrapperCreationOptions);
  60064. /**
  60065. * Disposes of the effect wrapper
  60066. */
  60067. dispose(): void;
  60068. }
  60069. }
  60070. declare module "babylonjs/Materials/index" {
  60071. export * from "babylonjs/Materials/Background/index";
  60072. export * from "babylonjs/Materials/colorCurves";
  60073. export * from "babylonjs/Materials/iEffectFallbacks";
  60074. export * from "babylonjs/Materials/effectFallbacks";
  60075. export * from "babylonjs/Materials/effect";
  60076. export * from "babylonjs/Materials/fresnelParameters";
  60077. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60078. export * from "babylonjs/Materials/material";
  60079. export * from "babylonjs/Materials/materialDefines";
  60080. export * from "babylonjs/Materials/materialHelper";
  60081. export * from "babylonjs/Materials/multiMaterial";
  60082. export * from "babylonjs/Materials/PBR/index";
  60083. export * from "babylonjs/Materials/pushMaterial";
  60084. export * from "babylonjs/Materials/shaderMaterial";
  60085. export * from "babylonjs/Materials/standardMaterial";
  60086. export * from "babylonjs/Materials/Textures/index";
  60087. export * from "babylonjs/Materials/uniformBuffer";
  60088. export * from "babylonjs/Materials/materialFlags";
  60089. export * from "babylonjs/Materials/Node/index";
  60090. export * from "babylonjs/Materials/effectRenderer";
  60091. }
  60092. declare module "babylonjs/Maths/index" {
  60093. export * from "babylonjs/Maths/math.scalar";
  60094. export * from "babylonjs/Maths/math";
  60095. export * from "babylonjs/Maths/sphericalPolynomial";
  60096. }
  60097. declare module "babylonjs/Misc/workerPool" {
  60098. import { IDisposable } from "babylonjs/scene";
  60099. /**
  60100. * Helper class to push actions to a pool of workers.
  60101. */
  60102. export class WorkerPool implements IDisposable {
  60103. private _workerInfos;
  60104. private _pendingActions;
  60105. /**
  60106. * Constructor
  60107. * @param workers Array of workers to use for actions
  60108. */
  60109. constructor(workers: Array<Worker>);
  60110. /**
  60111. * Terminates all workers and clears any pending actions.
  60112. */
  60113. dispose(): void;
  60114. /**
  60115. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60116. * pended until a worker has completed its action.
  60117. * @param action The action to perform. Call onComplete when the action is complete.
  60118. */
  60119. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60120. private _execute;
  60121. }
  60122. }
  60123. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60124. import { IDisposable } from "babylonjs/scene";
  60125. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60126. /**
  60127. * Configuration for Draco compression
  60128. */
  60129. export interface IDracoCompressionConfiguration {
  60130. /**
  60131. * Configuration for the decoder.
  60132. */
  60133. decoder: {
  60134. /**
  60135. * The url to the WebAssembly module.
  60136. */
  60137. wasmUrl?: string;
  60138. /**
  60139. * The url to the WebAssembly binary.
  60140. */
  60141. wasmBinaryUrl?: string;
  60142. /**
  60143. * The url to the fallback JavaScript module.
  60144. */
  60145. fallbackUrl?: string;
  60146. };
  60147. }
  60148. /**
  60149. * Draco compression (https://google.github.io/draco/)
  60150. *
  60151. * This class wraps the Draco module.
  60152. *
  60153. * **Encoder**
  60154. *
  60155. * The encoder is not currently implemented.
  60156. *
  60157. * **Decoder**
  60158. *
  60159. * 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.
  60160. *
  60161. * To update the configuration, use the following code:
  60162. * ```javascript
  60163. * DracoCompression.Configuration = {
  60164. * decoder: {
  60165. * wasmUrl: "<url to the WebAssembly library>",
  60166. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60167. * fallbackUrl: "<url to the fallback JavaScript library>",
  60168. * }
  60169. * };
  60170. * ```
  60171. *
  60172. * 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.
  60173. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60174. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60175. *
  60176. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60177. * ```javascript
  60178. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60179. * ```
  60180. *
  60181. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60182. */
  60183. export class DracoCompression implements IDisposable {
  60184. private _workerPoolPromise?;
  60185. private _decoderModulePromise?;
  60186. /**
  60187. * The configuration. Defaults to the following urls:
  60188. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60189. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60190. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60191. */
  60192. static Configuration: IDracoCompressionConfiguration;
  60193. /**
  60194. * Returns true if the decoder configuration is available.
  60195. */
  60196. static readonly DecoderAvailable: boolean;
  60197. /**
  60198. * Default number of workers to create when creating the draco compression object.
  60199. */
  60200. static DefaultNumWorkers: number;
  60201. private static GetDefaultNumWorkers;
  60202. private static _Default;
  60203. /**
  60204. * Default instance for the draco compression object.
  60205. */
  60206. static readonly Default: DracoCompression;
  60207. /**
  60208. * Constructor
  60209. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60210. */
  60211. constructor(numWorkers?: number);
  60212. /**
  60213. * Stop all async operations and release resources.
  60214. */
  60215. dispose(): void;
  60216. /**
  60217. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60218. * @returns a promise that resolves when ready
  60219. */
  60220. whenReadyAsync(): Promise<void>;
  60221. /**
  60222. * Decode Draco compressed mesh data to vertex data.
  60223. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60224. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60225. * @returns A promise that resolves with the decoded vertex data
  60226. */
  60227. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60228. [kind: string]: number;
  60229. }): Promise<VertexData>;
  60230. }
  60231. }
  60232. declare module "babylonjs/Meshes/Compression/index" {
  60233. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60234. }
  60235. declare module "babylonjs/Meshes/csg" {
  60236. import { Nullable } from "babylonjs/types";
  60237. import { Scene } from "babylonjs/scene";
  60238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60239. import { Mesh } from "babylonjs/Meshes/mesh";
  60240. import { Material } from "babylonjs/Materials/material";
  60241. /**
  60242. * Class for building Constructive Solid Geometry
  60243. */
  60244. export class CSG {
  60245. private polygons;
  60246. /**
  60247. * The world matrix
  60248. */
  60249. matrix: Matrix;
  60250. /**
  60251. * Stores the position
  60252. */
  60253. position: Vector3;
  60254. /**
  60255. * Stores the rotation
  60256. */
  60257. rotation: Vector3;
  60258. /**
  60259. * Stores the rotation quaternion
  60260. */
  60261. rotationQuaternion: Nullable<Quaternion>;
  60262. /**
  60263. * Stores the scaling vector
  60264. */
  60265. scaling: Vector3;
  60266. /**
  60267. * Convert the Mesh to CSG
  60268. * @param mesh The Mesh to convert to CSG
  60269. * @returns A new CSG from the Mesh
  60270. */
  60271. static FromMesh(mesh: Mesh): CSG;
  60272. /**
  60273. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60274. * @param polygons Polygons used to construct a CSG solid
  60275. */
  60276. private static FromPolygons;
  60277. /**
  60278. * Clones, or makes a deep copy, of the CSG
  60279. * @returns A new CSG
  60280. */
  60281. clone(): CSG;
  60282. /**
  60283. * Unions this CSG with another CSG
  60284. * @param csg The CSG to union against this CSG
  60285. * @returns The unioned CSG
  60286. */
  60287. union(csg: CSG): CSG;
  60288. /**
  60289. * Unions this CSG with another CSG in place
  60290. * @param csg The CSG to union against this CSG
  60291. */
  60292. unionInPlace(csg: CSG): void;
  60293. /**
  60294. * Subtracts this CSG with another CSG
  60295. * @param csg The CSG to subtract against this CSG
  60296. * @returns A new CSG
  60297. */
  60298. subtract(csg: CSG): CSG;
  60299. /**
  60300. * Subtracts this CSG with another CSG in place
  60301. * @param csg The CSG to subtact against this CSG
  60302. */
  60303. subtractInPlace(csg: CSG): void;
  60304. /**
  60305. * Intersect this CSG with another CSG
  60306. * @param csg The CSG to intersect against this CSG
  60307. * @returns A new CSG
  60308. */
  60309. intersect(csg: CSG): CSG;
  60310. /**
  60311. * Intersects this CSG with another CSG in place
  60312. * @param csg The CSG to intersect against this CSG
  60313. */
  60314. intersectInPlace(csg: CSG): void;
  60315. /**
  60316. * Return a new CSG solid with solid and empty space switched. This solid is
  60317. * not modified.
  60318. * @returns A new CSG solid with solid and empty space switched
  60319. */
  60320. inverse(): CSG;
  60321. /**
  60322. * Inverses the CSG in place
  60323. */
  60324. inverseInPlace(): void;
  60325. /**
  60326. * This is used to keep meshes transformations so they can be restored
  60327. * when we build back a Babylon Mesh
  60328. * NB : All CSG operations are performed in world coordinates
  60329. * @param csg The CSG to copy the transform attributes from
  60330. * @returns This CSG
  60331. */
  60332. copyTransformAttributes(csg: CSG): CSG;
  60333. /**
  60334. * Build Raw mesh from CSG
  60335. * Coordinates here are in world space
  60336. * @param name The name of the mesh geometry
  60337. * @param scene The Scene
  60338. * @param keepSubMeshes Specifies if the submeshes should be kept
  60339. * @returns A new Mesh
  60340. */
  60341. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60342. /**
  60343. * Build Mesh from CSG taking material and transforms into account
  60344. * @param name The name of the Mesh
  60345. * @param material The material of the Mesh
  60346. * @param scene The Scene
  60347. * @param keepSubMeshes Specifies if submeshes should be kept
  60348. * @returns The new Mesh
  60349. */
  60350. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60351. }
  60352. }
  60353. declare module "babylonjs/Meshes/trailMesh" {
  60354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60355. import { Mesh } from "babylonjs/Meshes/mesh";
  60356. import { Scene } from "babylonjs/scene";
  60357. /**
  60358. * Class used to create a trail following a mesh
  60359. */
  60360. export class TrailMesh extends Mesh {
  60361. private _generator;
  60362. private _autoStart;
  60363. private _running;
  60364. private _diameter;
  60365. private _length;
  60366. private _sectionPolygonPointsCount;
  60367. private _sectionVectors;
  60368. private _sectionNormalVectors;
  60369. private _beforeRenderObserver;
  60370. /**
  60371. * @constructor
  60372. * @param name The value used by scene.getMeshByName() to do a lookup.
  60373. * @param generator The mesh to generate a trail.
  60374. * @param scene The scene to add this mesh to.
  60375. * @param diameter Diameter of trailing mesh. Default is 1.
  60376. * @param length Length of trailing mesh. Default is 60.
  60377. * @param autoStart Automatically start trailing mesh. Default true.
  60378. */
  60379. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60380. /**
  60381. * "TrailMesh"
  60382. * @returns "TrailMesh"
  60383. */
  60384. getClassName(): string;
  60385. private _createMesh;
  60386. /**
  60387. * Start trailing mesh.
  60388. */
  60389. start(): void;
  60390. /**
  60391. * Stop trailing mesh.
  60392. */
  60393. stop(): void;
  60394. /**
  60395. * Update trailing mesh geometry.
  60396. */
  60397. update(): void;
  60398. /**
  60399. * Returns a new TrailMesh object.
  60400. * @param name is a string, the name given to the new mesh
  60401. * @param newGenerator use new generator object for cloned trail mesh
  60402. * @returns a new mesh
  60403. */
  60404. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60405. /**
  60406. * Serializes this trail mesh
  60407. * @param serializationObject object to write serialization to
  60408. */
  60409. serialize(serializationObject: any): void;
  60410. /**
  60411. * Parses a serialized trail mesh
  60412. * @param parsedMesh the serialized mesh
  60413. * @param scene the scene to create the trail mesh in
  60414. * @returns the created trail mesh
  60415. */
  60416. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60417. }
  60418. }
  60419. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60420. import { Nullable } from "babylonjs/types";
  60421. import { Scene } from "babylonjs/scene";
  60422. import { Vector4 } from "babylonjs/Maths/math.vector";
  60423. import { Color4 } from "babylonjs/Maths/math.color";
  60424. import { Mesh } from "babylonjs/Meshes/mesh";
  60425. /**
  60426. * Class containing static functions to help procedurally build meshes
  60427. */
  60428. export class TiledBoxBuilder {
  60429. /**
  60430. * Creates a box mesh
  60431. * 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)
  60432. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60436. * @param name defines the name of the mesh
  60437. * @param options defines the options used to create the mesh
  60438. * @param scene defines the hosting scene
  60439. * @returns the box mesh
  60440. */
  60441. static CreateTiledBox(name: string, options: {
  60442. pattern?: number;
  60443. width?: number;
  60444. height?: number;
  60445. depth?: number;
  60446. tileSize?: number;
  60447. tileWidth?: number;
  60448. tileHeight?: number;
  60449. alignHorizontal?: number;
  60450. alignVertical?: number;
  60451. faceUV?: Vector4[];
  60452. faceColors?: Color4[];
  60453. sideOrientation?: number;
  60454. updatable?: boolean;
  60455. }, scene?: Nullable<Scene>): Mesh;
  60456. }
  60457. }
  60458. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60459. import { Vector4 } from "babylonjs/Maths/math.vector";
  60460. import { Mesh } from "babylonjs/Meshes/mesh";
  60461. /**
  60462. * Class containing static functions to help procedurally build meshes
  60463. */
  60464. export class TorusKnotBuilder {
  60465. /**
  60466. * Creates a torus knot mesh
  60467. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60468. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60469. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60470. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60474. * @param name defines the name of the mesh
  60475. * @param options defines the options used to create the mesh
  60476. * @param scene defines the hosting scene
  60477. * @returns the torus knot mesh
  60478. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60479. */
  60480. static CreateTorusKnot(name: string, options: {
  60481. radius?: number;
  60482. tube?: number;
  60483. radialSegments?: number;
  60484. tubularSegments?: number;
  60485. p?: number;
  60486. q?: number;
  60487. updatable?: boolean;
  60488. sideOrientation?: number;
  60489. frontUVs?: Vector4;
  60490. backUVs?: Vector4;
  60491. }, scene: any): Mesh;
  60492. }
  60493. }
  60494. declare module "babylonjs/Meshes/polygonMesh" {
  60495. import { Scene } from "babylonjs/scene";
  60496. import { Vector2 } from "babylonjs/Maths/math.vector";
  60497. import { Mesh } from "babylonjs/Meshes/mesh";
  60498. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60499. import { Path2 } from "babylonjs/Maths/math.path";
  60500. /**
  60501. * Polygon
  60502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60503. */
  60504. export class Polygon {
  60505. /**
  60506. * Creates a rectangle
  60507. * @param xmin bottom X coord
  60508. * @param ymin bottom Y coord
  60509. * @param xmax top X coord
  60510. * @param ymax top Y coord
  60511. * @returns points that make the resulting rectation
  60512. */
  60513. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60514. /**
  60515. * Creates a circle
  60516. * @param radius radius of circle
  60517. * @param cx scale in x
  60518. * @param cy scale in y
  60519. * @param numberOfSides number of sides that make up the circle
  60520. * @returns points that make the resulting circle
  60521. */
  60522. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60523. /**
  60524. * Creates a polygon from input string
  60525. * @param input Input polygon data
  60526. * @returns the parsed points
  60527. */
  60528. static Parse(input: string): Vector2[];
  60529. /**
  60530. * Starts building a polygon from x and y coordinates
  60531. * @param x x coordinate
  60532. * @param y y coordinate
  60533. * @returns the started path2
  60534. */
  60535. static StartingAt(x: number, y: number): Path2;
  60536. }
  60537. /**
  60538. * Builds a polygon
  60539. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60540. */
  60541. export class PolygonMeshBuilder {
  60542. private _points;
  60543. private _outlinepoints;
  60544. private _holes;
  60545. private _name;
  60546. private _scene;
  60547. private _epoints;
  60548. private _eholes;
  60549. private _addToepoint;
  60550. /**
  60551. * Babylon reference to the earcut plugin.
  60552. */
  60553. bjsEarcut: any;
  60554. /**
  60555. * Creates a PolygonMeshBuilder
  60556. * @param name name of the builder
  60557. * @param contours Path of the polygon
  60558. * @param scene scene to add to when creating the mesh
  60559. * @param earcutInjection can be used to inject your own earcut reference
  60560. */
  60561. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60562. /**
  60563. * Adds a whole within the polygon
  60564. * @param hole Array of points defining the hole
  60565. * @returns this
  60566. */
  60567. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60568. /**
  60569. * Creates the polygon
  60570. * @param updatable If the mesh should be updatable
  60571. * @param depth The depth of the mesh created
  60572. * @returns the created mesh
  60573. */
  60574. build(updatable?: boolean, depth?: number): Mesh;
  60575. /**
  60576. * Creates the polygon
  60577. * @param depth The depth of the mesh created
  60578. * @returns the created VertexData
  60579. */
  60580. buildVertexData(depth?: number): VertexData;
  60581. /**
  60582. * Adds a side to the polygon
  60583. * @param positions points that make the polygon
  60584. * @param normals normals of the polygon
  60585. * @param uvs uvs of the polygon
  60586. * @param indices indices of the polygon
  60587. * @param bounds bounds of the polygon
  60588. * @param points points of the polygon
  60589. * @param depth depth of the polygon
  60590. * @param flip flip of the polygon
  60591. */
  60592. private addSide;
  60593. }
  60594. }
  60595. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60596. import { Scene } from "babylonjs/scene";
  60597. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60598. import { Color4 } from "babylonjs/Maths/math.color";
  60599. import { Mesh } from "babylonjs/Meshes/mesh";
  60600. import { Nullable } from "babylonjs/types";
  60601. /**
  60602. * Class containing static functions to help procedurally build meshes
  60603. */
  60604. export class PolygonBuilder {
  60605. /**
  60606. * Creates a polygon mesh
  60607. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60608. * * 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
  60609. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60612. * * Remember you can only change the shape positions, not their number when updating a polygon
  60613. * @param name defines the name of the mesh
  60614. * @param options defines the options used to create the mesh
  60615. * @param scene defines the hosting scene
  60616. * @param earcutInjection can be used to inject your own earcut reference
  60617. * @returns the polygon mesh
  60618. */
  60619. static CreatePolygon(name: string, options: {
  60620. shape: Vector3[];
  60621. holes?: Vector3[][];
  60622. depth?: number;
  60623. faceUV?: Vector4[];
  60624. faceColors?: Color4[];
  60625. updatable?: boolean;
  60626. sideOrientation?: number;
  60627. frontUVs?: Vector4;
  60628. backUVs?: Vector4;
  60629. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60630. /**
  60631. * Creates an extruded polygon mesh, with depth in the Y direction.
  60632. * * 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)
  60633. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60634. * @param name defines the name of the mesh
  60635. * @param options defines the options used to create the mesh
  60636. * @param scene defines the hosting scene
  60637. * @param earcutInjection can be used to inject your own earcut reference
  60638. * @returns the polygon mesh
  60639. */
  60640. static ExtrudePolygon(name: string, options: {
  60641. shape: Vector3[];
  60642. holes?: Vector3[][];
  60643. depth?: number;
  60644. faceUV?: Vector4[];
  60645. faceColors?: Color4[];
  60646. updatable?: boolean;
  60647. sideOrientation?: number;
  60648. frontUVs?: Vector4;
  60649. backUVs?: Vector4;
  60650. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60651. }
  60652. }
  60653. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60654. import { Scene } from "babylonjs/scene";
  60655. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60656. import { Mesh } from "babylonjs/Meshes/mesh";
  60657. import { Nullable } from "babylonjs/types";
  60658. /**
  60659. * Class containing static functions to help procedurally build meshes
  60660. */
  60661. export class LatheBuilder {
  60662. /**
  60663. * Creates lathe mesh.
  60664. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60665. * * 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
  60666. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60667. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60668. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60669. * * 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
  60670. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60671. * * 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
  60672. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60673. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60674. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60676. * @param name defines the name of the mesh
  60677. * @param options defines the options used to create the mesh
  60678. * @param scene defines the hosting scene
  60679. * @returns the lathe mesh
  60680. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60681. */
  60682. static CreateLathe(name: string, options: {
  60683. shape: Vector3[];
  60684. radius?: number;
  60685. tessellation?: number;
  60686. clip?: number;
  60687. arc?: number;
  60688. closed?: boolean;
  60689. updatable?: boolean;
  60690. sideOrientation?: number;
  60691. frontUVs?: Vector4;
  60692. backUVs?: Vector4;
  60693. cap?: number;
  60694. invertUV?: boolean;
  60695. }, scene?: Nullable<Scene>): Mesh;
  60696. }
  60697. }
  60698. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60699. import { Nullable } from "babylonjs/types";
  60700. import { Scene } from "babylonjs/scene";
  60701. import { Vector4 } from "babylonjs/Maths/math.vector";
  60702. import { Mesh } from "babylonjs/Meshes/mesh";
  60703. /**
  60704. * Class containing static functions to help procedurally build meshes
  60705. */
  60706. export class TiledPlaneBuilder {
  60707. /**
  60708. * Creates a tiled plane mesh
  60709. * * The parameter `pattern` will, depending on value, do nothing or
  60710. * * * flip (reflect about central vertical) alternate tiles across and up
  60711. * * * flip every tile on alternate rows
  60712. * * * rotate (180 degs) alternate tiles across and up
  60713. * * * rotate every tile on alternate rows
  60714. * * * flip and rotate alternate tiles across and up
  60715. * * * flip and rotate every tile on alternate rows
  60716. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60717. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60719. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60720. * * 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)
  60721. * * 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)
  60722. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60723. * @param name defines the name of the mesh
  60724. * @param options defines the options used to create the mesh
  60725. * @param scene defines the hosting scene
  60726. * @returns the box mesh
  60727. */
  60728. static CreateTiledPlane(name: string, options: {
  60729. pattern?: number;
  60730. tileSize?: number;
  60731. tileWidth?: number;
  60732. tileHeight?: number;
  60733. size?: number;
  60734. width?: number;
  60735. height?: number;
  60736. alignHorizontal?: number;
  60737. alignVertical?: number;
  60738. sideOrientation?: number;
  60739. frontUVs?: Vector4;
  60740. backUVs?: Vector4;
  60741. updatable?: boolean;
  60742. }, scene?: Nullable<Scene>): Mesh;
  60743. }
  60744. }
  60745. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60746. import { Nullable } from "babylonjs/types";
  60747. import { Scene } from "babylonjs/scene";
  60748. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60749. import { Mesh } from "babylonjs/Meshes/mesh";
  60750. /**
  60751. * Class containing static functions to help procedurally build meshes
  60752. */
  60753. export class TubeBuilder {
  60754. /**
  60755. * Creates a tube mesh.
  60756. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60757. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60758. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60759. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60760. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60761. * * 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)
  60762. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60763. * * 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
  60764. * * 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
  60765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60767. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60769. * @param name defines the name of the mesh
  60770. * @param options defines the options used to create the mesh
  60771. * @param scene defines the hosting scene
  60772. * @returns the tube mesh
  60773. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60774. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60775. */
  60776. static CreateTube(name: string, options: {
  60777. path: Vector3[];
  60778. radius?: number;
  60779. tessellation?: number;
  60780. radiusFunction?: {
  60781. (i: number, distance: number): number;
  60782. };
  60783. cap?: number;
  60784. arc?: number;
  60785. updatable?: boolean;
  60786. sideOrientation?: number;
  60787. frontUVs?: Vector4;
  60788. backUVs?: Vector4;
  60789. instance?: Mesh;
  60790. invertUV?: boolean;
  60791. }, scene?: Nullable<Scene>): Mesh;
  60792. }
  60793. }
  60794. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60795. import { Scene } from "babylonjs/scene";
  60796. import { Vector4 } from "babylonjs/Maths/math.vector";
  60797. import { Mesh } from "babylonjs/Meshes/mesh";
  60798. import { Nullable } from "babylonjs/types";
  60799. /**
  60800. * Class containing static functions to help procedurally build meshes
  60801. */
  60802. export class IcoSphereBuilder {
  60803. /**
  60804. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60805. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60806. * * 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`)
  60807. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60808. * * 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
  60809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60812. * @param name defines the name of the mesh
  60813. * @param options defines the options used to create the mesh
  60814. * @param scene defines the hosting scene
  60815. * @returns the icosahedron mesh
  60816. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60817. */
  60818. static CreateIcoSphere(name: string, options: {
  60819. radius?: number;
  60820. radiusX?: number;
  60821. radiusY?: number;
  60822. radiusZ?: number;
  60823. flat?: boolean;
  60824. subdivisions?: number;
  60825. sideOrientation?: number;
  60826. frontUVs?: Vector4;
  60827. backUVs?: Vector4;
  60828. updatable?: boolean;
  60829. }, scene?: Nullable<Scene>): Mesh;
  60830. }
  60831. }
  60832. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60833. import { Vector3 } from "babylonjs/Maths/math.vector";
  60834. import { Mesh } from "babylonjs/Meshes/mesh";
  60835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60836. /**
  60837. * Class containing static functions to help procedurally build meshes
  60838. */
  60839. export class DecalBuilder {
  60840. /**
  60841. * Creates a decal mesh.
  60842. * 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
  60843. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60844. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60845. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60846. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60847. * @param name defines the name of the mesh
  60848. * @param sourceMesh defines the mesh where the decal must be applied
  60849. * @param options defines the options used to create the mesh
  60850. * @param scene defines the hosting scene
  60851. * @returns the decal mesh
  60852. * @see https://doc.babylonjs.com/how_to/decals
  60853. */
  60854. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60855. position?: Vector3;
  60856. normal?: Vector3;
  60857. size?: Vector3;
  60858. angle?: number;
  60859. }): Mesh;
  60860. }
  60861. }
  60862. declare module "babylonjs/Meshes/meshBuilder" {
  60863. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60864. import { Nullable } from "babylonjs/types";
  60865. import { Scene } from "babylonjs/scene";
  60866. import { Mesh } from "babylonjs/Meshes/mesh";
  60867. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60868. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60870. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60871. import { Plane } from "babylonjs/Maths/math.plane";
  60872. /**
  60873. * Class containing static functions to help procedurally build meshes
  60874. */
  60875. export class MeshBuilder {
  60876. /**
  60877. * Creates a box mesh
  60878. * * The parameter `size` sets the size (float) of each box side (default 1)
  60879. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60880. * * 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)
  60881. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60885. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60886. * @param name defines the name of the mesh
  60887. * @param options defines the options used to create the mesh
  60888. * @param scene defines the hosting scene
  60889. * @returns the box mesh
  60890. */
  60891. static CreateBox(name: string, options: {
  60892. size?: number;
  60893. width?: number;
  60894. height?: number;
  60895. depth?: number;
  60896. faceUV?: Vector4[];
  60897. faceColors?: Color4[];
  60898. sideOrientation?: number;
  60899. frontUVs?: Vector4;
  60900. backUVs?: Vector4;
  60901. updatable?: boolean;
  60902. }, scene?: Nullable<Scene>): Mesh;
  60903. /**
  60904. * Creates a tiled box mesh
  60905. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60907. * @param name defines the name of the mesh
  60908. * @param options defines the options used to create the mesh
  60909. * @param scene defines the hosting scene
  60910. * @returns the tiled box mesh
  60911. */
  60912. static CreateTiledBox(name: string, options: {
  60913. pattern?: number;
  60914. size?: number;
  60915. width?: number;
  60916. height?: number;
  60917. depth: number;
  60918. tileSize?: number;
  60919. tileWidth?: number;
  60920. tileHeight?: number;
  60921. faceUV?: Vector4[];
  60922. faceColors?: Color4[];
  60923. alignHorizontal?: number;
  60924. alignVertical?: number;
  60925. sideOrientation?: number;
  60926. updatable?: boolean;
  60927. }, scene?: Nullable<Scene>): Mesh;
  60928. /**
  60929. * Creates a sphere mesh
  60930. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60931. * * 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`)
  60932. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60933. * * 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
  60934. * * 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)
  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. * @param name defines the name of the mesh
  60939. * @param options defines the options used to create the mesh
  60940. * @param scene defines the hosting scene
  60941. * @returns the sphere mesh
  60942. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60943. */
  60944. static CreateSphere(name: string, options: {
  60945. segments?: number;
  60946. diameter?: number;
  60947. diameterX?: number;
  60948. diameterY?: number;
  60949. diameterZ?: number;
  60950. arc?: number;
  60951. slice?: number;
  60952. sideOrientation?: number;
  60953. frontUVs?: Vector4;
  60954. backUVs?: Vector4;
  60955. updatable?: boolean;
  60956. }, scene?: Nullable<Scene>): Mesh;
  60957. /**
  60958. * Creates a plane polygonal mesh. By default, this is a disc
  60959. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60960. * * 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
  60961. * * 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
  60962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60965. * @param name defines the name of the mesh
  60966. * @param options defines the options used to create the mesh
  60967. * @param scene defines the hosting scene
  60968. * @returns the plane polygonal mesh
  60969. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60970. */
  60971. static CreateDisc(name: string, options: {
  60972. radius?: number;
  60973. tessellation?: number;
  60974. arc?: number;
  60975. updatable?: boolean;
  60976. sideOrientation?: number;
  60977. frontUVs?: Vector4;
  60978. backUVs?: Vector4;
  60979. }, scene?: Nullable<Scene>): Mesh;
  60980. /**
  60981. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60982. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60983. * * 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`)
  60984. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60985. * * 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
  60986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60989. * @param name defines the name of the mesh
  60990. * @param options defines the options used to create the mesh
  60991. * @param scene defines the hosting scene
  60992. * @returns the icosahedron mesh
  60993. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60994. */
  60995. static CreateIcoSphere(name: string, options: {
  60996. radius?: number;
  60997. radiusX?: number;
  60998. radiusY?: number;
  60999. radiusZ?: number;
  61000. flat?: boolean;
  61001. subdivisions?: number;
  61002. sideOrientation?: number;
  61003. frontUVs?: Vector4;
  61004. backUVs?: Vector4;
  61005. updatable?: boolean;
  61006. }, scene?: Nullable<Scene>): Mesh;
  61007. /**
  61008. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61009. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61010. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61011. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61012. * * 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
  61013. * * 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
  61014. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61018. * * 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
  61019. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61020. * * 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
  61021. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61023. * @param name defines the name of the mesh
  61024. * @param options defines the options used to create the mesh
  61025. * @param scene defines the hosting scene
  61026. * @returns the ribbon mesh
  61027. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61029. */
  61030. static CreateRibbon(name: string, options: {
  61031. pathArray: Vector3[][];
  61032. closeArray?: boolean;
  61033. closePath?: boolean;
  61034. offset?: number;
  61035. updatable?: boolean;
  61036. sideOrientation?: number;
  61037. frontUVs?: Vector4;
  61038. backUVs?: Vector4;
  61039. instance?: Mesh;
  61040. invertUV?: boolean;
  61041. uvs?: Vector2[];
  61042. colors?: Color4[];
  61043. }, scene?: Nullable<Scene>): Mesh;
  61044. /**
  61045. * Creates a cylinder or a cone mesh
  61046. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61047. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61048. * * 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.
  61049. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61050. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61051. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61052. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61053. * * 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).
  61054. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61055. * * 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).
  61056. * * 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
  61057. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61058. * * 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
  61059. * * 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.
  61060. * * If `enclose` is false, a ring surface is one element.
  61061. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61062. * * 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
  61063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61066. * @param name defines the name of the mesh
  61067. * @param options defines the options used to create the mesh
  61068. * @param scene defines the hosting scene
  61069. * @returns the cylinder mesh
  61070. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61071. */
  61072. static CreateCylinder(name: string, options: {
  61073. height?: number;
  61074. diameterTop?: number;
  61075. diameterBottom?: number;
  61076. diameter?: number;
  61077. tessellation?: number;
  61078. subdivisions?: number;
  61079. arc?: number;
  61080. faceColors?: Color4[];
  61081. faceUV?: Vector4[];
  61082. updatable?: boolean;
  61083. hasRings?: boolean;
  61084. enclose?: boolean;
  61085. cap?: number;
  61086. sideOrientation?: number;
  61087. frontUVs?: Vector4;
  61088. backUVs?: Vector4;
  61089. }, scene?: Nullable<Scene>): Mesh;
  61090. /**
  61091. * Creates a torus mesh
  61092. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61093. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61094. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61098. * @param name defines the name of the mesh
  61099. * @param options defines the options used to create the mesh
  61100. * @param scene defines the hosting scene
  61101. * @returns the torus mesh
  61102. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61103. */
  61104. static CreateTorus(name: string, options: {
  61105. diameter?: number;
  61106. thickness?: number;
  61107. tessellation?: number;
  61108. updatable?: boolean;
  61109. sideOrientation?: number;
  61110. frontUVs?: Vector4;
  61111. backUVs?: Vector4;
  61112. }, scene?: Nullable<Scene>): Mesh;
  61113. /**
  61114. * Creates a torus knot mesh
  61115. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61116. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61117. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61118. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61122. * @param name defines the name of the mesh
  61123. * @param options defines the options used to create the mesh
  61124. * @param scene defines the hosting scene
  61125. * @returns the torus knot mesh
  61126. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61127. */
  61128. static CreateTorusKnot(name: string, options: {
  61129. radius?: number;
  61130. tube?: number;
  61131. radialSegments?: number;
  61132. tubularSegments?: number;
  61133. p?: number;
  61134. q?: number;
  61135. updatable?: boolean;
  61136. sideOrientation?: number;
  61137. frontUVs?: Vector4;
  61138. backUVs?: Vector4;
  61139. }, scene?: Nullable<Scene>): Mesh;
  61140. /**
  61141. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61142. * * 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
  61143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61144. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61145. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61146. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61147. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61148. * * 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
  61149. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61152. * @param name defines the name of the new line system
  61153. * @param options defines the options used to create the line system
  61154. * @param scene defines the hosting scene
  61155. * @returns a new line system mesh
  61156. */
  61157. static CreateLineSystem(name: string, options: {
  61158. lines: Vector3[][];
  61159. updatable?: boolean;
  61160. instance?: Nullable<LinesMesh>;
  61161. colors?: Nullable<Color4[][]>;
  61162. useVertexAlpha?: boolean;
  61163. }, scene: Nullable<Scene>): LinesMesh;
  61164. /**
  61165. * Creates a line mesh
  61166. * 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
  61167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61168. * * The parameter `points` is an array successive Vector3
  61169. * * 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
  61170. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61172. * * When updating an instance, remember that only point positions can change, not the number of points
  61173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61175. * @param name defines the name of the new line system
  61176. * @param options defines the options used to create the line system
  61177. * @param scene defines the hosting scene
  61178. * @returns a new line mesh
  61179. */
  61180. static CreateLines(name: string, options: {
  61181. points: Vector3[];
  61182. updatable?: boolean;
  61183. instance?: Nullable<LinesMesh>;
  61184. colors?: Color4[];
  61185. useVertexAlpha?: boolean;
  61186. }, scene?: Nullable<Scene>): LinesMesh;
  61187. /**
  61188. * Creates a dashed line mesh
  61189. * * 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
  61190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61191. * * The parameter `points` is an array successive Vector3
  61192. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61193. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61194. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61195. * * 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
  61196. * * When updating an instance, remember that only point positions can change, not the number of points
  61197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61198. * @param name defines the name of the mesh
  61199. * @param options defines the options used to create the mesh
  61200. * @param scene defines the hosting scene
  61201. * @returns the dashed line mesh
  61202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61203. */
  61204. static CreateDashedLines(name: string, options: {
  61205. points: Vector3[];
  61206. dashSize?: number;
  61207. gapSize?: number;
  61208. dashNb?: number;
  61209. updatable?: boolean;
  61210. instance?: LinesMesh;
  61211. }, scene?: Nullable<Scene>): LinesMesh;
  61212. /**
  61213. * 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.
  61214. * * 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.
  61215. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61216. * * 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.
  61217. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61218. * * 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
  61219. * * 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
  61220. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61225. * @param name defines the name of the mesh
  61226. * @param options defines the options used to create the mesh
  61227. * @param scene defines the hosting scene
  61228. * @returns the extruded shape mesh
  61229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61231. */
  61232. static ExtrudeShape(name: string, options: {
  61233. shape: Vector3[];
  61234. path: Vector3[];
  61235. scale?: number;
  61236. rotation?: number;
  61237. cap?: number;
  61238. updatable?: boolean;
  61239. sideOrientation?: number;
  61240. frontUVs?: Vector4;
  61241. backUVs?: Vector4;
  61242. instance?: Mesh;
  61243. invertUV?: boolean;
  61244. }, scene?: Nullable<Scene>): Mesh;
  61245. /**
  61246. * Creates an custom extruded shape mesh.
  61247. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61248. * * 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.
  61249. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61250. * * 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
  61251. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61252. * * 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
  61253. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61254. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61255. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61256. * * 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
  61257. * * 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
  61258. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61260. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61261. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61263. * @param name defines the name of the mesh
  61264. * @param options defines the options used to create the mesh
  61265. * @param scene defines the hosting scene
  61266. * @returns the custom extruded shape mesh
  61267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61270. */
  61271. static ExtrudeShapeCustom(name: string, options: {
  61272. shape: Vector3[];
  61273. path: Vector3[];
  61274. scaleFunction?: any;
  61275. rotationFunction?: any;
  61276. ribbonCloseArray?: boolean;
  61277. ribbonClosePath?: boolean;
  61278. cap?: number;
  61279. updatable?: boolean;
  61280. sideOrientation?: number;
  61281. frontUVs?: Vector4;
  61282. backUVs?: Vector4;
  61283. instance?: Mesh;
  61284. invertUV?: boolean;
  61285. }, scene?: Nullable<Scene>): Mesh;
  61286. /**
  61287. * Creates lathe mesh.
  61288. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61289. * * 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
  61290. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61291. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61292. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61293. * * 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
  61294. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61295. * * 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
  61296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61298. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61300. * @param name defines the name of the mesh
  61301. * @param options defines the options used to create the mesh
  61302. * @param scene defines the hosting scene
  61303. * @returns the lathe mesh
  61304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61305. */
  61306. static CreateLathe(name: string, options: {
  61307. shape: Vector3[];
  61308. radius?: number;
  61309. tessellation?: number;
  61310. clip?: number;
  61311. arc?: number;
  61312. closed?: boolean;
  61313. updatable?: boolean;
  61314. sideOrientation?: number;
  61315. frontUVs?: Vector4;
  61316. backUVs?: Vector4;
  61317. cap?: number;
  61318. invertUV?: boolean;
  61319. }, scene?: Nullable<Scene>): Mesh;
  61320. /**
  61321. * Creates a tiled plane mesh
  61322. * * You can set a limited pattern arrangement with the tiles
  61323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61326. * @param name defines the name of the mesh
  61327. * @param options defines the options used to create the mesh
  61328. * @param scene defines the hosting scene
  61329. * @returns the plane mesh
  61330. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61331. */
  61332. static CreateTiledPlane(name: string, options: {
  61333. pattern?: number;
  61334. tileSize?: number;
  61335. tileWidth?: number;
  61336. tileHeight?: number;
  61337. size?: number;
  61338. width?: number;
  61339. height?: number;
  61340. alignHorizontal?: number;
  61341. alignVertical?: number;
  61342. sideOrientation?: number;
  61343. frontUVs?: Vector4;
  61344. backUVs?: Vector4;
  61345. updatable?: boolean;
  61346. }, scene?: Nullable<Scene>): Mesh;
  61347. /**
  61348. * Creates a plane mesh
  61349. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61350. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61351. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61355. * @param name defines the name of the mesh
  61356. * @param options defines the options used to create the mesh
  61357. * @param scene defines the hosting scene
  61358. * @returns the plane mesh
  61359. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61360. */
  61361. static CreatePlane(name: string, options: {
  61362. size?: number;
  61363. width?: number;
  61364. height?: number;
  61365. sideOrientation?: number;
  61366. frontUVs?: Vector4;
  61367. backUVs?: Vector4;
  61368. updatable?: boolean;
  61369. sourcePlane?: Plane;
  61370. }, scene?: Nullable<Scene>): Mesh;
  61371. /**
  61372. * Creates a ground mesh
  61373. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61374. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61376. * @param name defines the name of the mesh
  61377. * @param options defines the options used to create the mesh
  61378. * @param scene defines the hosting scene
  61379. * @returns the ground mesh
  61380. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61381. */
  61382. static CreateGround(name: string, options: {
  61383. width?: number;
  61384. height?: number;
  61385. subdivisions?: number;
  61386. subdivisionsX?: number;
  61387. subdivisionsY?: number;
  61388. updatable?: boolean;
  61389. }, scene?: Nullable<Scene>): Mesh;
  61390. /**
  61391. * Creates a tiled ground mesh
  61392. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61393. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61394. * * 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
  61395. * * 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
  61396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61397. * @param name defines the name of the mesh
  61398. * @param options defines the options used to create the mesh
  61399. * @param scene defines the hosting scene
  61400. * @returns the tiled ground mesh
  61401. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61402. */
  61403. static CreateTiledGround(name: string, options: {
  61404. xmin: number;
  61405. zmin: number;
  61406. xmax: number;
  61407. zmax: number;
  61408. subdivisions?: {
  61409. w: number;
  61410. h: number;
  61411. };
  61412. precision?: {
  61413. w: number;
  61414. h: number;
  61415. };
  61416. updatable?: boolean;
  61417. }, scene?: Nullable<Scene>): Mesh;
  61418. /**
  61419. * Creates a ground mesh from a height map
  61420. * * The parameter `url` sets the URL of the height map image resource.
  61421. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61422. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61423. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61424. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61425. * * 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.
  61426. * * 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).
  61427. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  61431. * @param options defines the options used to create the mesh
  61432. * @param scene defines the hosting scene
  61433. * @returns the ground mesh
  61434. * @see https://doc.babylonjs.com/babylon101/height_map
  61435. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61436. */
  61437. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61438. width?: number;
  61439. height?: number;
  61440. subdivisions?: number;
  61441. minHeight?: number;
  61442. maxHeight?: number;
  61443. colorFilter?: Color3;
  61444. alphaFilter?: number;
  61445. updatable?: boolean;
  61446. onReady?: (mesh: GroundMesh) => void;
  61447. }, scene?: Nullable<Scene>): GroundMesh;
  61448. /**
  61449. * Creates a polygon mesh
  61450. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61451. * * 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
  61452. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61453. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61455. * * Remember you can only change the shape positions, not their number when updating a polygon
  61456. * @param name defines the name of the mesh
  61457. * @param options defines the options used to create the mesh
  61458. * @param scene defines the hosting scene
  61459. * @param earcutInjection can be used to inject your own earcut reference
  61460. * @returns the polygon mesh
  61461. */
  61462. static CreatePolygon(name: string, options: {
  61463. shape: Vector3[];
  61464. holes?: Vector3[][];
  61465. depth?: number;
  61466. faceUV?: Vector4[];
  61467. faceColors?: Color4[];
  61468. updatable?: boolean;
  61469. sideOrientation?: number;
  61470. frontUVs?: Vector4;
  61471. backUVs?: Vector4;
  61472. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61473. /**
  61474. * Creates an extruded polygon mesh, with depth in the Y direction.
  61475. * * 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)
  61476. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61477. * @param name defines the name of the mesh
  61478. * @param options defines the options used to create the mesh
  61479. * @param scene defines the hosting scene
  61480. * @param earcutInjection can be used to inject your own earcut reference
  61481. * @returns the polygon mesh
  61482. */
  61483. static ExtrudePolygon(name: string, options: {
  61484. shape: Vector3[];
  61485. holes?: Vector3[][];
  61486. depth?: number;
  61487. faceUV?: Vector4[];
  61488. faceColors?: Color4[];
  61489. updatable?: boolean;
  61490. sideOrientation?: number;
  61491. frontUVs?: Vector4;
  61492. backUVs?: Vector4;
  61493. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61494. /**
  61495. * Creates a tube mesh.
  61496. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61497. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61498. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61499. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61500. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61501. * * 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)
  61502. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61503. * * 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
  61504. * * 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
  61505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the tube mesh
  61513. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61514. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61515. */
  61516. static CreateTube(name: string, options: {
  61517. path: Vector3[];
  61518. radius?: number;
  61519. tessellation?: number;
  61520. radiusFunction?: {
  61521. (i: number, distance: number): number;
  61522. };
  61523. cap?: number;
  61524. arc?: number;
  61525. updatable?: boolean;
  61526. sideOrientation?: number;
  61527. frontUVs?: Vector4;
  61528. backUVs?: Vector4;
  61529. instance?: Mesh;
  61530. invertUV?: boolean;
  61531. }, scene?: Nullable<Scene>): Mesh;
  61532. /**
  61533. * Creates a polyhedron mesh
  61534. * * 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
  61535. * * The parameter `size` (positive float, default 1) sets the polygon size
  61536. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61537. * * 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`
  61538. * * 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
  61539. * * 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)`)
  61540. * * 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
  61541. * * 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
  61542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61545. * @param name defines the name of the mesh
  61546. * @param options defines the options used to create the mesh
  61547. * @param scene defines the hosting scene
  61548. * @returns the polyhedron mesh
  61549. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61550. */
  61551. static CreatePolyhedron(name: string, options: {
  61552. type?: number;
  61553. size?: number;
  61554. sizeX?: number;
  61555. sizeY?: number;
  61556. sizeZ?: number;
  61557. custom?: any;
  61558. faceUV?: Vector4[];
  61559. faceColors?: Color4[];
  61560. flat?: boolean;
  61561. updatable?: boolean;
  61562. sideOrientation?: number;
  61563. frontUVs?: Vector4;
  61564. backUVs?: Vector4;
  61565. }, scene?: Nullable<Scene>): Mesh;
  61566. /**
  61567. * Creates a decal mesh.
  61568. * 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
  61569. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61570. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61571. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61572. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61573. * @param name defines the name of the mesh
  61574. * @param sourceMesh defines the mesh where the decal must be applied
  61575. * @param options defines the options used to create the mesh
  61576. * @param scene defines the hosting scene
  61577. * @returns the decal mesh
  61578. * @see https://doc.babylonjs.com/how_to/decals
  61579. */
  61580. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61581. position?: Vector3;
  61582. normal?: Vector3;
  61583. size?: Vector3;
  61584. angle?: number;
  61585. }): Mesh;
  61586. }
  61587. }
  61588. declare module "babylonjs/Meshes/meshSimplification" {
  61589. import { Mesh } from "babylonjs/Meshes/mesh";
  61590. /**
  61591. * A simplifier interface for future simplification implementations
  61592. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61593. */
  61594. export interface ISimplifier {
  61595. /**
  61596. * Simplification of a given mesh according to the given settings.
  61597. * Since this requires computation, it is assumed that the function runs async.
  61598. * @param settings The settings of the simplification, including quality and distance
  61599. * @param successCallback A callback that will be called after the mesh was simplified.
  61600. * @param errorCallback in case of an error, this callback will be called. optional.
  61601. */
  61602. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61603. }
  61604. /**
  61605. * Expected simplification settings.
  61606. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61607. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61608. */
  61609. export interface ISimplificationSettings {
  61610. /**
  61611. * Gets or sets the expected quality
  61612. */
  61613. quality: number;
  61614. /**
  61615. * Gets or sets the distance when this optimized version should be used
  61616. */
  61617. distance: number;
  61618. /**
  61619. * Gets an already optimized mesh
  61620. */
  61621. optimizeMesh?: boolean;
  61622. }
  61623. /**
  61624. * Class used to specify simplification options
  61625. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61626. */
  61627. export class SimplificationSettings implements ISimplificationSettings {
  61628. /** expected quality */
  61629. quality: number;
  61630. /** distance when this optimized version should be used */
  61631. distance: number;
  61632. /** already optimized mesh */
  61633. optimizeMesh?: boolean | undefined;
  61634. /**
  61635. * Creates a SimplificationSettings
  61636. * @param quality expected quality
  61637. * @param distance distance when this optimized version should be used
  61638. * @param optimizeMesh already optimized mesh
  61639. */
  61640. constructor(
  61641. /** expected quality */
  61642. quality: number,
  61643. /** distance when this optimized version should be used */
  61644. distance: number,
  61645. /** already optimized mesh */
  61646. optimizeMesh?: boolean | undefined);
  61647. }
  61648. /**
  61649. * Interface used to define a simplification task
  61650. */
  61651. export interface ISimplificationTask {
  61652. /**
  61653. * Array of settings
  61654. */
  61655. settings: Array<ISimplificationSettings>;
  61656. /**
  61657. * Simplification type
  61658. */
  61659. simplificationType: SimplificationType;
  61660. /**
  61661. * Mesh to simplify
  61662. */
  61663. mesh: Mesh;
  61664. /**
  61665. * Callback called on success
  61666. */
  61667. successCallback?: () => void;
  61668. /**
  61669. * Defines if parallel processing can be used
  61670. */
  61671. parallelProcessing: boolean;
  61672. }
  61673. /**
  61674. * Queue used to order the simplification tasks
  61675. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61676. */
  61677. export class SimplificationQueue {
  61678. private _simplificationArray;
  61679. /**
  61680. * Gets a boolean indicating that the process is still running
  61681. */
  61682. running: boolean;
  61683. /**
  61684. * Creates a new queue
  61685. */
  61686. constructor();
  61687. /**
  61688. * Adds a new simplification task
  61689. * @param task defines a task to add
  61690. */
  61691. addTask(task: ISimplificationTask): void;
  61692. /**
  61693. * Execute next task
  61694. */
  61695. executeNext(): void;
  61696. /**
  61697. * Execute a simplification task
  61698. * @param task defines the task to run
  61699. */
  61700. runSimplification(task: ISimplificationTask): void;
  61701. private getSimplifier;
  61702. }
  61703. /**
  61704. * The implemented types of simplification
  61705. * At the moment only Quadratic Error Decimation is implemented
  61706. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61707. */
  61708. export enum SimplificationType {
  61709. /** Quadratic error decimation */
  61710. QUADRATIC = 0
  61711. }
  61712. }
  61713. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61714. import { Scene } from "babylonjs/scene";
  61715. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61716. import { ISceneComponent } from "babylonjs/sceneComponent";
  61717. module "babylonjs/scene" {
  61718. interface Scene {
  61719. /** @hidden (Backing field) */
  61720. _simplificationQueue: SimplificationQueue;
  61721. /**
  61722. * Gets or sets the simplification queue attached to the scene
  61723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61724. */
  61725. simplificationQueue: SimplificationQueue;
  61726. }
  61727. }
  61728. module "babylonjs/Meshes/mesh" {
  61729. interface Mesh {
  61730. /**
  61731. * Simplify the mesh according to the given array of settings.
  61732. * Function will return immediately and will simplify async
  61733. * @param settings a collection of simplification settings
  61734. * @param parallelProcessing should all levels calculate parallel or one after the other
  61735. * @param simplificationType the type of simplification to run
  61736. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61737. * @returns the current mesh
  61738. */
  61739. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61740. }
  61741. }
  61742. /**
  61743. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61744. * created in a scene
  61745. */
  61746. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61747. /**
  61748. * The component name helpfull to identify the component in the list of scene components.
  61749. */
  61750. readonly name: string;
  61751. /**
  61752. * The scene the component belongs to.
  61753. */
  61754. scene: Scene;
  61755. /**
  61756. * Creates a new instance of the component for the given scene
  61757. * @param scene Defines the scene to register the component in
  61758. */
  61759. constructor(scene: Scene);
  61760. /**
  61761. * Registers the component in a given scene
  61762. */
  61763. register(): void;
  61764. /**
  61765. * Rebuilds the elements related to this component in case of
  61766. * context lost for instance.
  61767. */
  61768. rebuild(): void;
  61769. /**
  61770. * Disposes the component and the associated ressources
  61771. */
  61772. dispose(): void;
  61773. private _beforeCameraUpdate;
  61774. }
  61775. }
  61776. declare module "babylonjs/Meshes/Builders/index" {
  61777. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61778. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61779. export * from "babylonjs/Meshes/Builders/discBuilder";
  61780. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61781. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61782. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61783. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61784. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61785. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61786. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61787. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61788. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61789. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61790. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61791. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61792. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61793. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61794. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61795. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61796. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61797. }
  61798. declare module "babylonjs/Meshes/index" {
  61799. export * from "babylonjs/Meshes/abstractMesh";
  61800. export * from "babylonjs/Meshes/buffer";
  61801. export * from "babylonjs/Meshes/Compression/index";
  61802. export * from "babylonjs/Meshes/csg";
  61803. export * from "babylonjs/Meshes/geometry";
  61804. export * from "babylonjs/Meshes/groundMesh";
  61805. export * from "babylonjs/Meshes/trailMesh";
  61806. export * from "babylonjs/Meshes/instancedMesh";
  61807. export * from "babylonjs/Meshes/linesMesh";
  61808. export * from "babylonjs/Meshes/mesh";
  61809. export * from "babylonjs/Meshes/mesh.vertexData";
  61810. export * from "babylonjs/Meshes/meshBuilder";
  61811. export * from "babylonjs/Meshes/meshSimplification";
  61812. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61813. export * from "babylonjs/Meshes/polygonMesh";
  61814. export * from "babylonjs/Meshes/subMesh";
  61815. export * from "babylonjs/Meshes/meshLODLevel";
  61816. export * from "babylonjs/Meshes/transformNode";
  61817. export * from "babylonjs/Meshes/Builders/index";
  61818. export * from "babylonjs/Meshes/dataBuffer";
  61819. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61820. }
  61821. declare module "babylonjs/Morph/index" {
  61822. export * from "babylonjs/Morph/morphTarget";
  61823. export * from "babylonjs/Morph/morphTargetManager";
  61824. }
  61825. declare module "babylonjs/Navigation/INavigationEngine" {
  61826. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61827. import { Vector3 } from "babylonjs/Maths/math";
  61828. import { Mesh } from "babylonjs/Meshes/mesh";
  61829. import { Scene } from "babylonjs/scene";
  61830. /**
  61831. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61832. */
  61833. export interface INavigationEnginePlugin {
  61834. /**
  61835. * plugin name
  61836. */
  61837. name: string;
  61838. /**
  61839. * Creates a navigation mesh
  61840. * @param meshes array of all the geometry used to compute the navigatio mesh
  61841. * @param parameters bunch of parameters used to filter geometry
  61842. */
  61843. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61844. /**
  61845. * Create a navigation mesh debug mesh
  61846. * @param scene is where the mesh will be added
  61847. * @returns debug display mesh
  61848. */
  61849. createDebugNavMesh(scene: Scene): Mesh;
  61850. /**
  61851. * Get a navigation mesh constrained position, closest to the parameter position
  61852. * @param position world position
  61853. * @returns the closest point to position constrained by the navigation mesh
  61854. */
  61855. getClosestPoint(position: Vector3): Vector3;
  61856. /**
  61857. * Get a navigation mesh constrained position, within a particular radius
  61858. * @param position world position
  61859. * @param maxRadius the maximum distance to the constrained world position
  61860. * @returns the closest point to position constrained by the navigation mesh
  61861. */
  61862. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61863. /**
  61864. * Compute the final position from a segment made of destination-position
  61865. * @param position world position
  61866. * @param destination world position
  61867. * @returns the resulting point along the navmesh
  61868. */
  61869. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61870. /**
  61871. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61872. * @param start world position
  61873. * @param end world position
  61874. * @returns array containing world position composing the path
  61875. */
  61876. computePath(start: Vector3, end: Vector3): Vector3[];
  61877. /**
  61878. * If this plugin is supported
  61879. * @returns true if plugin is supported
  61880. */
  61881. isSupported(): boolean;
  61882. /**
  61883. * Create a new Crowd so you can add agents
  61884. * @param maxAgents the maximum agent count in the crowd
  61885. * @param maxAgentRadius the maximum radius an agent can have
  61886. * @param scene to attach the crowd to
  61887. * @returns the crowd you can add agents to
  61888. */
  61889. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61890. /**
  61891. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61892. * The queries will try to find a solution within those bounds
  61893. * default is (1,1,1)
  61894. * @param extent x,y,z value that define the extent around the queries point of reference
  61895. */
  61896. setDefaultQueryExtent(extent: Vector3): void;
  61897. /**
  61898. * Get the Bounding box extent specified by setDefaultQueryExtent
  61899. * @returns the box extent values
  61900. */
  61901. getDefaultQueryExtent(): Vector3;
  61902. /**
  61903. * Release all resources
  61904. */
  61905. dispose(): void;
  61906. }
  61907. /**
  61908. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61909. */
  61910. export interface ICrowd {
  61911. /**
  61912. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61913. * You can attach anything to that node. The node position is updated in the scene update tick.
  61914. * @param pos world position that will be constrained by the navigation mesh
  61915. * @param parameters agent parameters
  61916. * @param transform hooked to the agent that will be update by the scene
  61917. * @returns agent index
  61918. */
  61919. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61920. /**
  61921. * Returns the agent position in world space
  61922. * @param index agent index returned by addAgent
  61923. * @returns world space position
  61924. */
  61925. getAgentPosition(index: number): Vector3;
  61926. /**
  61927. * Gets the agent velocity in world space
  61928. * @param index agent index returned by addAgent
  61929. * @returns world space velocity
  61930. */
  61931. getAgentVelocity(index: number): Vector3;
  61932. /**
  61933. * remove a particular agent previously created
  61934. * @param index agent index returned by addAgent
  61935. */
  61936. removeAgent(index: number): void;
  61937. /**
  61938. * get the list of all agents attached to this crowd
  61939. * @returns list of agent indices
  61940. */
  61941. getAgents(): number[];
  61942. /**
  61943. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61944. * @param deltaTime in seconds
  61945. */
  61946. update(deltaTime: number): void;
  61947. /**
  61948. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61949. * @param index agent index returned by addAgent
  61950. * @param destination targeted world position
  61951. */
  61952. agentGoto(index: number, destination: Vector3): void;
  61953. /**
  61954. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61955. * The queries will try to find a solution within those bounds
  61956. * default is (1,1,1)
  61957. * @param extent x,y,z value that define the extent around the queries point of reference
  61958. */
  61959. setDefaultQueryExtent(extent: Vector3): void;
  61960. /**
  61961. * Get the Bounding box extent specified by setDefaultQueryExtent
  61962. * @returns the box extent values
  61963. */
  61964. getDefaultQueryExtent(): Vector3;
  61965. /**
  61966. * Release all resources
  61967. */
  61968. dispose(): void;
  61969. }
  61970. /**
  61971. * Configures an agent
  61972. */
  61973. export interface IAgentParameters {
  61974. /**
  61975. * Agent radius. [Limit: >= 0]
  61976. */
  61977. radius: number;
  61978. /**
  61979. * Agent height. [Limit: > 0]
  61980. */
  61981. height: number;
  61982. /**
  61983. * Maximum allowed acceleration. [Limit: >= 0]
  61984. */
  61985. maxAcceleration: number;
  61986. /**
  61987. * Maximum allowed speed. [Limit: >= 0]
  61988. */
  61989. maxSpeed: number;
  61990. /**
  61991. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61992. */
  61993. collisionQueryRange: number;
  61994. /**
  61995. * The path visibility optimization range. [Limit: > 0]
  61996. */
  61997. pathOptimizationRange: number;
  61998. /**
  61999. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62000. */
  62001. separationWeight: number;
  62002. }
  62003. /**
  62004. * Configures the navigation mesh creation
  62005. */
  62006. export interface INavMeshParameters {
  62007. /**
  62008. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62009. */
  62010. cs: number;
  62011. /**
  62012. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62013. */
  62014. ch: number;
  62015. /**
  62016. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62017. */
  62018. walkableSlopeAngle: number;
  62019. /**
  62020. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62021. * be considered walkable. [Limit: >= 3] [Units: vx]
  62022. */
  62023. walkableHeight: number;
  62024. /**
  62025. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62026. */
  62027. walkableClimb: number;
  62028. /**
  62029. * The distance to erode/shrink the walkable area of the heightfield away from
  62030. * obstructions. [Limit: >=0] [Units: vx]
  62031. */
  62032. walkableRadius: number;
  62033. /**
  62034. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62035. */
  62036. maxEdgeLen: number;
  62037. /**
  62038. * The maximum distance a simplfied contour's border edges should deviate
  62039. * the original raw contour. [Limit: >=0] [Units: vx]
  62040. */
  62041. maxSimplificationError: number;
  62042. /**
  62043. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62044. */
  62045. minRegionArea: number;
  62046. /**
  62047. * Any regions with a span count smaller than this value will, if possible,
  62048. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62049. */
  62050. mergeRegionArea: number;
  62051. /**
  62052. * The maximum number of vertices allowed for polygons generated during the
  62053. * contour to polygon conversion process. [Limit: >= 3]
  62054. */
  62055. maxVertsPerPoly: number;
  62056. /**
  62057. * Sets the sampling distance to use when generating the detail mesh.
  62058. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62059. */
  62060. detailSampleDist: number;
  62061. /**
  62062. * The maximum distance the detail mesh surface should deviate from heightfield
  62063. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62064. */
  62065. detailSampleMaxError: number;
  62066. }
  62067. }
  62068. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62069. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62070. import { Mesh } from "babylonjs/Meshes/mesh";
  62071. import { Scene } from "babylonjs/scene";
  62072. import { Vector3 } from "babylonjs/Maths/math";
  62073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62074. /**
  62075. * RecastJS navigation plugin
  62076. */
  62077. export class RecastJSPlugin implements INavigationEnginePlugin {
  62078. /**
  62079. * Reference to the Recast library
  62080. */
  62081. bjsRECAST: any;
  62082. /**
  62083. * plugin name
  62084. */
  62085. name: string;
  62086. /**
  62087. * the first navmesh created. We might extend this to support multiple navmeshes
  62088. */
  62089. navMesh: any;
  62090. /**
  62091. * Initializes the recastJS plugin
  62092. * @param recastInjection can be used to inject your own recast reference
  62093. */
  62094. constructor(recastInjection?: any);
  62095. /**
  62096. * Creates a navigation mesh
  62097. * @param meshes array of all the geometry used to compute the navigatio mesh
  62098. * @param parameters bunch of parameters used to filter geometry
  62099. */
  62100. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62101. /**
  62102. * Create a navigation mesh debug mesh
  62103. * @param scene is where the mesh will be added
  62104. * @returns debug display mesh
  62105. */
  62106. createDebugNavMesh(scene: Scene): Mesh;
  62107. /**
  62108. * Get a navigation mesh constrained position, closest to the parameter position
  62109. * @param position world position
  62110. * @returns the closest point to position constrained by the navigation mesh
  62111. */
  62112. getClosestPoint(position: Vector3): Vector3;
  62113. /**
  62114. * Get a navigation mesh constrained position, within a particular radius
  62115. * @param position world position
  62116. * @param maxRadius the maximum distance to the constrained world position
  62117. * @returns the closest point to position constrained by the navigation mesh
  62118. */
  62119. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62120. /**
  62121. * Compute the final position from a segment made of destination-position
  62122. * @param position world position
  62123. * @param destination world position
  62124. * @returns the resulting point along the navmesh
  62125. */
  62126. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62127. /**
  62128. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62129. * @param start world position
  62130. * @param end world position
  62131. * @returns array containing world position composing the path
  62132. */
  62133. computePath(start: Vector3, end: Vector3): Vector3[];
  62134. /**
  62135. * Create a new Crowd so you can add agents
  62136. * @param maxAgents the maximum agent count in the crowd
  62137. * @param maxAgentRadius the maximum radius an agent can have
  62138. * @param scene to attach the crowd to
  62139. * @returns the crowd you can add agents to
  62140. */
  62141. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62142. /**
  62143. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62144. * The queries will try to find a solution within those bounds
  62145. * default is (1,1,1)
  62146. * @param extent x,y,z value that define the extent around the queries point of reference
  62147. */
  62148. setDefaultQueryExtent(extent: Vector3): void;
  62149. /**
  62150. * Get the Bounding box extent specified by setDefaultQueryExtent
  62151. * @returns the box extent values
  62152. */
  62153. getDefaultQueryExtent(): Vector3;
  62154. /**
  62155. * Disposes
  62156. */
  62157. dispose(): void;
  62158. /**
  62159. * If this plugin is supported
  62160. * @returns true if plugin is supported
  62161. */
  62162. isSupported(): boolean;
  62163. }
  62164. /**
  62165. * Recast detour crowd implementation
  62166. */
  62167. export class RecastJSCrowd implements ICrowd {
  62168. /**
  62169. * Recast/detour plugin
  62170. */
  62171. bjsRECASTPlugin: RecastJSPlugin;
  62172. /**
  62173. * Link to the detour crowd
  62174. */
  62175. recastCrowd: any;
  62176. /**
  62177. * One transform per agent
  62178. */
  62179. transforms: TransformNode[];
  62180. /**
  62181. * All agents created
  62182. */
  62183. agents: number[];
  62184. /**
  62185. * Link to the scene is kept to unregister the crowd from the scene
  62186. */
  62187. private _scene;
  62188. /**
  62189. * Observer for crowd updates
  62190. */
  62191. private _onBeforeAnimationsObserver;
  62192. /**
  62193. * Constructor
  62194. * @param plugin recastJS plugin
  62195. * @param maxAgents the maximum agent count in the crowd
  62196. * @param maxAgentRadius the maximum radius an agent can have
  62197. * @param scene to attach the crowd to
  62198. * @returns the crowd you can add agents to
  62199. */
  62200. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62201. /**
  62202. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62203. * You can attach anything to that node. The node position is updated in the scene update tick.
  62204. * @param pos world position that will be constrained by the navigation mesh
  62205. * @param parameters agent parameters
  62206. * @param transform hooked to the agent that will be update by the scene
  62207. * @returns agent index
  62208. */
  62209. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62210. /**
  62211. * Returns the agent position in world space
  62212. * @param index agent index returned by addAgent
  62213. * @returns world space position
  62214. */
  62215. getAgentPosition(index: number): Vector3;
  62216. /**
  62217. * Returns the agent velocity in world space
  62218. * @param index agent index returned by addAgent
  62219. * @returns world space velocity
  62220. */
  62221. getAgentVelocity(index: number): Vector3;
  62222. /**
  62223. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62224. * @param index agent index returned by addAgent
  62225. * @param destination targeted world position
  62226. */
  62227. agentGoto(index: number, destination: Vector3): void;
  62228. /**
  62229. * remove a particular agent previously created
  62230. * @param index agent index returned by addAgent
  62231. */
  62232. removeAgent(index: number): void;
  62233. /**
  62234. * get the list of all agents attached to this crowd
  62235. * @returns list of agent indices
  62236. */
  62237. getAgents(): number[];
  62238. /**
  62239. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62240. * @param deltaTime in seconds
  62241. */
  62242. update(deltaTime: number): void;
  62243. /**
  62244. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62245. * The queries will try to find a solution within those bounds
  62246. * default is (1,1,1)
  62247. * @param extent x,y,z value that define the extent around the queries point of reference
  62248. */
  62249. setDefaultQueryExtent(extent: Vector3): void;
  62250. /**
  62251. * Get the Bounding box extent specified by setDefaultQueryExtent
  62252. * @returns the box extent values
  62253. */
  62254. getDefaultQueryExtent(): Vector3;
  62255. /**
  62256. * Release all resources
  62257. */
  62258. dispose(): void;
  62259. }
  62260. }
  62261. declare module "babylonjs/Navigation/Plugins/index" {
  62262. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62263. }
  62264. declare module "babylonjs/Navigation/index" {
  62265. export * from "babylonjs/Navigation/INavigationEngine";
  62266. export * from "babylonjs/Navigation/Plugins/index";
  62267. }
  62268. declare module "babylonjs/Offline/database" {
  62269. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62270. /**
  62271. * Class used to enable access to IndexedDB
  62272. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62273. */
  62274. export class Database implements IOfflineProvider {
  62275. private _callbackManifestChecked;
  62276. private _currentSceneUrl;
  62277. private _db;
  62278. private _enableSceneOffline;
  62279. private _enableTexturesOffline;
  62280. private _manifestVersionFound;
  62281. private _mustUpdateRessources;
  62282. private _hasReachedQuota;
  62283. private _isSupported;
  62284. private _idbFactory;
  62285. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62286. private static IsUASupportingBlobStorage;
  62287. /**
  62288. * Gets a boolean indicating if Database storate is enabled (off by default)
  62289. */
  62290. static IDBStorageEnabled: boolean;
  62291. /**
  62292. * Gets a boolean indicating if scene must be saved in the database
  62293. */
  62294. readonly enableSceneOffline: boolean;
  62295. /**
  62296. * Gets a boolean indicating if textures must be saved in the database
  62297. */
  62298. readonly enableTexturesOffline: boolean;
  62299. /**
  62300. * Creates a new Database
  62301. * @param urlToScene defines the url to load the scene
  62302. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62303. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62304. */
  62305. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62306. private static _ParseURL;
  62307. private static _ReturnFullUrlLocation;
  62308. private _checkManifestFile;
  62309. /**
  62310. * Open the database and make it available
  62311. * @param successCallback defines the callback to call on success
  62312. * @param errorCallback defines the callback to call on error
  62313. */
  62314. open(successCallback: () => void, errorCallback: () => void): void;
  62315. /**
  62316. * Loads an image from the database
  62317. * @param url defines the url to load from
  62318. * @param image defines the target DOM image
  62319. */
  62320. loadImage(url: string, image: HTMLImageElement): void;
  62321. private _loadImageFromDBAsync;
  62322. private _saveImageIntoDBAsync;
  62323. private _checkVersionFromDB;
  62324. private _loadVersionFromDBAsync;
  62325. private _saveVersionIntoDBAsync;
  62326. /**
  62327. * Loads a file from database
  62328. * @param url defines the URL to load from
  62329. * @param sceneLoaded defines a callback to call on success
  62330. * @param progressCallBack defines a callback to call when progress changed
  62331. * @param errorCallback defines a callback to call on error
  62332. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62333. */
  62334. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62335. private _loadFileAsync;
  62336. private _saveFileAsync;
  62337. /**
  62338. * Validates if xhr data is correct
  62339. * @param xhr defines the request to validate
  62340. * @param dataType defines the expected data type
  62341. * @returns true if data is correct
  62342. */
  62343. private static _ValidateXHRData;
  62344. }
  62345. }
  62346. declare module "babylonjs/Offline/index" {
  62347. export * from "babylonjs/Offline/database";
  62348. export * from "babylonjs/Offline/IOfflineProvider";
  62349. }
  62350. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62351. /** @hidden */
  62352. export var gpuUpdateParticlesPixelShader: {
  62353. name: string;
  62354. shader: string;
  62355. };
  62356. }
  62357. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62358. /** @hidden */
  62359. export var gpuUpdateParticlesVertexShader: {
  62360. name: string;
  62361. shader: string;
  62362. };
  62363. }
  62364. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62365. /** @hidden */
  62366. export var clipPlaneFragmentDeclaration2: {
  62367. name: string;
  62368. shader: string;
  62369. };
  62370. }
  62371. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62372. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62373. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62374. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62375. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62376. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62377. /** @hidden */
  62378. export var gpuRenderParticlesPixelShader: {
  62379. name: string;
  62380. shader: string;
  62381. };
  62382. }
  62383. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62384. /** @hidden */
  62385. export var clipPlaneVertexDeclaration2: {
  62386. name: string;
  62387. shader: string;
  62388. };
  62389. }
  62390. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62391. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62392. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62393. /** @hidden */
  62394. export var gpuRenderParticlesVertexShader: {
  62395. name: string;
  62396. shader: string;
  62397. };
  62398. }
  62399. declare module "babylonjs/Particles/gpuParticleSystem" {
  62400. import { Nullable } from "babylonjs/types";
  62401. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62402. import { Observable } from "babylonjs/Misc/observable";
  62403. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62404. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62405. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62406. import { Scene, IDisposable } from "babylonjs/scene";
  62407. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62409. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62410. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62411. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62412. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62413. /**
  62414. * This represents a GPU particle system in Babylon
  62415. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62416. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62417. */
  62418. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62419. /**
  62420. * The layer mask we are rendering the particles through.
  62421. */
  62422. layerMask: number;
  62423. private _capacity;
  62424. private _activeCount;
  62425. private _currentActiveCount;
  62426. private _accumulatedCount;
  62427. private _renderEffect;
  62428. private _updateEffect;
  62429. private _buffer0;
  62430. private _buffer1;
  62431. private _spriteBuffer;
  62432. private _updateVAO;
  62433. private _renderVAO;
  62434. private _targetIndex;
  62435. private _sourceBuffer;
  62436. private _targetBuffer;
  62437. private _engine;
  62438. private _currentRenderId;
  62439. private _started;
  62440. private _stopped;
  62441. private _timeDelta;
  62442. private _randomTexture;
  62443. private _randomTexture2;
  62444. private _attributesStrideSize;
  62445. private _updateEffectOptions;
  62446. private _randomTextureSize;
  62447. private _actualFrame;
  62448. private readonly _rawTextureWidth;
  62449. /**
  62450. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62451. */
  62452. static readonly IsSupported: boolean;
  62453. /**
  62454. * An event triggered when the system is disposed.
  62455. */
  62456. onDisposeObservable: Observable<GPUParticleSystem>;
  62457. /**
  62458. * Gets the maximum number of particles active at the same time.
  62459. * @returns The max number of active particles.
  62460. */
  62461. getCapacity(): number;
  62462. /**
  62463. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62464. * to override the particles.
  62465. */
  62466. forceDepthWrite: boolean;
  62467. /**
  62468. * Gets or set the number of active particles
  62469. */
  62470. activeParticleCount: number;
  62471. private _preWarmDone;
  62472. /**
  62473. * Is this system ready to be used/rendered
  62474. * @return true if the system is ready
  62475. */
  62476. isReady(): boolean;
  62477. /**
  62478. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62479. * @returns True if it has been started, otherwise false.
  62480. */
  62481. isStarted(): boolean;
  62482. /**
  62483. * Starts the particle system and begins to emit
  62484. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62485. */
  62486. start(delay?: number): void;
  62487. /**
  62488. * Stops the particle system.
  62489. */
  62490. stop(): void;
  62491. /**
  62492. * Remove all active particles
  62493. */
  62494. reset(): void;
  62495. /**
  62496. * Returns the string "GPUParticleSystem"
  62497. * @returns a string containing the class name
  62498. */
  62499. getClassName(): string;
  62500. private _colorGradientsTexture;
  62501. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62502. /**
  62503. * Adds a new color gradient
  62504. * @param gradient defines the gradient to use (between 0 and 1)
  62505. * @param color1 defines the color to affect to the specified gradient
  62506. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62507. * @returns the current particle system
  62508. */
  62509. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62510. /**
  62511. * Remove a specific color gradient
  62512. * @param gradient defines the gradient to remove
  62513. * @returns the current particle system
  62514. */
  62515. removeColorGradient(gradient: number): GPUParticleSystem;
  62516. private _angularSpeedGradientsTexture;
  62517. private _sizeGradientsTexture;
  62518. private _velocityGradientsTexture;
  62519. private _limitVelocityGradientsTexture;
  62520. private _dragGradientsTexture;
  62521. private _addFactorGradient;
  62522. /**
  62523. * Adds a new size gradient
  62524. * @param gradient defines the gradient to use (between 0 and 1)
  62525. * @param factor defines the size factor to affect to the specified gradient
  62526. * @returns the current particle system
  62527. */
  62528. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62529. /**
  62530. * Remove a specific size gradient
  62531. * @param gradient defines the gradient to remove
  62532. * @returns the current particle system
  62533. */
  62534. removeSizeGradient(gradient: number): GPUParticleSystem;
  62535. /**
  62536. * Adds a new angular speed gradient
  62537. * @param gradient defines the gradient to use (between 0 and 1)
  62538. * @param factor defines the angular speed to affect to the specified gradient
  62539. * @returns the current particle system
  62540. */
  62541. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62542. /**
  62543. * Remove a specific angular speed gradient
  62544. * @param gradient defines the gradient to remove
  62545. * @returns the current particle system
  62546. */
  62547. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62548. /**
  62549. * Adds a new velocity gradient
  62550. * @param gradient defines the gradient to use (between 0 and 1)
  62551. * @param factor defines the velocity to affect to the specified gradient
  62552. * @returns the current particle system
  62553. */
  62554. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62555. /**
  62556. * Remove a specific velocity gradient
  62557. * @param gradient defines the gradient to remove
  62558. * @returns the current particle system
  62559. */
  62560. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62561. /**
  62562. * Adds a new limit velocity gradient
  62563. * @param gradient defines the gradient to use (between 0 and 1)
  62564. * @param factor defines the limit velocity value to affect to the specified gradient
  62565. * @returns the current particle system
  62566. */
  62567. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62568. /**
  62569. * Remove a specific limit velocity gradient
  62570. * @param gradient defines the gradient to remove
  62571. * @returns the current particle system
  62572. */
  62573. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62574. /**
  62575. * Adds a new drag gradient
  62576. * @param gradient defines the gradient to use (between 0 and 1)
  62577. * @param factor defines the drag value to affect to the specified gradient
  62578. * @returns the current particle system
  62579. */
  62580. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62581. /**
  62582. * Remove a specific drag gradient
  62583. * @param gradient defines the gradient to remove
  62584. * @returns the current particle system
  62585. */
  62586. removeDragGradient(gradient: number): GPUParticleSystem;
  62587. /**
  62588. * Not supported by GPUParticleSystem
  62589. * @param gradient defines the gradient to use (between 0 and 1)
  62590. * @param factor defines the emit rate value to affect to the specified gradient
  62591. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62592. * @returns the current particle system
  62593. */
  62594. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62595. /**
  62596. * Not supported by GPUParticleSystem
  62597. * @param gradient defines the gradient to remove
  62598. * @returns the current particle system
  62599. */
  62600. removeEmitRateGradient(gradient: number): IParticleSystem;
  62601. /**
  62602. * Not supported by GPUParticleSystem
  62603. * @param gradient defines the gradient to use (between 0 and 1)
  62604. * @param factor defines the start size value to affect to the specified gradient
  62605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62606. * @returns the current particle system
  62607. */
  62608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62609. /**
  62610. * Not supported by GPUParticleSystem
  62611. * @param gradient defines the gradient to remove
  62612. * @returns the current particle system
  62613. */
  62614. removeStartSizeGradient(gradient: number): IParticleSystem;
  62615. /**
  62616. * Not supported by GPUParticleSystem
  62617. * @param gradient defines the gradient to use (between 0 and 1)
  62618. * @param min defines the color remap minimal range
  62619. * @param max defines the color remap maximal range
  62620. * @returns the current particle system
  62621. */
  62622. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62623. /**
  62624. * Not supported by GPUParticleSystem
  62625. * @param gradient defines the gradient to remove
  62626. * @returns the current particle system
  62627. */
  62628. removeColorRemapGradient(): IParticleSystem;
  62629. /**
  62630. * Not supported by GPUParticleSystem
  62631. * @param gradient defines the gradient to use (between 0 and 1)
  62632. * @param min defines the alpha remap minimal range
  62633. * @param max defines the alpha remap maximal range
  62634. * @returns the current particle system
  62635. */
  62636. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62637. /**
  62638. * Not supported by GPUParticleSystem
  62639. * @param gradient defines the gradient to remove
  62640. * @returns the current particle system
  62641. */
  62642. removeAlphaRemapGradient(): IParticleSystem;
  62643. /**
  62644. * Not supported by GPUParticleSystem
  62645. * @param gradient defines the gradient to use (between 0 and 1)
  62646. * @param color defines the color to affect to the specified gradient
  62647. * @returns the current particle system
  62648. */
  62649. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62650. /**
  62651. * Not supported by GPUParticleSystem
  62652. * @param gradient defines the gradient to remove
  62653. * @returns the current particle system
  62654. */
  62655. removeRampGradient(): IParticleSystem;
  62656. /**
  62657. * Not supported by GPUParticleSystem
  62658. * @returns the list of ramp gradients
  62659. */
  62660. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62661. /**
  62662. * Not supported by GPUParticleSystem
  62663. * Gets or sets a boolean indicating that ramp gradients must be used
  62664. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62665. */
  62666. useRampGradients: boolean;
  62667. /**
  62668. * Not supported by GPUParticleSystem
  62669. * @param gradient defines the gradient to use (between 0 and 1)
  62670. * @param factor defines the life time factor to affect to the specified gradient
  62671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62672. * @returns the current particle system
  62673. */
  62674. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62675. /**
  62676. * Not supported by GPUParticleSystem
  62677. * @param gradient defines the gradient to remove
  62678. * @returns the current particle system
  62679. */
  62680. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62681. /**
  62682. * Instantiates a GPU particle system.
  62683. * 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.
  62684. * @param name The name of the particle system
  62685. * @param options The options used to create the system
  62686. * @param scene The scene the particle system belongs to
  62687. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62688. */
  62689. constructor(name: string, options: Partial<{
  62690. capacity: number;
  62691. randomTextureSize: number;
  62692. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62693. protected _reset(): void;
  62694. private _createUpdateVAO;
  62695. private _createRenderVAO;
  62696. private _initialize;
  62697. /** @hidden */
  62698. _recreateUpdateEffect(): void;
  62699. /** @hidden */
  62700. _recreateRenderEffect(): void;
  62701. /**
  62702. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62703. * @param preWarm defines if we are in the pre-warmimg phase
  62704. */
  62705. animate(preWarm?: boolean): void;
  62706. private _createFactorGradientTexture;
  62707. private _createSizeGradientTexture;
  62708. private _createAngularSpeedGradientTexture;
  62709. private _createVelocityGradientTexture;
  62710. private _createLimitVelocityGradientTexture;
  62711. private _createDragGradientTexture;
  62712. private _createColorGradientTexture;
  62713. /**
  62714. * Renders the particle system in its current state
  62715. * @param preWarm defines if the system should only update the particles but not render them
  62716. * @returns the current number of particles
  62717. */
  62718. render(preWarm?: boolean): number;
  62719. /**
  62720. * Rebuilds the particle system
  62721. */
  62722. rebuild(): void;
  62723. private _releaseBuffers;
  62724. private _releaseVAOs;
  62725. /**
  62726. * Disposes the particle system and free the associated resources
  62727. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62728. */
  62729. dispose(disposeTexture?: boolean): void;
  62730. /**
  62731. * Clones the particle system.
  62732. * @param name The name of the cloned object
  62733. * @param newEmitter The new emitter to use
  62734. * @returns the cloned particle system
  62735. */
  62736. clone(name: string, newEmitter: any): GPUParticleSystem;
  62737. /**
  62738. * Serializes the particle system to a JSON object.
  62739. * @returns the JSON object
  62740. */
  62741. serialize(): any;
  62742. /**
  62743. * Parses a JSON object to create a GPU particle system.
  62744. * @param parsedParticleSystem The JSON object to parse
  62745. * @param scene The scene to create the particle system in
  62746. * @param rootUrl The root url to use to load external dependencies like texture
  62747. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62748. * @returns the parsed GPU particle system
  62749. */
  62750. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62751. }
  62752. }
  62753. declare module "babylonjs/Particles/particleSystemSet" {
  62754. import { Nullable } from "babylonjs/types";
  62755. import { Color3 } from "babylonjs/Maths/math.color";
  62756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62758. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62759. import { Scene, IDisposable } from "babylonjs/scene";
  62760. /**
  62761. * Represents a set of particle systems working together to create a specific effect
  62762. */
  62763. export class ParticleSystemSet implements IDisposable {
  62764. /**
  62765. * Gets or sets base Assets URL
  62766. */
  62767. static BaseAssetsUrl: string;
  62768. private _emitterCreationOptions;
  62769. private _emitterNode;
  62770. /**
  62771. * Gets the particle system list
  62772. */
  62773. systems: IParticleSystem[];
  62774. /**
  62775. * Gets the emitter node used with this set
  62776. */
  62777. readonly emitterNode: Nullable<TransformNode>;
  62778. /**
  62779. * Creates a new emitter mesh as a sphere
  62780. * @param options defines the options used to create the sphere
  62781. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62782. * @param scene defines the hosting scene
  62783. */
  62784. setEmitterAsSphere(options: {
  62785. diameter: number;
  62786. segments: number;
  62787. color: Color3;
  62788. }, renderingGroupId: number, scene: Scene): void;
  62789. /**
  62790. * Starts all particle systems of the set
  62791. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62792. */
  62793. start(emitter?: AbstractMesh): void;
  62794. /**
  62795. * Release all associated resources
  62796. */
  62797. dispose(): void;
  62798. /**
  62799. * Serialize the set into a JSON compatible object
  62800. * @returns a JSON compatible representation of the set
  62801. */
  62802. serialize(): any;
  62803. /**
  62804. * Parse a new ParticleSystemSet from a serialized source
  62805. * @param data defines a JSON compatible representation of the set
  62806. * @param scene defines the hosting scene
  62807. * @param gpu defines if we want GPU particles or CPU particles
  62808. * @returns a new ParticleSystemSet
  62809. */
  62810. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62811. }
  62812. }
  62813. declare module "babylonjs/Particles/particleHelper" {
  62814. import { Nullable } from "babylonjs/types";
  62815. import { Scene } from "babylonjs/scene";
  62816. import { Vector3 } from "babylonjs/Maths/math.vector";
  62817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62818. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62819. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62820. /**
  62821. * This class is made for on one-liner static method to help creating particle system set.
  62822. */
  62823. export class ParticleHelper {
  62824. /**
  62825. * Gets or sets base Assets URL
  62826. */
  62827. static BaseAssetsUrl: string;
  62828. /**
  62829. * Create a default particle system that you can tweak
  62830. * @param emitter defines the emitter to use
  62831. * @param capacity defines the system capacity (default is 500 particles)
  62832. * @param scene defines the hosting scene
  62833. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62834. * @returns the new Particle system
  62835. */
  62836. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62837. /**
  62838. * This is the main static method (one-liner) of this helper to create different particle systems
  62839. * @param type This string represents the type to the particle system to create
  62840. * @param scene The scene where the particle system should live
  62841. * @param gpu If the system will use gpu
  62842. * @returns the ParticleSystemSet created
  62843. */
  62844. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62845. /**
  62846. * Static function used to export a particle system to a ParticleSystemSet variable.
  62847. * Please note that the emitter shape is not exported
  62848. * @param systems defines the particle systems to export
  62849. * @returns the created particle system set
  62850. */
  62851. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62852. }
  62853. }
  62854. declare module "babylonjs/Particles/particleSystemComponent" {
  62855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62856. import { Effect } from "babylonjs/Materials/effect";
  62857. import "babylonjs/Shaders/particles.vertex";
  62858. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62859. module "babylonjs/Engines/engine" {
  62860. interface Engine {
  62861. /**
  62862. * Create an effect to use with particle systems.
  62863. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62864. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62865. * @param uniformsNames defines a list of attribute names
  62866. * @param samplers defines an array of string used to represent textures
  62867. * @param defines defines the string containing the defines to use to compile the shaders
  62868. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62869. * @param onCompiled defines a function to call when the effect creation is successful
  62870. * @param onError defines a function to call when the effect creation has failed
  62871. * @returns the new Effect
  62872. */
  62873. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62874. }
  62875. }
  62876. module "babylonjs/Meshes/mesh" {
  62877. interface Mesh {
  62878. /**
  62879. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62880. * @returns an array of IParticleSystem
  62881. */
  62882. getEmittedParticleSystems(): IParticleSystem[];
  62883. /**
  62884. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62885. * @returns an array of IParticleSystem
  62886. */
  62887. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62888. }
  62889. }
  62890. /**
  62891. * @hidden
  62892. */
  62893. export var _IDoNeedToBeInTheBuild: number;
  62894. }
  62895. declare module "babylonjs/Particles/pointsCloudSystem" {
  62896. import { Color4 } from "babylonjs/Maths/math";
  62897. import { Mesh } from "babylonjs/Meshes/mesh";
  62898. import { Scene, IDisposable } from "babylonjs/scene";
  62899. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62900. /** Defines the 4 color options */
  62901. export enum PointColor {
  62902. /** color value */
  62903. Color = 2,
  62904. /** uv value */
  62905. UV = 1,
  62906. /** random value */
  62907. Random = 0,
  62908. /** stated value */
  62909. Stated = 3
  62910. }
  62911. /**
  62912. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62913. * 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.
  62914. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62915. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62916. *
  62917. * Full documentation here : TO BE ENTERED
  62918. */
  62919. export class PointsCloudSystem implements IDisposable {
  62920. /**
  62921. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62922. * Example : var p = SPS.particles[i];
  62923. */
  62924. particles: CloudPoint[];
  62925. /**
  62926. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62927. */
  62928. nbParticles: number;
  62929. /**
  62930. * This a counter for your own usage. It's not set by any SPS functions.
  62931. */
  62932. counter: number;
  62933. /**
  62934. * The PCS name. This name is also given to the underlying mesh.
  62935. */
  62936. name: string;
  62937. /**
  62938. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62939. */
  62940. mesh: Mesh;
  62941. /**
  62942. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62943. * Please read :
  62944. */
  62945. vars: any;
  62946. /**
  62947. * @hidden
  62948. */
  62949. _size: number;
  62950. private _scene;
  62951. private _promises;
  62952. private _positions;
  62953. private _indices;
  62954. private _normals;
  62955. private _colors;
  62956. private _uvs;
  62957. private _indices32;
  62958. private _positions32;
  62959. private _colors32;
  62960. private _uvs32;
  62961. private _updatable;
  62962. private _isVisibilityBoxLocked;
  62963. private _alwaysVisible;
  62964. private _groups;
  62965. private _groupCounter;
  62966. private _computeParticleColor;
  62967. private _computeParticleTexture;
  62968. private _computeParticleRotation;
  62969. private _computeBoundingBox;
  62970. private _isReady;
  62971. /**
  62972. * Creates a PCS (Points Cloud System) object
  62973. * @param name (String) is the PCS name, this will be the underlying mesh name
  62974. * @param pointSize (number) is the size for each point
  62975. * @param scene (Scene) is the scene in which the PCS is added
  62976. * @param options defines the options of the PCS e.g.
  62977. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62978. */
  62979. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62980. updatable?: boolean;
  62981. });
  62982. /**
  62983. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62984. * If no points were added to the PCS, the returned mesh is just a single point.
  62985. * @returns a promise for the created mesh
  62986. */
  62987. buildMeshAsync(): Promise<Mesh>;
  62988. /**
  62989. * @hidden
  62990. */
  62991. private _buildMesh;
  62992. private _addParticle;
  62993. private _randomUnitVector;
  62994. private _getColorIndicesForCoord;
  62995. private _setPointsColorOrUV;
  62996. private _colorFromTexture;
  62997. private _calculateDensity;
  62998. /**
  62999. * Adds points to the PCS in random positions within a unit sphere
  63000. * @param nb (positive integer) the number of particles to be created from this model
  63001. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63002. * @returns the number of groups in the system
  63003. */
  63004. addPoints(nb: number, pointFunction?: any): number;
  63005. /**
  63006. * Adds points to the PCS from the surface of the model shape
  63007. * @param mesh is any Mesh object that will be used as a surface model for the points
  63008. * @param nb (positive integer) the number of particles to be created from this model
  63009. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63010. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63011. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63012. * @returns the number of groups in the system
  63013. */
  63014. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63015. /**
  63016. * Adds points to the PCS inside the model shape
  63017. * @param mesh is any Mesh object that will be used as a surface model for the points
  63018. * @param nb (positive integer) the number of particles to be created from this model
  63019. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63020. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63021. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63022. * @returns the number of groups in the system
  63023. */
  63024. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63025. /**
  63026. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63027. * This method calls `updateParticle()` for each particle of the SPS.
  63028. * For an animated SPS, it is usually called within the render loop.
  63029. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63030. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63031. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63032. * @returns the PCS.
  63033. */
  63034. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63035. /**
  63036. * Disposes the PCS.
  63037. */
  63038. dispose(): void;
  63039. /**
  63040. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63041. * doc :
  63042. * @returns the PCS.
  63043. */
  63044. refreshVisibleSize(): PointsCloudSystem;
  63045. /**
  63046. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63047. * @param size the size (float) of the visibility box
  63048. * note : this doesn't lock the PCS mesh bounding box.
  63049. * doc :
  63050. */
  63051. setVisibilityBox(size: number): void;
  63052. /**
  63053. * Gets whether the PCS is always visible or not
  63054. * doc :
  63055. */
  63056. /**
  63057. * Sets the PCS as always visible or not
  63058. * doc :
  63059. */
  63060. isAlwaysVisible: boolean;
  63061. /**
  63062. * Tells to `setParticles()` to compute the particle rotations or not
  63063. * Default value : false. The PCS is faster when it's set to false
  63064. * Note : particle rotations are only applied to parent particles
  63065. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63066. */
  63067. computeParticleRotation: boolean;
  63068. /**
  63069. * Tells to `setParticles()` to compute the particle colors or not.
  63070. * Default value : true. The PCS is faster when it's set to false.
  63071. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63072. */
  63073. /**
  63074. * Gets if `setParticles()` computes the particle colors or not.
  63075. * Default value : false. The PCS is faster when it's set to false.
  63076. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63077. */
  63078. computeParticleColor: boolean;
  63079. /**
  63080. * Gets if `setParticles()` computes the particle textures or not.
  63081. * Default value : false. The PCS is faster when it's set to false.
  63082. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63083. */
  63084. computeParticleTexture: boolean;
  63085. /**
  63086. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63087. */
  63088. /**
  63089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63090. */
  63091. computeBoundingBox: boolean;
  63092. /**
  63093. * This function does nothing. It may be overwritten to set all the particle first values.
  63094. * The PCS doesn't call this function, you may have to call it by your own.
  63095. * doc :
  63096. */
  63097. initParticles(): void;
  63098. /**
  63099. * This function does nothing. It may be overwritten to recycle a particle
  63100. * The PCS doesn't call this function, you can to call it
  63101. * doc :
  63102. * @param particle The particle to recycle
  63103. * @returns the recycled particle
  63104. */
  63105. recycleParticle(particle: CloudPoint): CloudPoint;
  63106. /**
  63107. * Updates a particle : this function should be overwritten by the user.
  63108. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63109. * doc :
  63110. * @example : just set a particle position or velocity and recycle conditions
  63111. * @param particle The particle to update
  63112. * @returns the updated particle
  63113. */
  63114. updateParticle(particle: CloudPoint): CloudPoint;
  63115. /**
  63116. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63117. * This does nothing and may be overwritten by the user.
  63118. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63119. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63120. * @param update the boolean update value actually passed to setParticles()
  63121. */
  63122. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63123. /**
  63124. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63125. * This will be passed three parameters.
  63126. * This does nothing and may be overwritten by the user.
  63127. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63128. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63129. * @param update the boolean update value actually passed to setParticles()
  63130. */
  63131. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63132. }
  63133. }
  63134. declare module "babylonjs/Particles/cloudPoint" {
  63135. import { Nullable } from "babylonjs/types";
  63136. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63137. import { Mesh } from "babylonjs/Meshes/mesh";
  63138. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63139. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63140. /**
  63141. * Represents one particle of a points cloud system.
  63142. */
  63143. export class CloudPoint {
  63144. /**
  63145. * particle global index
  63146. */
  63147. idx: number;
  63148. /**
  63149. * The color of the particle
  63150. */
  63151. color: Nullable<Color4>;
  63152. /**
  63153. * The world space position of the particle.
  63154. */
  63155. position: Vector3;
  63156. /**
  63157. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63158. */
  63159. rotation: Vector3;
  63160. /**
  63161. * The world space rotation quaternion of the particle.
  63162. */
  63163. rotationQuaternion: Nullable<Quaternion>;
  63164. /**
  63165. * The uv of the particle.
  63166. */
  63167. uv: Nullable<Vector2>;
  63168. /**
  63169. * The current speed of the particle.
  63170. */
  63171. velocity: Vector3;
  63172. /**
  63173. * The pivot point in the particle local space.
  63174. */
  63175. pivot: Vector3;
  63176. /**
  63177. * Must the particle be translated from its pivot point in its local space ?
  63178. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63179. * Default : false
  63180. */
  63181. translateFromPivot: boolean;
  63182. /**
  63183. * Index of this particle in the global "positions" array (Internal use)
  63184. * @hidden
  63185. */
  63186. _pos: number;
  63187. /**
  63188. * @hidden Index of this particle in the global "indices" array (Internal use)
  63189. */
  63190. _ind: number;
  63191. /**
  63192. * Group this particle belongs to
  63193. */
  63194. _group: PointsGroup;
  63195. /**
  63196. * Group id of this particle
  63197. */
  63198. groupId: number;
  63199. /**
  63200. * Index of the particle in its group id (Internal use)
  63201. */
  63202. idxInGroup: number;
  63203. /**
  63204. * @hidden Particle BoundingInfo object (Internal use)
  63205. */
  63206. _boundingInfo: BoundingInfo;
  63207. /**
  63208. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63209. */
  63210. _pcs: PointsCloudSystem;
  63211. /**
  63212. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63213. */
  63214. _stillInvisible: boolean;
  63215. /**
  63216. * @hidden Last computed particle rotation matrix
  63217. */
  63218. _rotationMatrix: number[];
  63219. /**
  63220. * Parent particle Id, if any.
  63221. * Default null.
  63222. */
  63223. parentId: Nullable<number>;
  63224. /**
  63225. * @hidden Internal global position in the PCS.
  63226. */
  63227. _globalPosition: Vector3;
  63228. /**
  63229. * Creates a Point Cloud object.
  63230. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63231. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63232. * @param group (PointsGroup) is the group the particle belongs to
  63233. * @param groupId (integer) is the group identifier in the PCS.
  63234. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63235. * @param pcs defines the PCS it is associated to
  63236. */
  63237. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63238. /**
  63239. * get point size
  63240. */
  63241. /**
  63242. * Set point size
  63243. */
  63244. size: Vector3;
  63245. /**
  63246. * Legacy support, changed quaternion to rotationQuaternion
  63247. */
  63248. /**
  63249. * Legacy support, changed quaternion to rotationQuaternion
  63250. */
  63251. quaternion: Nullable<Quaternion>;
  63252. /**
  63253. * Returns a boolean. True if the particle intersects a mesh, else false
  63254. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63255. * @param target is the object (point or mesh) what the intersection is computed against
  63256. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63257. * @returns true if it intersects
  63258. */
  63259. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63260. /**
  63261. * get the rotation matrix of the particle
  63262. * @hidden
  63263. */
  63264. getRotationMatrix(m: Matrix): void;
  63265. }
  63266. /**
  63267. * Represents a group of points in a points cloud system
  63268. * * PCS internal tool, don't use it manually.
  63269. */
  63270. export class PointsGroup {
  63271. /**
  63272. * The group id
  63273. * @hidden
  63274. */
  63275. groupID: number;
  63276. /**
  63277. * image data for group (internal use)
  63278. * @hidden
  63279. */
  63280. _groupImageData: Nullable<ArrayBufferView>;
  63281. /**
  63282. * Image Width (internal use)
  63283. * @hidden
  63284. */
  63285. _groupImgWidth: number;
  63286. /**
  63287. * Image Height (internal use)
  63288. * @hidden
  63289. */
  63290. _groupImgHeight: number;
  63291. /**
  63292. * Custom position function (internal use)
  63293. * @hidden
  63294. */
  63295. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63296. /**
  63297. * density per facet for surface points
  63298. * @hidden
  63299. */
  63300. _groupDensity: number[];
  63301. /**
  63302. * Only when points are colored by texture carries pointer to texture list array
  63303. * @hidden
  63304. */
  63305. _textureNb: number;
  63306. /**
  63307. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63308. * PCS internal tool, don't use it manually.
  63309. * @hidden
  63310. */
  63311. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63312. }
  63313. }
  63314. declare module "babylonjs/Particles/index" {
  63315. export * from "babylonjs/Particles/baseParticleSystem";
  63316. export * from "babylonjs/Particles/EmitterTypes/index";
  63317. export * from "babylonjs/Particles/gpuParticleSystem";
  63318. export * from "babylonjs/Particles/IParticleSystem";
  63319. export * from "babylonjs/Particles/particle";
  63320. export * from "babylonjs/Particles/particleHelper";
  63321. export * from "babylonjs/Particles/particleSystem";
  63322. export * from "babylonjs/Particles/particleSystemComponent";
  63323. export * from "babylonjs/Particles/particleSystemSet";
  63324. export * from "babylonjs/Particles/solidParticle";
  63325. export * from "babylonjs/Particles/solidParticleSystem";
  63326. export * from "babylonjs/Particles/cloudPoint";
  63327. export * from "babylonjs/Particles/pointsCloudSystem";
  63328. export * from "babylonjs/Particles/subEmitter";
  63329. }
  63330. declare module "babylonjs/Physics/physicsEngineComponent" {
  63331. import { Nullable } from "babylonjs/types";
  63332. import { Observable, Observer } from "babylonjs/Misc/observable";
  63333. import { Vector3 } from "babylonjs/Maths/math.vector";
  63334. import { Mesh } from "babylonjs/Meshes/mesh";
  63335. import { ISceneComponent } from "babylonjs/sceneComponent";
  63336. import { Scene } from "babylonjs/scene";
  63337. import { Node } from "babylonjs/node";
  63338. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63339. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63340. module "babylonjs/scene" {
  63341. interface Scene {
  63342. /** @hidden (Backing field) */
  63343. _physicsEngine: Nullable<IPhysicsEngine>;
  63344. /** @hidden */
  63345. _physicsTimeAccumulator: number;
  63346. /**
  63347. * Gets the current physics engine
  63348. * @returns a IPhysicsEngine or null if none attached
  63349. */
  63350. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63351. /**
  63352. * Enables physics to the current scene
  63353. * @param gravity defines the scene's gravity for the physics engine
  63354. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63355. * @return a boolean indicating if the physics engine was initialized
  63356. */
  63357. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63358. /**
  63359. * Disables and disposes the physics engine associated with the scene
  63360. */
  63361. disablePhysicsEngine(): void;
  63362. /**
  63363. * Gets a boolean indicating if there is an active physics engine
  63364. * @returns a boolean indicating if there is an active physics engine
  63365. */
  63366. isPhysicsEnabled(): boolean;
  63367. /**
  63368. * Deletes a physics compound impostor
  63369. * @param compound defines the compound to delete
  63370. */
  63371. deleteCompoundImpostor(compound: any): void;
  63372. /**
  63373. * An event triggered when physic simulation is about to be run
  63374. */
  63375. onBeforePhysicsObservable: Observable<Scene>;
  63376. /**
  63377. * An event triggered when physic simulation has been done
  63378. */
  63379. onAfterPhysicsObservable: Observable<Scene>;
  63380. }
  63381. }
  63382. module "babylonjs/Meshes/abstractMesh" {
  63383. interface AbstractMesh {
  63384. /** @hidden */
  63385. _physicsImpostor: Nullable<PhysicsImpostor>;
  63386. /**
  63387. * Gets or sets impostor used for physic simulation
  63388. * @see http://doc.babylonjs.com/features/physics_engine
  63389. */
  63390. physicsImpostor: Nullable<PhysicsImpostor>;
  63391. /**
  63392. * Gets the current physics impostor
  63393. * @see http://doc.babylonjs.com/features/physics_engine
  63394. * @returns a physics impostor or null
  63395. */
  63396. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63397. /** Apply a physic impulse to the mesh
  63398. * @param force defines the force to apply
  63399. * @param contactPoint defines where to apply the force
  63400. * @returns the current mesh
  63401. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63402. */
  63403. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63404. /**
  63405. * Creates a physic joint between two meshes
  63406. * @param otherMesh defines the other mesh to use
  63407. * @param pivot1 defines the pivot to use on this mesh
  63408. * @param pivot2 defines the pivot to use on the other mesh
  63409. * @param options defines additional options (can be plugin dependent)
  63410. * @returns the current mesh
  63411. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63412. */
  63413. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63414. /** @hidden */
  63415. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63416. }
  63417. }
  63418. /**
  63419. * Defines the physics engine scene component responsible to manage a physics engine
  63420. */
  63421. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63422. /**
  63423. * The component name helpful to identify the component in the list of scene components.
  63424. */
  63425. readonly name: string;
  63426. /**
  63427. * The scene the component belongs to.
  63428. */
  63429. scene: Scene;
  63430. /**
  63431. * Creates a new instance of the component for the given scene
  63432. * @param scene Defines the scene to register the component in
  63433. */
  63434. constructor(scene: Scene);
  63435. /**
  63436. * Registers the component in a given scene
  63437. */
  63438. register(): void;
  63439. /**
  63440. * Rebuilds the elements related to this component in case of
  63441. * context lost for instance.
  63442. */
  63443. rebuild(): void;
  63444. /**
  63445. * Disposes the component and the associated ressources
  63446. */
  63447. dispose(): void;
  63448. }
  63449. }
  63450. declare module "babylonjs/Physics/physicsHelper" {
  63451. import { Nullable } from "babylonjs/types";
  63452. import { Vector3 } from "babylonjs/Maths/math.vector";
  63453. import { Mesh } from "babylonjs/Meshes/mesh";
  63454. import { Scene } from "babylonjs/scene";
  63455. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63456. /**
  63457. * A helper for physics simulations
  63458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63459. */
  63460. export class PhysicsHelper {
  63461. private _scene;
  63462. private _physicsEngine;
  63463. /**
  63464. * Initializes the Physics helper
  63465. * @param scene Babylon.js scene
  63466. */
  63467. constructor(scene: Scene);
  63468. /**
  63469. * Applies a radial explosion impulse
  63470. * @param origin the origin of the explosion
  63471. * @param radiusOrEventOptions the radius or the options of radial explosion
  63472. * @param strength the explosion strength
  63473. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63474. * @returns A physics radial explosion event, or null
  63475. */
  63476. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63477. /**
  63478. * Applies a radial explosion force
  63479. * @param origin the origin of the explosion
  63480. * @param radiusOrEventOptions the radius or the options of radial explosion
  63481. * @param strength the explosion strength
  63482. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63483. * @returns A physics radial explosion event, or null
  63484. */
  63485. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63486. /**
  63487. * Creates a gravitational field
  63488. * @param origin the origin of the explosion
  63489. * @param radiusOrEventOptions the radius or the options of radial explosion
  63490. * @param strength the explosion strength
  63491. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63492. * @returns A physics gravitational field event, or null
  63493. */
  63494. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63495. /**
  63496. * Creates a physics updraft event
  63497. * @param origin the origin of the updraft
  63498. * @param radiusOrEventOptions the radius or the options of the updraft
  63499. * @param strength the strength of the updraft
  63500. * @param height the height of the updraft
  63501. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63502. * @returns A physics updraft event, or null
  63503. */
  63504. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63505. /**
  63506. * Creates a physics vortex event
  63507. * @param origin the of the vortex
  63508. * @param radiusOrEventOptions the radius or the options of the vortex
  63509. * @param strength the strength of the vortex
  63510. * @param height the height of the vortex
  63511. * @returns a Physics vortex event, or null
  63512. * A physics vortex event or null
  63513. */
  63514. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63515. }
  63516. /**
  63517. * Represents a physics radial explosion event
  63518. */
  63519. class PhysicsRadialExplosionEvent {
  63520. private _scene;
  63521. private _options;
  63522. private _sphere;
  63523. private _dataFetched;
  63524. /**
  63525. * Initializes a radial explosioin event
  63526. * @param _scene BabylonJS scene
  63527. * @param _options The options for the vortex event
  63528. */
  63529. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63530. /**
  63531. * Returns the data related to the radial explosion event (sphere).
  63532. * @returns The radial explosion event data
  63533. */
  63534. getData(): PhysicsRadialExplosionEventData;
  63535. /**
  63536. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63537. * @param impostor A physics imposter
  63538. * @param origin the origin of the explosion
  63539. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63540. */
  63541. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63542. /**
  63543. * Triggers affecterd impostors callbacks
  63544. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63545. */
  63546. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63547. /**
  63548. * Disposes the sphere.
  63549. * @param force Specifies if the sphere should be disposed by force
  63550. */
  63551. dispose(force?: boolean): void;
  63552. /*** Helpers ***/
  63553. private _prepareSphere;
  63554. private _intersectsWithSphere;
  63555. }
  63556. /**
  63557. * Represents a gravitational field event
  63558. */
  63559. class PhysicsGravitationalFieldEvent {
  63560. private _physicsHelper;
  63561. private _scene;
  63562. private _origin;
  63563. private _options;
  63564. private _tickCallback;
  63565. private _sphere;
  63566. private _dataFetched;
  63567. /**
  63568. * Initializes the physics gravitational field event
  63569. * @param _physicsHelper A physics helper
  63570. * @param _scene BabylonJS scene
  63571. * @param _origin The origin position of the gravitational field event
  63572. * @param _options The options for the vortex event
  63573. */
  63574. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63575. /**
  63576. * Returns the data related to the gravitational field event (sphere).
  63577. * @returns A gravitational field event
  63578. */
  63579. getData(): PhysicsGravitationalFieldEventData;
  63580. /**
  63581. * Enables the gravitational field.
  63582. */
  63583. enable(): void;
  63584. /**
  63585. * Disables the gravitational field.
  63586. */
  63587. disable(): void;
  63588. /**
  63589. * Disposes the sphere.
  63590. * @param force The force to dispose from the gravitational field event
  63591. */
  63592. dispose(force?: boolean): void;
  63593. private _tick;
  63594. }
  63595. /**
  63596. * Represents a physics updraft event
  63597. */
  63598. class PhysicsUpdraftEvent {
  63599. private _scene;
  63600. private _origin;
  63601. private _options;
  63602. private _physicsEngine;
  63603. private _originTop;
  63604. private _originDirection;
  63605. private _tickCallback;
  63606. private _cylinder;
  63607. private _cylinderPosition;
  63608. private _dataFetched;
  63609. /**
  63610. * Initializes the physics updraft event
  63611. * @param _scene BabylonJS scene
  63612. * @param _origin The origin position of the updraft
  63613. * @param _options The options for the updraft event
  63614. */
  63615. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63616. /**
  63617. * Returns the data related to the updraft event (cylinder).
  63618. * @returns A physics updraft event
  63619. */
  63620. getData(): PhysicsUpdraftEventData;
  63621. /**
  63622. * Enables the updraft.
  63623. */
  63624. enable(): void;
  63625. /**
  63626. * Disables the updraft.
  63627. */
  63628. disable(): void;
  63629. /**
  63630. * Disposes the cylinder.
  63631. * @param force Specifies if the updraft should be disposed by force
  63632. */
  63633. dispose(force?: boolean): void;
  63634. private getImpostorHitData;
  63635. private _tick;
  63636. /*** Helpers ***/
  63637. private _prepareCylinder;
  63638. private _intersectsWithCylinder;
  63639. }
  63640. /**
  63641. * Represents a physics vortex event
  63642. */
  63643. class PhysicsVortexEvent {
  63644. private _scene;
  63645. private _origin;
  63646. private _options;
  63647. private _physicsEngine;
  63648. private _originTop;
  63649. private _tickCallback;
  63650. private _cylinder;
  63651. private _cylinderPosition;
  63652. private _dataFetched;
  63653. /**
  63654. * Initializes the physics vortex event
  63655. * @param _scene The BabylonJS scene
  63656. * @param _origin The origin position of the vortex
  63657. * @param _options The options for the vortex event
  63658. */
  63659. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63660. /**
  63661. * Returns the data related to the vortex event (cylinder).
  63662. * @returns The physics vortex event data
  63663. */
  63664. getData(): PhysicsVortexEventData;
  63665. /**
  63666. * Enables the vortex.
  63667. */
  63668. enable(): void;
  63669. /**
  63670. * Disables the cortex.
  63671. */
  63672. disable(): void;
  63673. /**
  63674. * Disposes the sphere.
  63675. * @param force
  63676. */
  63677. dispose(force?: boolean): void;
  63678. private getImpostorHitData;
  63679. private _tick;
  63680. /*** Helpers ***/
  63681. private _prepareCylinder;
  63682. private _intersectsWithCylinder;
  63683. }
  63684. /**
  63685. * Options fot the radial explosion event
  63686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63687. */
  63688. export class PhysicsRadialExplosionEventOptions {
  63689. /**
  63690. * The radius of the sphere for the radial explosion.
  63691. */
  63692. radius: number;
  63693. /**
  63694. * The strenth of the explosion.
  63695. */
  63696. strength: number;
  63697. /**
  63698. * The strenght of the force in correspondence to the distance of the affected object
  63699. */
  63700. falloff: PhysicsRadialImpulseFalloff;
  63701. /**
  63702. * Sphere options for the radial explosion.
  63703. */
  63704. sphere: {
  63705. segments: number;
  63706. diameter: number;
  63707. };
  63708. /**
  63709. * Sphere options for the radial explosion.
  63710. */
  63711. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63712. }
  63713. /**
  63714. * Options fot the updraft event
  63715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63716. */
  63717. export class PhysicsUpdraftEventOptions {
  63718. /**
  63719. * The radius of the cylinder for the vortex
  63720. */
  63721. radius: number;
  63722. /**
  63723. * The strenth of the updraft.
  63724. */
  63725. strength: number;
  63726. /**
  63727. * The height of the cylinder for the updraft.
  63728. */
  63729. height: number;
  63730. /**
  63731. * The mode for the the updraft.
  63732. */
  63733. updraftMode: PhysicsUpdraftMode;
  63734. }
  63735. /**
  63736. * Options fot the vortex event
  63737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63738. */
  63739. export class PhysicsVortexEventOptions {
  63740. /**
  63741. * The radius of the cylinder for the vortex
  63742. */
  63743. radius: number;
  63744. /**
  63745. * The strenth of the vortex.
  63746. */
  63747. strength: number;
  63748. /**
  63749. * The height of the cylinder for the vortex.
  63750. */
  63751. height: number;
  63752. /**
  63753. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63754. */
  63755. centripetalForceThreshold: number;
  63756. /**
  63757. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63758. */
  63759. centripetalForceMultiplier: number;
  63760. /**
  63761. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63762. */
  63763. centrifugalForceMultiplier: number;
  63764. /**
  63765. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63766. */
  63767. updraftForceMultiplier: number;
  63768. }
  63769. /**
  63770. * The strenght of the force in correspondence to the distance of the affected object
  63771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63772. */
  63773. export enum PhysicsRadialImpulseFalloff {
  63774. /** Defines that impulse is constant in strength across it's whole radius */
  63775. Constant = 0,
  63776. /** Defines that impulse gets weaker if it's further from the origin */
  63777. Linear = 1
  63778. }
  63779. /**
  63780. * The strength of the force in correspondence to the distance of the affected object
  63781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63782. */
  63783. export enum PhysicsUpdraftMode {
  63784. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63785. Center = 0,
  63786. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63787. Perpendicular = 1
  63788. }
  63789. /**
  63790. * Interface for a physics hit data
  63791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63792. */
  63793. export interface PhysicsHitData {
  63794. /**
  63795. * The force applied at the contact point
  63796. */
  63797. force: Vector3;
  63798. /**
  63799. * The contact point
  63800. */
  63801. contactPoint: Vector3;
  63802. /**
  63803. * The distance from the origin to the contact point
  63804. */
  63805. distanceFromOrigin: number;
  63806. }
  63807. /**
  63808. * Interface for radial explosion event data
  63809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63810. */
  63811. export interface PhysicsRadialExplosionEventData {
  63812. /**
  63813. * A sphere used for the radial explosion event
  63814. */
  63815. sphere: Mesh;
  63816. }
  63817. /**
  63818. * Interface for gravitational field event data
  63819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63820. */
  63821. export interface PhysicsGravitationalFieldEventData {
  63822. /**
  63823. * A sphere mesh used for the gravitational field event
  63824. */
  63825. sphere: Mesh;
  63826. }
  63827. /**
  63828. * Interface for updraft event data
  63829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63830. */
  63831. export interface PhysicsUpdraftEventData {
  63832. /**
  63833. * A cylinder used for the updraft event
  63834. */
  63835. cylinder: Mesh;
  63836. }
  63837. /**
  63838. * Interface for vortex event data
  63839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63840. */
  63841. export interface PhysicsVortexEventData {
  63842. /**
  63843. * A cylinder used for the vortex event
  63844. */
  63845. cylinder: Mesh;
  63846. }
  63847. /**
  63848. * Interface for an affected physics impostor
  63849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63850. */
  63851. export interface PhysicsAffectedImpostorWithData {
  63852. /**
  63853. * The impostor affected by the effect
  63854. */
  63855. impostor: PhysicsImpostor;
  63856. /**
  63857. * The data about the hit/horce from the explosion
  63858. */
  63859. hitData: PhysicsHitData;
  63860. }
  63861. }
  63862. declare module "babylonjs/Physics/Plugins/index" {
  63863. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63864. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63865. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63866. }
  63867. declare module "babylonjs/Physics/index" {
  63868. export * from "babylonjs/Physics/IPhysicsEngine";
  63869. export * from "babylonjs/Physics/physicsEngine";
  63870. export * from "babylonjs/Physics/physicsEngineComponent";
  63871. export * from "babylonjs/Physics/physicsHelper";
  63872. export * from "babylonjs/Physics/physicsImpostor";
  63873. export * from "babylonjs/Physics/physicsJoint";
  63874. export * from "babylonjs/Physics/Plugins/index";
  63875. }
  63876. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63877. /** @hidden */
  63878. export var blackAndWhitePixelShader: {
  63879. name: string;
  63880. shader: string;
  63881. };
  63882. }
  63883. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63885. import { Camera } from "babylonjs/Cameras/camera";
  63886. import { Engine } from "babylonjs/Engines/engine";
  63887. import "babylonjs/Shaders/blackAndWhite.fragment";
  63888. /**
  63889. * Post process used to render in black and white
  63890. */
  63891. export class BlackAndWhitePostProcess extends PostProcess {
  63892. /**
  63893. * Linear about to convert he result to black and white (default: 1)
  63894. */
  63895. degree: number;
  63896. /**
  63897. * Creates a black and white post process
  63898. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63899. * @param name The name of the effect.
  63900. * @param options The required width/height ratio to downsize to before computing the render pass.
  63901. * @param camera The camera to apply the render pass to.
  63902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63903. * @param engine The engine which the post process will be applied. (default: current engine)
  63904. * @param reusable If the post process can be reused on the same frame. (default: false)
  63905. */
  63906. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63907. }
  63908. }
  63909. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63910. import { Nullable } from "babylonjs/types";
  63911. import { Camera } from "babylonjs/Cameras/camera";
  63912. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63913. import { Engine } from "babylonjs/Engines/engine";
  63914. /**
  63915. * This represents a set of one or more post processes in Babylon.
  63916. * A post process can be used to apply a shader to a texture after it is rendered.
  63917. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63918. */
  63919. export class PostProcessRenderEffect {
  63920. private _postProcesses;
  63921. private _getPostProcesses;
  63922. private _singleInstance;
  63923. private _cameras;
  63924. private _indicesForCamera;
  63925. /**
  63926. * Name of the effect
  63927. * @hidden
  63928. */
  63929. _name: string;
  63930. /**
  63931. * Instantiates a post process render effect.
  63932. * A post process can be used to apply a shader to a texture after it is rendered.
  63933. * @param engine The engine the effect is tied to
  63934. * @param name The name of the effect
  63935. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63936. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63937. */
  63938. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63939. /**
  63940. * Checks if all the post processes in the effect are supported.
  63941. */
  63942. readonly isSupported: boolean;
  63943. /**
  63944. * Updates the current state of the effect
  63945. * @hidden
  63946. */
  63947. _update(): void;
  63948. /**
  63949. * Attaches the effect on cameras
  63950. * @param cameras The camera to attach to.
  63951. * @hidden
  63952. */
  63953. _attachCameras(cameras: Camera): void;
  63954. /**
  63955. * Attaches the effect on cameras
  63956. * @param cameras The camera to attach to.
  63957. * @hidden
  63958. */
  63959. _attachCameras(cameras: Camera[]): void;
  63960. /**
  63961. * Detaches the effect on cameras
  63962. * @param cameras The camera to detatch from.
  63963. * @hidden
  63964. */
  63965. _detachCameras(cameras: Camera): void;
  63966. /**
  63967. * Detatches the effect on cameras
  63968. * @param cameras The camera to detatch from.
  63969. * @hidden
  63970. */
  63971. _detachCameras(cameras: Camera[]): void;
  63972. /**
  63973. * Enables the effect on given cameras
  63974. * @param cameras The camera to enable.
  63975. * @hidden
  63976. */
  63977. _enable(cameras: Camera): void;
  63978. /**
  63979. * Enables the effect on given cameras
  63980. * @param cameras The camera to enable.
  63981. * @hidden
  63982. */
  63983. _enable(cameras: Nullable<Camera[]>): void;
  63984. /**
  63985. * Disables the effect on the given cameras
  63986. * @param cameras The camera to disable.
  63987. * @hidden
  63988. */
  63989. _disable(cameras: Camera): void;
  63990. /**
  63991. * Disables the effect on the given cameras
  63992. * @param cameras The camera to disable.
  63993. * @hidden
  63994. */
  63995. _disable(cameras: Nullable<Camera[]>): void;
  63996. /**
  63997. * Gets a list of the post processes contained in the effect.
  63998. * @param camera The camera to get the post processes on.
  63999. * @returns The list of the post processes in the effect.
  64000. */
  64001. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64002. }
  64003. }
  64004. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64005. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64006. /** @hidden */
  64007. export var extractHighlightsPixelShader: {
  64008. name: string;
  64009. shader: string;
  64010. };
  64011. }
  64012. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64013. import { Nullable } from "babylonjs/types";
  64014. import { Camera } from "babylonjs/Cameras/camera";
  64015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64016. import { Engine } from "babylonjs/Engines/engine";
  64017. import "babylonjs/Shaders/extractHighlights.fragment";
  64018. /**
  64019. * 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.
  64020. */
  64021. export class ExtractHighlightsPostProcess extends PostProcess {
  64022. /**
  64023. * The luminance threshold, pixels below this value will be set to black.
  64024. */
  64025. threshold: number;
  64026. /** @hidden */
  64027. _exposure: number;
  64028. /**
  64029. * Post process which has the input texture to be used when performing highlight extraction
  64030. * @hidden
  64031. */
  64032. _inputPostProcess: Nullable<PostProcess>;
  64033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64034. }
  64035. }
  64036. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64037. /** @hidden */
  64038. export var bloomMergePixelShader: {
  64039. name: string;
  64040. shader: string;
  64041. };
  64042. }
  64043. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64045. import { Nullable } from "babylonjs/types";
  64046. import { Engine } from "babylonjs/Engines/engine";
  64047. import { Camera } from "babylonjs/Cameras/camera";
  64048. import "babylonjs/Shaders/bloomMerge.fragment";
  64049. /**
  64050. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64051. */
  64052. export class BloomMergePostProcess extends PostProcess {
  64053. /** Weight of the bloom to be added to the original input. */
  64054. weight: number;
  64055. /**
  64056. * Creates a new instance of @see BloomMergePostProcess
  64057. * @param name The name of the effect.
  64058. * @param originalFromInput Post process which's input will be used for the merge.
  64059. * @param blurred Blurred highlights post process which's output will be used.
  64060. * @param weight Weight of the bloom to be added to the original input.
  64061. * @param options The required width/height ratio to downsize to before computing the render pass.
  64062. * @param camera The camera to apply the render pass to.
  64063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64064. * @param engine The engine which the post process will be applied. (default: current engine)
  64065. * @param reusable If the post process can be reused on the same frame. (default: false)
  64066. * @param textureType Type of textures used when performing the post process. (default: 0)
  64067. * @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)
  64068. */
  64069. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64070. /** Weight of the bloom to be added to the original input. */
  64071. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64072. }
  64073. }
  64074. declare module "babylonjs/PostProcesses/bloomEffect" {
  64075. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64077. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64078. import { Camera } from "babylonjs/Cameras/camera";
  64079. import { Scene } from "babylonjs/scene";
  64080. /**
  64081. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64082. */
  64083. export class BloomEffect extends PostProcessRenderEffect {
  64084. private bloomScale;
  64085. /**
  64086. * @hidden Internal
  64087. */
  64088. _effects: Array<PostProcess>;
  64089. /**
  64090. * @hidden Internal
  64091. */
  64092. _downscale: ExtractHighlightsPostProcess;
  64093. private _blurX;
  64094. private _blurY;
  64095. private _merge;
  64096. /**
  64097. * The luminance threshold to find bright areas of the image to bloom.
  64098. */
  64099. threshold: number;
  64100. /**
  64101. * The strength of the bloom.
  64102. */
  64103. weight: number;
  64104. /**
  64105. * Specifies the size of the bloom blur kernel, relative to the final output size
  64106. */
  64107. kernel: number;
  64108. /**
  64109. * Creates a new instance of @see BloomEffect
  64110. * @param scene The scene the effect belongs to.
  64111. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64112. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64113. * @param bloomWeight The the strength of bloom.
  64114. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64115. * @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)
  64116. */
  64117. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64118. /**
  64119. * Disposes each of the internal effects for a given camera.
  64120. * @param camera The camera to dispose the effect on.
  64121. */
  64122. disposeEffects(camera: Camera): void;
  64123. /**
  64124. * @hidden Internal
  64125. */
  64126. _updateEffects(): void;
  64127. /**
  64128. * Internal
  64129. * @returns if all the contained post processes are ready.
  64130. * @hidden
  64131. */
  64132. _isReady(): boolean;
  64133. }
  64134. }
  64135. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64136. /** @hidden */
  64137. export var chromaticAberrationPixelShader: {
  64138. name: string;
  64139. shader: string;
  64140. };
  64141. }
  64142. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64143. import { Vector2 } from "babylonjs/Maths/math.vector";
  64144. import { Nullable } from "babylonjs/types";
  64145. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64146. import { Camera } from "babylonjs/Cameras/camera";
  64147. import { Engine } from "babylonjs/Engines/engine";
  64148. import "babylonjs/Shaders/chromaticAberration.fragment";
  64149. /**
  64150. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64151. */
  64152. export class ChromaticAberrationPostProcess extends PostProcess {
  64153. /**
  64154. * The amount of seperation of rgb channels (default: 30)
  64155. */
  64156. aberrationAmount: number;
  64157. /**
  64158. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64159. */
  64160. radialIntensity: number;
  64161. /**
  64162. * 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))
  64163. */
  64164. direction: Vector2;
  64165. /**
  64166. * 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))
  64167. */
  64168. centerPosition: Vector2;
  64169. /**
  64170. * Creates a new instance ChromaticAberrationPostProcess
  64171. * @param name The name of the effect.
  64172. * @param screenWidth The width of the screen to apply the effect on.
  64173. * @param screenHeight The height of the screen to apply the effect on.
  64174. * @param options The required width/height ratio to downsize to before computing the render pass.
  64175. * @param camera The camera to apply the render pass to.
  64176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64177. * @param engine The engine which the post process will be applied. (default: current engine)
  64178. * @param reusable If the post process can be reused on the same frame. (default: false)
  64179. * @param textureType Type of textures used when performing the post process. (default: 0)
  64180. * @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)
  64181. */
  64182. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64183. }
  64184. }
  64185. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64186. /** @hidden */
  64187. export var circleOfConfusionPixelShader: {
  64188. name: string;
  64189. shader: string;
  64190. };
  64191. }
  64192. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64193. import { Nullable } from "babylonjs/types";
  64194. import { Engine } from "babylonjs/Engines/engine";
  64195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64197. import { Camera } from "babylonjs/Cameras/camera";
  64198. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64199. /**
  64200. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64201. */
  64202. export class CircleOfConfusionPostProcess extends PostProcess {
  64203. /**
  64204. * 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.
  64205. */
  64206. lensSize: number;
  64207. /**
  64208. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64209. */
  64210. fStop: number;
  64211. /**
  64212. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64213. */
  64214. focusDistance: number;
  64215. /**
  64216. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64217. */
  64218. focalLength: number;
  64219. private _depthTexture;
  64220. /**
  64221. * Creates a new instance CircleOfConfusionPostProcess
  64222. * @param name The name of the effect.
  64223. * @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.
  64224. * @param options The required width/height ratio to downsize to before computing the render pass.
  64225. * @param camera The camera to apply the render pass to.
  64226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64227. * @param engine The engine which the post process will be applied. (default: current engine)
  64228. * @param reusable If the post process can be reused on the same frame. (default: false)
  64229. * @param textureType Type of textures used when performing the post process. (default: 0)
  64230. * @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)
  64231. */
  64232. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64233. /**
  64234. * 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.
  64235. */
  64236. depthTexture: RenderTargetTexture;
  64237. }
  64238. }
  64239. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64240. /** @hidden */
  64241. export var colorCorrectionPixelShader: {
  64242. name: string;
  64243. shader: string;
  64244. };
  64245. }
  64246. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64248. import { Engine } from "babylonjs/Engines/engine";
  64249. import { Camera } from "babylonjs/Cameras/camera";
  64250. import "babylonjs/Shaders/colorCorrection.fragment";
  64251. /**
  64252. *
  64253. * This post-process allows the modification of rendered colors by using
  64254. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64255. *
  64256. * The object needs to be provided an url to a texture containing the color
  64257. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64258. * Use an image editing software to tweak the LUT to match your needs.
  64259. *
  64260. * For an example of a color LUT, see here:
  64261. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64262. * For explanations on color grading, see here:
  64263. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64264. *
  64265. */
  64266. export class ColorCorrectionPostProcess extends PostProcess {
  64267. private _colorTableTexture;
  64268. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64269. }
  64270. }
  64271. declare module "babylonjs/Shaders/convolution.fragment" {
  64272. /** @hidden */
  64273. export var convolutionPixelShader: {
  64274. name: string;
  64275. shader: string;
  64276. };
  64277. }
  64278. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64279. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64280. import { Nullable } from "babylonjs/types";
  64281. import { Camera } from "babylonjs/Cameras/camera";
  64282. import { Engine } from "babylonjs/Engines/engine";
  64283. import "babylonjs/Shaders/convolution.fragment";
  64284. /**
  64285. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64286. * input texture to perform effects such as edge detection or sharpening
  64287. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64288. */
  64289. export class ConvolutionPostProcess extends PostProcess {
  64290. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64291. kernel: number[];
  64292. /**
  64293. * Creates a new instance ConvolutionPostProcess
  64294. * @param name The name of the effect.
  64295. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64296. * @param options The required width/height ratio to downsize to before computing the render pass.
  64297. * @param camera The camera to apply the render pass to.
  64298. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64299. * @param engine The engine which the post process will be applied. (default: current engine)
  64300. * @param reusable If the post process can be reused on the same frame. (default: false)
  64301. * @param textureType Type of textures used when performing the post process. (default: 0)
  64302. */
  64303. constructor(name: string,
  64304. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64305. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64306. /**
  64307. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64308. */
  64309. static EdgeDetect0Kernel: number[];
  64310. /**
  64311. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64312. */
  64313. static EdgeDetect1Kernel: number[];
  64314. /**
  64315. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64316. */
  64317. static EdgeDetect2Kernel: number[];
  64318. /**
  64319. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64320. */
  64321. static SharpenKernel: number[];
  64322. /**
  64323. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64324. */
  64325. static EmbossKernel: number[];
  64326. /**
  64327. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64328. */
  64329. static GaussianKernel: number[];
  64330. }
  64331. }
  64332. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64333. import { Nullable } from "babylonjs/types";
  64334. import { Vector2 } from "babylonjs/Maths/math.vector";
  64335. import { Camera } from "babylonjs/Cameras/camera";
  64336. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64337. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64338. import { Engine } from "babylonjs/Engines/engine";
  64339. import { Scene } from "babylonjs/scene";
  64340. /**
  64341. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64342. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64343. * based on samples that have a large difference in distance than the center pixel.
  64344. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64345. */
  64346. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64347. direction: Vector2;
  64348. /**
  64349. * Creates a new instance CircleOfConfusionPostProcess
  64350. * @param name The name of the effect.
  64351. * @param scene The scene the effect belongs to.
  64352. * @param direction The direction the blur should be applied.
  64353. * @param kernel The size of the kernel used to blur.
  64354. * @param options The required width/height ratio to downsize to before computing the render pass.
  64355. * @param camera The camera to apply the render pass to.
  64356. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64357. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64359. * @param engine The engine which the post process will be applied. (default: current engine)
  64360. * @param reusable If the post process can be reused on the same frame. (default: false)
  64361. * @param textureType Type of textures used when performing the post process. (default: 0)
  64362. * @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)
  64363. */
  64364. 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);
  64365. }
  64366. }
  64367. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64368. /** @hidden */
  64369. export var depthOfFieldMergePixelShader: {
  64370. name: string;
  64371. shader: string;
  64372. };
  64373. }
  64374. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64375. import { Nullable } from "babylonjs/types";
  64376. import { Camera } from "babylonjs/Cameras/camera";
  64377. import { Effect } from "babylonjs/Materials/effect";
  64378. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64379. import { Engine } from "babylonjs/Engines/engine";
  64380. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64381. /**
  64382. * Options to be set when merging outputs from the default pipeline.
  64383. */
  64384. export class DepthOfFieldMergePostProcessOptions {
  64385. /**
  64386. * The original image to merge on top of
  64387. */
  64388. originalFromInput: PostProcess;
  64389. /**
  64390. * Parameters to perform the merge of the depth of field effect
  64391. */
  64392. depthOfField?: {
  64393. circleOfConfusion: PostProcess;
  64394. blurSteps: Array<PostProcess>;
  64395. };
  64396. /**
  64397. * Parameters to perform the merge of bloom effect
  64398. */
  64399. bloom?: {
  64400. blurred: PostProcess;
  64401. weight: number;
  64402. };
  64403. }
  64404. /**
  64405. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64406. */
  64407. export class DepthOfFieldMergePostProcess extends PostProcess {
  64408. private blurSteps;
  64409. /**
  64410. * Creates a new instance of DepthOfFieldMergePostProcess
  64411. * @param name The name of the effect.
  64412. * @param originalFromInput Post process which's input will be used for the merge.
  64413. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64414. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64415. * @param options The required width/height ratio to downsize to before computing the render pass.
  64416. * @param camera The camera to apply the render pass to.
  64417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64418. * @param engine The engine which the post process will be applied. (default: current engine)
  64419. * @param reusable If the post process can be reused on the same frame. (default: false)
  64420. * @param textureType Type of textures used when performing the post process. (default: 0)
  64421. * @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)
  64422. */
  64423. 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);
  64424. /**
  64425. * Updates the effect with the current post process compile time values and recompiles the shader.
  64426. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64427. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64428. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64429. * @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
  64430. * @param onCompiled Called when the shader has been compiled.
  64431. * @param onError Called if there is an error when compiling a shader.
  64432. */
  64433. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64434. }
  64435. }
  64436. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64437. import { Nullable } from "babylonjs/types";
  64438. import { Camera } from "babylonjs/Cameras/camera";
  64439. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64441. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64442. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64443. import { Scene } from "babylonjs/scene";
  64444. /**
  64445. * Specifies the level of max blur that should be applied when using the depth of field effect
  64446. */
  64447. export enum DepthOfFieldEffectBlurLevel {
  64448. /**
  64449. * Subtle blur
  64450. */
  64451. Low = 0,
  64452. /**
  64453. * Medium blur
  64454. */
  64455. Medium = 1,
  64456. /**
  64457. * Large blur
  64458. */
  64459. High = 2
  64460. }
  64461. /**
  64462. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64463. */
  64464. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64465. private _circleOfConfusion;
  64466. /**
  64467. * @hidden Internal, blurs from high to low
  64468. */
  64469. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64470. private _depthOfFieldBlurY;
  64471. private _dofMerge;
  64472. /**
  64473. * @hidden Internal post processes in depth of field effect
  64474. */
  64475. _effects: Array<PostProcess>;
  64476. /**
  64477. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64478. */
  64479. focalLength: number;
  64480. /**
  64481. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64482. */
  64483. fStop: number;
  64484. /**
  64485. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64486. */
  64487. focusDistance: number;
  64488. /**
  64489. * 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.
  64490. */
  64491. lensSize: number;
  64492. /**
  64493. * Creates a new instance DepthOfFieldEffect
  64494. * @param scene The scene the effect belongs to.
  64495. * @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.
  64496. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64497. * @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)
  64498. */
  64499. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64500. /**
  64501. * Get the current class name of the current effet
  64502. * @returns "DepthOfFieldEffect"
  64503. */
  64504. getClassName(): string;
  64505. /**
  64506. * 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.
  64507. */
  64508. depthTexture: RenderTargetTexture;
  64509. /**
  64510. * Disposes each of the internal effects for a given camera.
  64511. * @param camera The camera to dispose the effect on.
  64512. */
  64513. disposeEffects(camera: Camera): void;
  64514. /**
  64515. * @hidden Internal
  64516. */
  64517. _updateEffects(): void;
  64518. /**
  64519. * Internal
  64520. * @returns if all the contained post processes are ready.
  64521. * @hidden
  64522. */
  64523. _isReady(): boolean;
  64524. }
  64525. }
  64526. declare module "babylonjs/Shaders/displayPass.fragment" {
  64527. /** @hidden */
  64528. export var displayPassPixelShader: {
  64529. name: string;
  64530. shader: string;
  64531. };
  64532. }
  64533. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64534. import { Nullable } from "babylonjs/types";
  64535. import { Camera } from "babylonjs/Cameras/camera";
  64536. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64537. import { Engine } from "babylonjs/Engines/engine";
  64538. import "babylonjs/Shaders/displayPass.fragment";
  64539. /**
  64540. * DisplayPassPostProcess which produces an output the same as it's input
  64541. */
  64542. export class DisplayPassPostProcess extends PostProcess {
  64543. /**
  64544. * Creates the DisplayPassPostProcess
  64545. * @param name The name of the effect.
  64546. * @param options The required width/height ratio to downsize to before computing the render pass.
  64547. * @param camera The camera to apply the render pass to.
  64548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64549. * @param engine The engine which the post process will be applied. (default: current engine)
  64550. * @param reusable If the post process can be reused on the same frame. (default: false)
  64551. */
  64552. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64553. }
  64554. }
  64555. declare module "babylonjs/Shaders/filter.fragment" {
  64556. /** @hidden */
  64557. export var filterPixelShader: {
  64558. name: string;
  64559. shader: string;
  64560. };
  64561. }
  64562. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64563. import { Nullable } from "babylonjs/types";
  64564. import { Matrix } from "babylonjs/Maths/math.vector";
  64565. import { Camera } from "babylonjs/Cameras/camera";
  64566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64567. import { Engine } from "babylonjs/Engines/engine";
  64568. import "babylonjs/Shaders/filter.fragment";
  64569. /**
  64570. * Applies a kernel filter to the image
  64571. */
  64572. export class FilterPostProcess extends PostProcess {
  64573. /** The matrix to be applied to the image */
  64574. kernelMatrix: Matrix;
  64575. /**
  64576. *
  64577. * @param name The name of the effect.
  64578. * @param kernelMatrix The matrix to be applied to the image
  64579. * @param options The required width/height ratio to downsize to before computing the render pass.
  64580. * @param camera The camera to apply the render pass to.
  64581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64582. * @param engine The engine which the post process will be applied. (default: current engine)
  64583. * @param reusable If the post process can be reused on the same frame. (default: false)
  64584. */
  64585. constructor(name: string,
  64586. /** The matrix to be applied to the image */
  64587. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64588. }
  64589. }
  64590. declare module "babylonjs/Shaders/fxaa.fragment" {
  64591. /** @hidden */
  64592. export var fxaaPixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module "babylonjs/Shaders/fxaa.vertex" {
  64598. /** @hidden */
  64599. export var fxaaVertexShader: {
  64600. name: string;
  64601. shader: string;
  64602. };
  64603. }
  64604. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64605. import { Nullable } from "babylonjs/types";
  64606. import { Camera } from "babylonjs/Cameras/camera";
  64607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64608. import { Engine } from "babylonjs/Engines/engine";
  64609. import "babylonjs/Shaders/fxaa.fragment";
  64610. import "babylonjs/Shaders/fxaa.vertex";
  64611. /**
  64612. * Fxaa post process
  64613. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64614. */
  64615. export class FxaaPostProcess extends PostProcess {
  64616. /** @hidden */
  64617. texelWidth: number;
  64618. /** @hidden */
  64619. texelHeight: number;
  64620. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64621. private _getDefines;
  64622. }
  64623. }
  64624. declare module "babylonjs/Shaders/grain.fragment" {
  64625. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64626. /** @hidden */
  64627. export var grainPixelShader: {
  64628. name: string;
  64629. shader: string;
  64630. };
  64631. }
  64632. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64633. import { Nullable } from "babylonjs/types";
  64634. import { Camera } from "babylonjs/Cameras/camera";
  64635. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64636. import { Engine } from "babylonjs/Engines/engine";
  64637. import "babylonjs/Shaders/grain.fragment";
  64638. /**
  64639. * The GrainPostProcess adds noise to the image at mid luminance levels
  64640. */
  64641. export class GrainPostProcess extends PostProcess {
  64642. /**
  64643. * The intensity of the grain added (default: 30)
  64644. */
  64645. intensity: number;
  64646. /**
  64647. * If the grain should be randomized on every frame
  64648. */
  64649. animated: boolean;
  64650. /**
  64651. * Creates a new instance of @see GrainPostProcess
  64652. * @param name The name of the effect.
  64653. * @param options The required width/height ratio to downsize to before computing the render pass.
  64654. * @param camera The camera to apply the render pass to.
  64655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64656. * @param engine The engine which the post process will be applied. (default: current engine)
  64657. * @param reusable If the post process can be reused on the same frame. (default: false)
  64658. * @param textureType Type of textures used when performing the post process. (default: 0)
  64659. * @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)
  64660. */
  64661. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64662. }
  64663. }
  64664. declare module "babylonjs/Shaders/highlights.fragment" {
  64665. /** @hidden */
  64666. export var highlightsPixelShader: {
  64667. name: string;
  64668. shader: string;
  64669. };
  64670. }
  64671. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64672. import { Nullable } from "babylonjs/types";
  64673. import { Camera } from "babylonjs/Cameras/camera";
  64674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64675. import { Engine } from "babylonjs/Engines/engine";
  64676. import "babylonjs/Shaders/highlights.fragment";
  64677. /**
  64678. * Extracts highlights from the image
  64679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64680. */
  64681. export class HighlightsPostProcess extends PostProcess {
  64682. /**
  64683. * Extracts highlights from the image
  64684. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64685. * @param name The name of the effect.
  64686. * @param options The required width/height ratio to downsize to before computing the render pass.
  64687. * @param camera The camera to apply the render pass to.
  64688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64689. * @param engine The engine which the post process will be applied. (default: current engine)
  64690. * @param reusable If the post process can be reused on the same frame. (default: false)
  64691. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64692. */
  64693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64694. }
  64695. }
  64696. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64697. /** @hidden */
  64698. export var mrtFragmentDeclaration: {
  64699. name: string;
  64700. shader: string;
  64701. };
  64702. }
  64703. declare module "babylonjs/Shaders/geometry.fragment" {
  64704. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64705. /** @hidden */
  64706. export var geometryPixelShader: {
  64707. name: string;
  64708. shader: string;
  64709. };
  64710. }
  64711. declare module "babylonjs/Shaders/geometry.vertex" {
  64712. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64713. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64714. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64715. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64716. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64717. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64718. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64719. /** @hidden */
  64720. export var geometryVertexShader: {
  64721. name: string;
  64722. shader: string;
  64723. };
  64724. }
  64725. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64726. import { Matrix } from "babylonjs/Maths/math.vector";
  64727. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64728. import { Mesh } from "babylonjs/Meshes/mesh";
  64729. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64730. import { Effect } from "babylonjs/Materials/effect";
  64731. import { Scene } from "babylonjs/scene";
  64732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64733. import "babylonjs/Shaders/geometry.fragment";
  64734. import "babylonjs/Shaders/geometry.vertex";
  64735. /** @hidden */
  64736. interface ISavedTransformationMatrix {
  64737. world: Matrix;
  64738. viewProjection: Matrix;
  64739. }
  64740. /**
  64741. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64742. */
  64743. export class GeometryBufferRenderer {
  64744. /**
  64745. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64746. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64747. */
  64748. static readonly POSITION_TEXTURE_TYPE: number;
  64749. /**
  64750. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64751. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64752. */
  64753. static readonly VELOCITY_TEXTURE_TYPE: number;
  64754. /**
  64755. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64756. * in order to compute objects velocities when enableVelocity is set to "true"
  64757. * @hidden
  64758. */
  64759. _previousTransformationMatrices: {
  64760. [index: number]: ISavedTransformationMatrix;
  64761. };
  64762. /**
  64763. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64764. * in order to compute objects velocities when enableVelocity is set to "true"
  64765. * @hidden
  64766. */
  64767. _previousBonesTransformationMatrices: {
  64768. [index: number]: Float32Array;
  64769. };
  64770. /**
  64771. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64772. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64773. */
  64774. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64775. private _scene;
  64776. private _multiRenderTarget;
  64777. private _ratio;
  64778. private _enablePosition;
  64779. private _enableVelocity;
  64780. private _positionIndex;
  64781. private _velocityIndex;
  64782. protected _effect: Effect;
  64783. protected _cachedDefines: string;
  64784. /**
  64785. * Set the render list (meshes to be rendered) used in the G buffer.
  64786. */
  64787. renderList: Mesh[];
  64788. /**
  64789. * Gets wether or not G buffer are supported by the running hardware.
  64790. * This requires draw buffer supports
  64791. */
  64792. readonly isSupported: boolean;
  64793. /**
  64794. * Returns the index of the given texture type in the G-Buffer textures array
  64795. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64796. * @returns the index of the given texture type in the G-Buffer textures array
  64797. */
  64798. getTextureIndex(textureType: number): number;
  64799. /**
  64800. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64801. */
  64802. /**
  64803. * Sets whether or not objects positions are enabled for the G buffer.
  64804. */
  64805. enablePosition: boolean;
  64806. /**
  64807. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64808. */
  64809. /**
  64810. * Sets wether or not objects velocities are enabled for the G buffer.
  64811. */
  64812. enableVelocity: boolean;
  64813. /**
  64814. * Gets the scene associated with the buffer.
  64815. */
  64816. readonly scene: Scene;
  64817. /**
  64818. * Gets the ratio used by the buffer during its creation.
  64819. * How big is the buffer related to the main canvas.
  64820. */
  64821. readonly ratio: number;
  64822. /** @hidden */
  64823. static _SceneComponentInitialization: (scene: Scene) => void;
  64824. /**
  64825. * Creates a new G Buffer for the scene
  64826. * @param scene The scene the buffer belongs to
  64827. * @param ratio How big is the buffer related to the main canvas.
  64828. */
  64829. constructor(scene: Scene, ratio?: number);
  64830. /**
  64831. * Checks wether everything is ready to render a submesh to the G buffer.
  64832. * @param subMesh the submesh to check readiness for
  64833. * @param useInstances is the mesh drawn using instance or not
  64834. * @returns true if ready otherwise false
  64835. */
  64836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64837. /**
  64838. * Gets the current underlying G Buffer.
  64839. * @returns the buffer
  64840. */
  64841. getGBuffer(): MultiRenderTarget;
  64842. /**
  64843. * Gets the number of samples used to render the buffer (anti aliasing).
  64844. */
  64845. /**
  64846. * Sets the number of samples used to render the buffer (anti aliasing).
  64847. */
  64848. samples: number;
  64849. /**
  64850. * Disposes the renderer and frees up associated resources.
  64851. */
  64852. dispose(): void;
  64853. protected _createRenderTargets(): void;
  64854. private _copyBonesTransformationMatrices;
  64855. }
  64856. }
  64857. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64858. import { Nullable } from "babylonjs/types";
  64859. import { Scene } from "babylonjs/scene";
  64860. import { ISceneComponent } from "babylonjs/sceneComponent";
  64861. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64862. module "babylonjs/scene" {
  64863. interface Scene {
  64864. /** @hidden (Backing field) */
  64865. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64866. /**
  64867. * Gets or Sets the current geometry buffer associated to the scene.
  64868. */
  64869. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64870. /**
  64871. * Enables a GeometryBufferRender and associates it with the scene
  64872. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64873. * @returns the GeometryBufferRenderer
  64874. */
  64875. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64876. /**
  64877. * Disables the GeometryBufferRender associated with the scene
  64878. */
  64879. disableGeometryBufferRenderer(): void;
  64880. }
  64881. }
  64882. /**
  64883. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64884. * in several rendering techniques.
  64885. */
  64886. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64887. /**
  64888. * The component name helpful to identify the component in the list of scene components.
  64889. */
  64890. readonly name: string;
  64891. /**
  64892. * The scene the component belongs to.
  64893. */
  64894. scene: Scene;
  64895. /**
  64896. * Creates a new instance of the component for the given scene
  64897. * @param scene Defines the scene to register the component in
  64898. */
  64899. constructor(scene: Scene);
  64900. /**
  64901. * Registers the component in a given scene
  64902. */
  64903. register(): void;
  64904. /**
  64905. * Rebuilds the elements related to this component in case of
  64906. * context lost for instance.
  64907. */
  64908. rebuild(): void;
  64909. /**
  64910. * Disposes the component and the associated ressources
  64911. */
  64912. dispose(): void;
  64913. private _gatherRenderTargets;
  64914. }
  64915. }
  64916. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64917. /** @hidden */
  64918. export var motionBlurPixelShader: {
  64919. name: string;
  64920. shader: string;
  64921. };
  64922. }
  64923. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64924. import { Nullable } from "babylonjs/types";
  64925. import { Camera } from "babylonjs/Cameras/camera";
  64926. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64927. import { Scene } from "babylonjs/scene";
  64928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64929. import "babylonjs/Animations/animatable";
  64930. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64931. import "babylonjs/Shaders/motionBlur.fragment";
  64932. import { Engine } from "babylonjs/Engines/engine";
  64933. /**
  64934. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64935. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64936. * As an example, all you have to do is to create the post-process:
  64937. * var mb = new BABYLON.MotionBlurPostProcess(
  64938. * 'mb', // The name of the effect.
  64939. * scene, // The scene containing the objects to blur according to their velocity.
  64940. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64941. * camera // The camera to apply the render pass to.
  64942. * );
  64943. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64944. */
  64945. export class MotionBlurPostProcess extends PostProcess {
  64946. /**
  64947. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64948. */
  64949. motionStrength: number;
  64950. /**
  64951. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64952. */
  64953. /**
  64954. * Sets the number of iterations to be used for motion blur quality
  64955. */
  64956. motionBlurSamples: number;
  64957. private _motionBlurSamples;
  64958. private _geometryBufferRenderer;
  64959. /**
  64960. * Creates a new instance MotionBlurPostProcess
  64961. * @param name The name of the effect.
  64962. * @param scene The scene containing the objects to blur according to their velocity.
  64963. * @param options The required width/height ratio to downsize to before computing the render pass.
  64964. * @param camera The camera to apply the render pass to.
  64965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64966. * @param engine The engine which the post process will be applied. (default: current engine)
  64967. * @param reusable If the post process can be reused on the same frame. (default: false)
  64968. * @param textureType Type of textures used when performing the post process. (default: 0)
  64969. * @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)
  64970. */
  64971. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64972. /**
  64973. * Excludes the given skinned mesh from computing bones velocities.
  64974. * 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.
  64975. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64976. */
  64977. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64978. /**
  64979. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64980. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64981. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64982. */
  64983. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64984. /**
  64985. * Disposes the post process.
  64986. * @param camera The camera to dispose the post process on.
  64987. */
  64988. dispose(camera?: Camera): void;
  64989. }
  64990. }
  64991. declare module "babylonjs/Shaders/refraction.fragment" {
  64992. /** @hidden */
  64993. export var refractionPixelShader: {
  64994. name: string;
  64995. shader: string;
  64996. };
  64997. }
  64998. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64999. import { Color3 } from "babylonjs/Maths/math.color";
  65000. import { Camera } from "babylonjs/Cameras/camera";
  65001. import { Texture } from "babylonjs/Materials/Textures/texture";
  65002. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65003. import { Engine } from "babylonjs/Engines/engine";
  65004. import "babylonjs/Shaders/refraction.fragment";
  65005. /**
  65006. * Post process which applies a refractin texture
  65007. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65008. */
  65009. export class RefractionPostProcess extends PostProcess {
  65010. /** the base color of the refraction (used to taint the rendering) */
  65011. color: Color3;
  65012. /** simulated refraction depth */
  65013. depth: number;
  65014. /** the coefficient of the base color (0 to remove base color tainting) */
  65015. colorLevel: number;
  65016. private _refTexture;
  65017. private _ownRefractionTexture;
  65018. /**
  65019. * Gets or sets the refraction texture
  65020. * Please note that you are responsible for disposing the texture if you set it manually
  65021. */
  65022. refractionTexture: Texture;
  65023. /**
  65024. * Initializes the RefractionPostProcess
  65025. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65026. * @param name The name of the effect.
  65027. * @param refractionTextureUrl Url of the refraction texture to use
  65028. * @param color the base color of the refraction (used to taint the rendering)
  65029. * @param depth simulated refraction depth
  65030. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65031. * @param camera The camera to apply the render pass to.
  65032. * @param options The required width/height ratio to downsize to before computing the render pass.
  65033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65034. * @param engine The engine which the post process will be applied. (default: current engine)
  65035. * @param reusable If the post process can be reused on the same frame. (default: false)
  65036. */
  65037. constructor(name: string, refractionTextureUrl: string,
  65038. /** the base color of the refraction (used to taint the rendering) */
  65039. color: Color3,
  65040. /** simulated refraction depth */
  65041. depth: number,
  65042. /** the coefficient of the base color (0 to remove base color tainting) */
  65043. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65044. /**
  65045. * Disposes of the post process
  65046. * @param camera Camera to dispose post process on
  65047. */
  65048. dispose(camera: Camera): void;
  65049. }
  65050. }
  65051. declare module "babylonjs/Shaders/sharpen.fragment" {
  65052. /** @hidden */
  65053. export var sharpenPixelShader: {
  65054. name: string;
  65055. shader: string;
  65056. };
  65057. }
  65058. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65059. import { Nullable } from "babylonjs/types";
  65060. import { Camera } from "babylonjs/Cameras/camera";
  65061. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65062. import "babylonjs/Shaders/sharpen.fragment";
  65063. import { Engine } from "babylonjs/Engines/engine";
  65064. /**
  65065. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65066. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65067. */
  65068. export class SharpenPostProcess extends PostProcess {
  65069. /**
  65070. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65071. */
  65072. colorAmount: number;
  65073. /**
  65074. * How much sharpness should be applied (default: 0.3)
  65075. */
  65076. edgeAmount: number;
  65077. /**
  65078. * Creates a new instance ConvolutionPostProcess
  65079. * @param name The name of the effect.
  65080. * @param options The required width/height ratio to downsize to before computing the render pass.
  65081. * @param camera The camera to apply the render pass to.
  65082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65083. * @param engine The engine which the post process will be applied. (default: current engine)
  65084. * @param reusable If the post process can be reused on the same frame. (default: false)
  65085. * @param textureType Type of textures used when performing the post process. (default: 0)
  65086. * @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)
  65087. */
  65088. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65089. }
  65090. }
  65091. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65092. import { Nullable } from "babylonjs/types";
  65093. import { Camera } from "babylonjs/Cameras/camera";
  65094. import { Engine } from "babylonjs/Engines/engine";
  65095. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65096. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65097. /**
  65098. * PostProcessRenderPipeline
  65099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65100. */
  65101. export class PostProcessRenderPipeline {
  65102. private engine;
  65103. private _renderEffects;
  65104. private _renderEffectsForIsolatedPass;
  65105. /**
  65106. * List of inspectable custom properties (used by the Inspector)
  65107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65108. */
  65109. inspectableCustomProperties: IInspectable[];
  65110. /**
  65111. * @hidden
  65112. */
  65113. protected _cameras: Camera[];
  65114. /** @hidden */
  65115. _name: string;
  65116. /**
  65117. * Gets pipeline name
  65118. */
  65119. readonly name: string;
  65120. /** Gets the list of attached cameras */
  65121. readonly cameras: Camera[];
  65122. /**
  65123. * Initializes a PostProcessRenderPipeline
  65124. * @param engine engine to add the pipeline to
  65125. * @param name name of the pipeline
  65126. */
  65127. constructor(engine: Engine, name: string);
  65128. /**
  65129. * Gets the class name
  65130. * @returns "PostProcessRenderPipeline"
  65131. */
  65132. getClassName(): string;
  65133. /**
  65134. * If all the render effects in the pipeline are supported
  65135. */
  65136. readonly isSupported: boolean;
  65137. /**
  65138. * Adds an effect to the pipeline
  65139. * @param renderEffect the effect to add
  65140. */
  65141. addEffect(renderEffect: PostProcessRenderEffect): void;
  65142. /** @hidden */
  65143. _rebuild(): void;
  65144. /** @hidden */
  65145. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65146. /** @hidden */
  65147. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65148. /** @hidden */
  65149. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65150. /** @hidden */
  65151. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65152. /** @hidden */
  65153. _attachCameras(cameras: Camera, unique: boolean): void;
  65154. /** @hidden */
  65155. _attachCameras(cameras: Camera[], unique: boolean): void;
  65156. /** @hidden */
  65157. _detachCameras(cameras: Camera): void;
  65158. /** @hidden */
  65159. _detachCameras(cameras: Nullable<Camera[]>): void;
  65160. /** @hidden */
  65161. _update(): void;
  65162. /** @hidden */
  65163. _reset(): void;
  65164. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65165. /**
  65166. * Disposes of the pipeline
  65167. */
  65168. dispose(): void;
  65169. }
  65170. }
  65171. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65172. import { Camera } from "babylonjs/Cameras/camera";
  65173. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65174. /**
  65175. * PostProcessRenderPipelineManager class
  65176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65177. */
  65178. export class PostProcessRenderPipelineManager {
  65179. private _renderPipelines;
  65180. /**
  65181. * Initializes a PostProcessRenderPipelineManager
  65182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65183. */
  65184. constructor();
  65185. /**
  65186. * Gets the list of supported render pipelines
  65187. */
  65188. readonly supportedPipelines: PostProcessRenderPipeline[];
  65189. /**
  65190. * Adds a pipeline to the manager
  65191. * @param renderPipeline The pipeline to add
  65192. */
  65193. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65194. /**
  65195. * Attaches a camera to the pipeline
  65196. * @param renderPipelineName The name of the pipeline to attach to
  65197. * @param cameras the camera to attach
  65198. * @param unique if the camera can be attached multiple times to the pipeline
  65199. */
  65200. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65201. /**
  65202. * Detaches a camera from the pipeline
  65203. * @param renderPipelineName The name of the pipeline to detach from
  65204. * @param cameras the camera to detach
  65205. */
  65206. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65207. /**
  65208. * Enables an effect by name on a pipeline
  65209. * @param renderPipelineName the name of the pipeline to enable the effect in
  65210. * @param renderEffectName the name of the effect to enable
  65211. * @param cameras the cameras that the effect should be enabled on
  65212. */
  65213. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65214. /**
  65215. * Disables an effect by name on a pipeline
  65216. * @param renderPipelineName the name of the pipeline to disable the effect in
  65217. * @param renderEffectName the name of the effect to disable
  65218. * @param cameras the cameras that the effect should be disabled on
  65219. */
  65220. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65221. /**
  65222. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65223. */
  65224. update(): void;
  65225. /** @hidden */
  65226. _rebuild(): void;
  65227. /**
  65228. * Disposes of the manager and pipelines
  65229. */
  65230. dispose(): void;
  65231. }
  65232. }
  65233. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65234. import { ISceneComponent } from "babylonjs/sceneComponent";
  65235. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65236. import { Scene } from "babylonjs/scene";
  65237. module "babylonjs/scene" {
  65238. interface Scene {
  65239. /** @hidden (Backing field) */
  65240. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65241. /**
  65242. * Gets the postprocess render pipeline manager
  65243. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65244. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65245. */
  65246. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65247. }
  65248. }
  65249. /**
  65250. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65251. */
  65252. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65253. /**
  65254. * The component name helpfull to identify the component in the list of scene components.
  65255. */
  65256. readonly name: string;
  65257. /**
  65258. * The scene the component belongs to.
  65259. */
  65260. scene: Scene;
  65261. /**
  65262. * Creates a new instance of the component for the given scene
  65263. * @param scene Defines the scene to register the component in
  65264. */
  65265. constructor(scene: Scene);
  65266. /**
  65267. * Registers the component in a given scene
  65268. */
  65269. register(): void;
  65270. /**
  65271. * Rebuilds the elements related to this component in case of
  65272. * context lost for instance.
  65273. */
  65274. rebuild(): void;
  65275. /**
  65276. * Disposes the component and the associated ressources
  65277. */
  65278. dispose(): void;
  65279. private _gatherRenderTargets;
  65280. }
  65281. }
  65282. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65283. import { Nullable } from "babylonjs/types";
  65284. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65285. import { Camera } from "babylonjs/Cameras/camera";
  65286. import { IDisposable } from "babylonjs/scene";
  65287. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65288. import { Scene } from "babylonjs/scene";
  65289. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65290. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65291. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65292. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65293. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65294. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65295. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65296. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65297. import { Animation } from "babylonjs/Animations/animation";
  65298. /**
  65299. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65300. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65301. */
  65302. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65303. private _scene;
  65304. private _camerasToBeAttached;
  65305. /**
  65306. * ID of the sharpen post process,
  65307. */
  65308. private readonly SharpenPostProcessId;
  65309. /**
  65310. * @ignore
  65311. * ID of the image processing post process;
  65312. */
  65313. readonly ImageProcessingPostProcessId: string;
  65314. /**
  65315. * @ignore
  65316. * ID of the Fast Approximate Anti-Aliasing post process;
  65317. */
  65318. readonly FxaaPostProcessId: string;
  65319. /**
  65320. * ID of the chromatic aberration post process,
  65321. */
  65322. private readonly ChromaticAberrationPostProcessId;
  65323. /**
  65324. * ID of the grain post process
  65325. */
  65326. private readonly GrainPostProcessId;
  65327. /**
  65328. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65329. */
  65330. sharpen: SharpenPostProcess;
  65331. private _sharpenEffect;
  65332. private bloom;
  65333. /**
  65334. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65335. */
  65336. depthOfField: DepthOfFieldEffect;
  65337. /**
  65338. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65339. */
  65340. fxaa: FxaaPostProcess;
  65341. /**
  65342. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65343. */
  65344. imageProcessing: ImageProcessingPostProcess;
  65345. /**
  65346. * Chromatic aberration post process which will shift rgb colors in the image
  65347. */
  65348. chromaticAberration: ChromaticAberrationPostProcess;
  65349. private _chromaticAberrationEffect;
  65350. /**
  65351. * Grain post process which add noise to the image
  65352. */
  65353. grain: GrainPostProcess;
  65354. private _grainEffect;
  65355. /**
  65356. * Glow post process which adds a glow to emissive areas of the image
  65357. */
  65358. private _glowLayer;
  65359. /**
  65360. * Animations which can be used to tweak settings over a period of time
  65361. */
  65362. animations: Animation[];
  65363. private _imageProcessingConfigurationObserver;
  65364. private _sharpenEnabled;
  65365. private _bloomEnabled;
  65366. private _depthOfFieldEnabled;
  65367. private _depthOfFieldBlurLevel;
  65368. private _fxaaEnabled;
  65369. private _imageProcessingEnabled;
  65370. private _defaultPipelineTextureType;
  65371. private _bloomScale;
  65372. private _chromaticAberrationEnabled;
  65373. private _grainEnabled;
  65374. private _buildAllowed;
  65375. /**
  65376. * Gets active scene
  65377. */
  65378. readonly scene: Scene;
  65379. /**
  65380. * Enable or disable the sharpen process from the pipeline
  65381. */
  65382. sharpenEnabled: boolean;
  65383. private _resizeObserver;
  65384. private _hardwareScaleLevel;
  65385. private _bloomKernel;
  65386. /**
  65387. * Specifies the size of the bloom blur kernel, relative to the final output size
  65388. */
  65389. bloomKernel: number;
  65390. /**
  65391. * Specifies the weight of the bloom in the final rendering
  65392. */
  65393. private _bloomWeight;
  65394. /**
  65395. * Specifies the luma threshold for the area that will be blurred by the bloom
  65396. */
  65397. private _bloomThreshold;
  65398. private _hdr;
  65399. /**
  65400. * The strength of the bloom.
  65401. */
  65402. bloomWeight: number;
  65403. /**
  65404. * The strength of the bloom.
  65405. */
  65406. bloomThreshold: number;
  65407. /**
  65408. * The scale of the bloom, lower value will provide better performance.
  65409. */
  65410. bloomScale: number;
  65411. /**
  65412. * Enable or disable the bloom from the pipeline
  65413. */
  65414. bloomEnabled: boolean;
  65415. private _rebuildBloom;
  65416. /**
  65417. * If the depth of field is enabled.
  65418. */
  65419. depthOfFieldEnabled: boolean;
  65420. /**
  65421. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65422. */
  65423. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65424. /**
  65425. * If the anti aliasing is enabled.
  65426. */
  65427. fxaaEnabled: boolean;
  65428. private _samples;
  65429. /**
  65430. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65431. */
  65432. samples: number;
  65433. /**
  65434. * If image processing is enabled.
  65435. */
  65436. imageProcessingEnabled: boolean;
  65437. /**
  65438. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65439. */
  65440. glowLayerEnabled: boolean;
  65441. /**
  65442. * Gets the glow layer (or null if not defined)
  65443. */
  65444. readonly glowLayer: Nullable<GlowLayer>;
  65445. /**
  65446. * Enable or disable the chromaticAberration process from the pipeline
  65447. */
  65448. chromaticAberrationEnabled: boolean;
  65449. /**
  65450. * Enable or disable the grain process from the pipeline
  65451. */
  65452. grainEnabled: boolean;
  65453. /**
  65454. * @constructor
  65455. * @param name - The rendering pipeline name (default: "")
  65456. * @param hdr - If high dynamic range textures should be used (default: true)
  65457. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65458. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65459. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65460. */
  65461. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65462. /**
  65463. * Get the class name
  65464. * @returns "DefaultRenderingPipeline"
  65465. */
  65466. getClassName(): string;
  65467. /**
  65468. * Force the compilation of the entire pipeline.
  65469. */
  65470. prepare(): void;
  65471. private _hasCleared;
  65472. private _prevPostProcess;
  65473. private _prevPrevPostProcess;
  65474. private _setAutoClearAndTextureSharing;
  65475. private _depthOfFieldSceneObserver;
  65476. private _buildPipeline;
  65477. private _disposePostProcesses;
  65478. /**
  65479. * Adds a camera to the pipeline
  65480. * @param camera the camera to be added
  65481. */
  65482. addCamera(camera: Camera): void;
  65483. /**
  65484. * Removes a camera from the pipeline
  65485. * @param camera the camera to remove
  65486. */
  65487. removeCamera(camera: Camera): void;
  65488. /**
  65489. * Dispose of the pipeline and stop all post processes
  65490. */
  65491. dispose(): void;
  65492. /**
  65493. * Serialize the rendering pipeline (Used when exporting)
  65494. * @returns the serialized object
  65495. */
  65496. serialize(): any;
  65497. /**
  65498. * Parse the serialized pipeline
  65499. * @param source Source pipeline.
  65500. * @param scene The scene to load the pipeline to.
  65501. * @param rootUrl The URL of the serialized pipeline.
  65502. * @returns An instantiated pipeline from the serialized object.
  65503. */
  65504. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65505. }
  65506. }
  65507. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65508. /** @hidden */
  65509. export var lensHighlightsPixelShader: {
  65510. name: string;
  65511. shader: string;
  65512. };
  65513. }
  65514. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65515. /** @hidden */
  65516. export var depthOfFieldPixelShader: {
  65517. name: string;
  65518. shader: string;
  65519. };
  65520. }
  65521. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65522. import { Camera } from "babylonjs/Cameras/camera";
  65523. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65524. import { Scene } from "babylonjs/scene";
  65525. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65526. import "babylonjs/Shaders/chromaticAberration.fragment";
  65527. import "babylonjs/Shaders/lensHighlights.fragment";
  65528. import "babylonjs/Shaders/depthOfField.fragment";
  65529. /**
  65530. * BABYLON.JS Chromatic Aberration GLSL Shader
  65531. * Author: Olivier Guyot
  65532. * Separates very slightly R, G and B colors on the edges of the screen
  65533. * Inspired by Francois Tarlier & Martins Upitis
  65534. */
  65535. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65536. /**
  65537. * @ignore
  65538. * The chromatic aberration PostProcess id in the pipeline
  65539. */
  65540. LensChromaticAberrationEffect: string;
  65541. /**
  65542. * @ignore
  65543. * The highlights enhancing PostProcess id in the pipeline
  65544. */
  65545. HighlightsEnhancingEffect: string;
  65546. /**
  65547. * @ignore
  65548. * The depth-of-field PostProcess id in the pipeline
  65549. */
  65550. LensDepthOfFieldEffect: string;
  65551. private _scene;
  65552. private _depthTexture;
  65553. private _grainTexture;
  65554. private _chromaticAberrationPostProcess;
  65555. private _highlightsPostProcess;
  65556. private _depthOfFieldPostProcess;
  65557. private _edgeBlur;
  65558. private _grainAmount;
  65559. private _chromaticAberration;
  65560. private _distortion;
  65561. private _highlightsGain;
  65562. private _highlightsThreshold;
  65563. private _dofDistance;
  65564. private _dofAperture;
  65565. private _dofDarken;
  65566. private _dofPentagon;
  65567. private _blurNoise;
  65568. /**
  65569. * @constructor
  65570. *
  65571. * Effect parameters are as follow:
  65572. * {
  65573. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65574. * edge_blur: number; // from 0 to x (1 for realism)
  65575. * distortion: number; // from 0 to x (1 for realism)
  65576. * grain_amount: number; // from 0 to 1
  65577. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65578. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65579. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65580. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65581. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65582. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65583. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65584. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65585. * }
  65586. * Note: if an effect parameter is unset, effect is disabled
  65587. *
  65588. * @param name The rendering pipeline name
  65589. * @param parameters - An object containing all parameters (see above)
  65590. * @param scene The scene linked to this pipeline
  65591. * @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)
  65592. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65593. */
  65594. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65595. /**
  65596. * Get the class name
  65597. * @returns "LensRenderingPipeline"
  65598. */
  65599. getClassName(): string;
  65600. /**
  65601. * Gets associated scene
  65602. */
  65603. readonly scene: Scene;
  65604. /**
  65605. * Gets or sets the edge blur
  65606. */
  65607. edgeBlur: number;
  65608. /**
  65609. * Gets or sets the grain amount
  65610. */
  65611. grainAmount: number;
  65612. /**
  65613. * Gets or sets the chromatic aberration amount
  65614. */
  65615. chromaticAberration: number;
  65616. /**
  65617. * Gets or sets the depth of field aperture
  65618. */
  65619. dofAperture: number;
  65620. /**
  65621. * Gets or sets the edge distortion
  65622. */
  65623. edgeDistortion: number;
  65624. /**
  65625. * Gets or sets the depth of field distortion
  65626. */
  65627. dofDistortion: number;
  65628. /**
  65629. * Gets or sets the darken out of focus amount
  65630. */
  65631. darkenOutOfFocus: number;
  65632. /**
  65633. * Gets or sets a boolean indicating if blur noise is enabled
  65634. */
  65635. blurNoise: boolean;
  65636. /**
  65637. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65638. */
  65639. pentagonBokeh: boolean;
  65640. /**
  65641. * Gets or sets the highlight grain amount
  65642. */
  65643. highlightsGain: number;
  65644. /**
  65645. * Gets or sets the highlight threshold
  65646. */
  65647. highlightsThreshold: number;
  65648. /**
  65649. * Sets the amount of blur at the edges
  65650. * @param amount blur amount
  65651. */
  65652. setEdgeBlur(amount: number): void;
  65653. /**
  65654. * Sets edge blur to 0
  65655. */
  65656. disableEdgeBlur(): void;
  65657. /**
  65658. * Sets the amout of grain
  65659. * @param amount Amount of grain
  65660. */
  65661. setGrainAmount(amount: number): void;
  65662. /**
  65663. * Set grain amount to 0
  65664. */
  65665. disableGrain(): void;
  65666. /**
  65667. * Sets the chromatic aberration amount
  65668. * @param amount amount of chromatic aberration
  65669. */
  65670. setChromaticAberration(amount: number): void;
  65671. /**
  65672. * Sets chromatic aberration amount to 0
  65673. */
  65674. disableChromaticAberration(): void;
  65675. /**
  65676. * Sets the EdgeDistortion amount
  65677. * @param amount amount of EdgeDistortion
  65678. */
  65679. setEdgeDistortion(amount: number): void;
  65680. /**
  65681. * Sets edge distortion to 0
  65682. */
  65683. disableEdgeDistortion(): void;
  65684. /**
  65685. * Sets the FocusDistance amount
  65686. * @param amount amount of FocusDistance
  65687. */
  65688. setFocusDistance(amount: number): void;
  65689. /**
  65690. * Disables depth of field
  65691. */
  65692. disableDepthOfField(): void;
  65693. /**
  65694. * Sets the Aperture amount
  65695. * @param amount amount of Aperture
  65696. */
  65697. setAperture(amount: number): void;
  65698. /**
  65699. * Sets the DarkenOutOfFocus amount
  65700. * @param amount amount of DarkenOutOfFocus
  65701. */
  65702. setDarkenOutOfFocus(amount: number): void;
  65703. private _pentagonBokehIsEnabled;
  65704. /**
  65705. * Creates a pentagon bokeh effect
  65706. */
  65707. enablePentagonBokeh(): void;
  65708. /**
  65709. * Disables the pentagon bokeh effect
  65710. */
  65711. disablePentagonBokeh(): void;
  65712. /**
  65713. * Enables noise blur
  65714. */
  65715. enableNoiseBlur(): void;
  65716. /**
  65717. * Disables noise blur
  65718. */
  65719. disableNoiseBlur(): void;
  65720. /**
  65721. * Sets the HighlightsGain amount
  65722. * @param amount amount of HighlightsGain
  65723. */
  65724. setHighlightsGain(amount: number): void;
  65725. /**
  65726. * Sets the HighlightsThreshold amount
  65727. * @param amount amount of HighlightsThreshold
  65728. */
  65729. setHighlightsThreshold(amount: number): void;
  65730. /**
  65731. * Disables highlights
  65732. */
  65733. disableHighlights(): void;
  65734. /**
  65735. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65736. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65737. */
  65738. dispose(disableDepthRender?: boolean): void;
  65739. private _createChromaticAberrationPostProcess;
  65740. private _createHighlightsPostProcess;
  65741. private _createDepthOfFieldPostProcess;
  65742. private _createGrainTexture;
  65743. }
  65744. }
  65745. declare module "babylonjs/Shaders/ssao2.fragment" {
  65746. /** @hidden */
  65747. export var ssao2PixelShader: {
  65748. name: string;
  65749. shader: string;
  65750. };
  65751. }
  65752. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65753. /** @hidden */
  65754. export var ssaoCombinePixelShader: {
  65755. name: string;
  65756. shader: string;
  65757. };
  65758. }
  65759. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65760. import { Camera } from "babylonjs/Cameras/camera";
  65761. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65762. import { Scene } from "babylonjs/scene";
  65763. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65764. import "babylonjs/Shaders/ssao2.fragment";
  65765. import "babylonjs/Shaders/ssaoCombine.fragment";
  65766. /**
  65767. * Render pipeline to produce ssao effect
  65768. */
  65769. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65770. /**
  65771. * @ignore
  65772. * The PassPostProcess id in the pipeline that contains the original scene color
  65773. */
  65774. SSAOOriginalSceneColorEffect: string;
  65775. /**
  65776. * @ignore
  65777. * The SSAO PostProcess id in the pipeline
  65778. */
  65779. SSAORenderEffect: string;
  65780. /**
  65781. * @ignore
  65782. * The horizontal blur PostProcess id in the pipeline
  65783. */
  65784. SSAOBlurHRenderEffect: string;
  65785. /**
  65786. * @ignore
  65787. * The vertical blur PostProcess id in the pipeline
  65788. */
  65789. SSAOBlurVRenderEffect: string;
  65790. /**
  65791. * @ignore
  65792. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65793. */
  65794. SSAOCombineRenderEffect: string;
  65795. /**
  65796. * The output strength of the SSAO post-process. Default value is 1.0.
  65797. */
  65798. totalStrength: number;
  65799. /**
  65800. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65801. */
  65802. maxZ: number;
  65803. /**
  65804. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65805. */
  65806. minZAspect: number;
  65807. private _samples;
  65808. /**
  65809. * Number of samples used for the SSAO calculations. Default value is 8
  65810. */
  65811. samples: number;
  65812. private _textureSamples;
  65813. /**
  65814. * Number of samples to use for antialiasing
  65815. */
  65816. textureSamples: number;
  65817. /**
  65818. * Ratio object used for SSAO ratio and blur ratio
  65819. */
  65820. private _ratio;
  65821. /**
  65822. * Dynamically generated sphere sampler.
  65823. */
  65824. private _sampleSphere;
  65825. /**
  65826. * Blur filter offsets
  65827. */
  65828. private _samplerOffsets;
  65829. private _expensiveBlur;
  65830. /**
  65831. * If bilateral blur should be used
  65832. */
  65833. expensiveBlur: boolean;
  65834. /**
  65835. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65836. */
  65837. radius: number;
  65838. /**
  65839. * The base color of the SSAO post-process
  65840. * The final result is "base + ssao" between [0, 1]
  65841. */
  65842. base: number;
  65843. /**
  65844. * Support test.
  65845. */
  65846. static readonly IsSupported: boolean;
  65847. private _scene;
  65848. private _depthTexture;
  65849. private _normalTexture;
  65850. private _randomTexture;
  65851. private _originalColorPostProcess;
  65852. private _ssaoPostProcess;
  65853. private _blurHPostProcess;
  65854. private _blurVPostProcess;
  65855. private _ssaoCombinePostProcess;
  65856. /**
  65857. * Gets active scene
  65858. */
  65859. readonly scene: Scene;
  65860. /**
  65861. * @constructor
  65862. * @param name The rendering pipeline name
  65863. * @param scene The scene linked to this pipeline
  65864. * @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 }
  65865. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65866. */
  65867. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65868. /**
  65869. * Get the class name
  65870. * @returns "SSAO2RenderingPipeline"
  65871. */
  65872. getClassName(): string;
  65873. /**
  65874. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65875. */
  65876. dispose(disableGeometryBufferRenderer?: boolean): void;
  65877. private _createBlurPostProcess;
  65878. /** @hidden */
  65879. _rebuild(): void;
  65880. private _bits;
  65881. private _radicalInverse_VdC;
  65882. private _hammersley;
  65883. private _hemisphereSample_uniform;
  65884. private _generateHemisphere;
  65885. private _createSSAOPostProcess;
  65886. private _createSSAOCombinePostProcess;
  65887. private _createRandomTexture;
  65888. /**
  65889. * Serialize the rendering pipeline (Used when exporting)
  65890. * @returns the serialized object
  65891. */
  65892. serialize(): any;
  65893. /**
  65894. * Parse the serialized pipeline
  65895. * @param source Source pipeline.
  65896. * @param scene The scene to load the pipeline to.
  65897. * @param rootUrl The URL of the serialized pipeline.
  65898. * @returns An instantiated pipeline from the serialized object.
  65899. */
  65900. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65901. }
  65902. }
  65903. declare module "babylonjs/Shaders/ssao.fragment" {
  65904. /** @hidden */
  65905. export var ssaoPixelShader: {
  65906. name: string;
  65907. shader: string;
  65908. };
  65909. }
  65910. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65911. import { Camera } from "babylonjs/Cameras/camera";
  65912. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65913. import { Scene } from "babylonjs/scene";
  65914. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65915. import "babylonjs/Shaders/ssao.fragment";
  65916. import "babylonjs/Shaders/ssaoCombine.fragment";
  65917. /**
  65918. * Render pipeline to produce ssao effect
  65919. */
  65920. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65921. /**
  65922. * @ignore
  65923. * The PassPostProcess id in the pipeline that contains the original scene color
  65924. */
  65925. SSAOOriginalSceneColorEffect: string;
  65926. /**
  65927. * @ignore
  65928. * The SSAO PostProcess id in the pipeline
  65929. */
  65930. SSAORenderEffect: string;
  65931. /**
  65932. * @ignore
  65933. * The horizontal blur PostProcess id in the pipeline
  65934. */
  65935. SSAOBlurHRenderEffect: string;
  65936. /**
  65937. * @ignore
  65938. * The vertical blur PostProcess id in the pipeline
  65939. */
  65940. SSAOBlurVRenderEffect: string;
  65941. /**
  65942. * @ignore
  65943. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65944. */
  65945. SSAOCombineRenderEffect: string;
  65946. /**
  65947. * The output strength of the SSAO post-process. Default value is 1.0.
  65948. */
  65949. totalStrength: number;
  65950. /**
  65951. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65952. */
  65953. radius: number;
  65954. /**
  65955. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65956. * Must not be equal to fallOff and superior to fallOff.
  65957. * Default value is 0.0075
  65958. */
  65959. area: number;
  65960. /**
  65961. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65962. * Must not be equal to area and inferior to area.
  65963. * Default value is 0.000001
  65964. */
  65965. fallOff: number;
  65966. /**
  65967. * The base color of the SSAO post-process
  65968. * The final result is "base + ssao" between [0, 1]
  65969. */
  65970. base: number;
  65971. private _scene;
  65972. private _depthTexture;
  65973. private _randomTexture;
  65974. private _originalColorPostProcess;
  65975. private _ssaoPostProcess;
  65976. private _blurHPostProcess;
  65977. private _blurVPostProcess;
  65978. private _ssaoCombinePostProcess;
  65979. private _firstUpdate;
  65980. /**
  65981. * Gets active scene
  65982. */
  65983. readonly scene: Scene;
  65984. /**
  65985. * @constructor
  65986. * @param name - The rendering pipeline name
  65987. * @param scene - The scene linked to this pipeline
  65988. * @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 }
  65989. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65990. */
  65991. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65992. /**
  65993. * Get the class name
  65994. * @returns "SSAORenderingPipeline"
  65995. */
  65996. getClassName(): string;
  65997. /**
  65998. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65999. */
  66000. dispose(disableDepthRender?: boolean): void;
  66001. private _createBlurPostProcess;
  66002. /** @hidden */
  66003. _rebuild(): void;
  66004. private _createSSAOPostProcess;
  66005. private _createSSAOCombinePostProcess;
  66006. private _createRandomTexture;
  66007. }
  66008. }
  66009. declare module "babylonjs/Shaders/standard.fragment" {
  66010. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66011. /** @hidden */
  66012. export var standardPixelShader: {
  66013. name: string;
  66014. shader: string;
  66015. };
  66016. }
  66017. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66018. import { Nullable } from "babylonjs/types";
  66019. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66020. import { Camera } from "babylonjs/Cameras/camera";
  66021. import { Texture } from "babylonjs/Materials/Textures/texture";
  66022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66023. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66024. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66025. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66026. import { IDisposable } from "babylonjs/scene";
  66027. import { SpotLight } from "babylonjs/Lights/spotLight";
  66028. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66029. import { Scene } from "babylonjs/scene";
  66030. import { Animation } from "babylonjs/Animations/animation";
  66031. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66032. import "babylonjs/Shaders/standard.fragment";
  66033. /**
  66034. * Standard rendering pipeline
  66035. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66036. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66037. */
  66038. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66039. /**
  66040. * Public members
  66041. */
  66042. /**
  66043. * Post-process which contains the original scene color before the pipeline applies all the effects
  66044. */
  66045. originalPostProcess: Nullable<PostProcess>;
  66046. /**
  66047. * Post-process used to down scale an image x4
  66048. */
  66049. downSampleX4PostProcess: Nullable<PostProcess>;
  66050. /**
  66051. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66052. */
  66053. brightPassPostProcess: Nullable<PostProcess>;
  66054. /**
  66055. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66056. */
  66057. blurHPostProcesses: PostProcess[];
  66058. /**
  66059. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66060. */
  66061. blurVPostProcesses: PostProcess[];
  66062. /**
  66063. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66064. */
  66065. textureAdderPostProcess: Nullable<PostProcess>;
  66066. /**
  66067. * Post-process used to create volumetric lighting effect
  66068. */
  66069. volumetricLightPostProcess: Nullable<PostProcess>;
  66070. /**
  66071. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66072. */
  66073. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66074. /**
  66075. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66076. */
  66077. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66078. /**
  66079. * Post-process used to merge the volumetric light effect and the real scene color
  66080. */
  66081. volumetricLightMergePostProces: Nullable<PostProcess>;
  66082. /**
  66083. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66084. */
  66085. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66086. /**
  66087. * Base post-process used to calculate the average luminance of the final image for HDR
  66088. */
  66089. luminancePostProcess: Nullable<PostProcess>;
  66090. /**
  66091. * Post-processes used to create down sample post-processes in order to get
  66092. * the average luminance of the final image for HDR
  66093. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66094. */
  66095. luminanceDownSamplePostProcesses: PostProcess[];
  66096. /**
  66097. * Post-process used to create a HDR effect (light adaptation)
  66098. */
  66099. hdrPostProcess: Nullable<PostProcess>;
  66100. /**
  66101. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66102. */
  66103. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66104. /**
  66105. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66106. */
  66107. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66108. /**
  66109. * Post-process used to merge the final HDR post-process and the real scene color
  66110. */
  66111. hdrFinalPostProcess: Nullable<PostProcess>;
  66112. /**
  66113. * Post-process used to create a lens flare effect
  66114. */
  66115. lensFlarePostProcess: Nullable<PostProcess>;
  66116. /**
  66117. * Post-process that merges the result of the lens flare post-process and the real scene color
  66118. */
  66119. lensFlareComposePostProcess: Nullable<PostProcess>;
  66120. /**
  66121. * Post-process used to create a motion blur effect
  66122. */
  66123. motionBlurPostProcess: Nullable<PostProcess>;
  66124. /**
  66125. * Post-process used to create a depth of field effect
  66126. */
  66127. depthOfFieldPostProcess: Nullable<PostProcess>;
  66128. /**
  66129. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66130. */
  66131. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66132. /**
  66133. * Represents the brightness threshold in order to configure the illuminated surfaces
  66134. */
  66135. brightThreshold: number;
  66136. /**
  66137. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66138. */
  66139. blurWidth: number;
  66140. /**
  66141. * Sets if the blur for highlighted surfaces must be only horizontal
  66142. */
  66143. horizontalBlur: boolean;
  66144. /**
  66145. * Gets the overall exposure used by the pipeline
  66146. */
  66147. /**
  66148. * Sets the overall exposure used by the pipeline
  66149. */
  66150. exposure: number;
  66151. /**
  66152. * Texture used typically to simulate "dirty" on camera lens
  66153. */
  66154. lensTexture: Nullable<Texture>;
  66155. /**
  66156. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66157. */
  66158. volumetricLightCoefficient: number;
  66159. /**
  66160. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66161. */
  66162. volumetricLightPower: number;
  66163. /**
  66164. * Used the set the blur intensity to smooth the volumetric lights
  66165. */
  66166. volumetricLightBlurScale: number;
  66167. /**
  66168. * Light (spot or directional) used to generate the volumetric lights rays
  66169. * The source light must have a shadow generate so the pipeline can get its
  66170. * depth map
  66171. */
  66172. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66173. /**
  66174. * For eye adaptation, represents the minimum luminance the eye can see
  66175. */
  66176. hdrMinimumLuminance: number;
  66177. /**
  66178. * For eye adaptation, represents the decrease luminance speed
  66179. */
  66180. hdrDecreaseRate: number;
  66181. /**
  66182. * For eye adaptation, represents the increase luminance speed
  66183. */
  66184. hdrIncreaseRate: number;
  66185. /**
  66186. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66187. */
  66188. /**
  66189. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66190. */
  66191. hdrAutoExposure: boolean;
  66192. /**
  66193. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66194. */
  66195. lensColorTexture: Nullable<Texture>;
  66196. /**
  66197. * The overall strengh for the lens flare effect
  66198. */
  66199. lensFlareStrength: number;
  66200. /**
  66201. * Dispersion coefficient for lens flare ghosts
  66202. */
  66203. lensFlareGhostDispersal: number;
  66204. /**
  66205. * Main lens flare halo width
  66206. */
  66207. lensFlareHaloWidth: number;
  66208. /**
  66209. * Based on the lens distortion effect, defines how much the lens flare result
  66210. * is distorted
  66211. */
  66212. lensFlareDistortionStrength: number;
  66213. /**
  66214. * Configures the blur intensity used for for lens flare (halo)
  66215. */
  66216. lensFlareBlurWidth: number;
  66217. /**
  66218. * Lens star texture must be used to simulate rays on the flares and is available
  66219. * in the documentation
  66220. */
  66221. lensStarTexture: Nullable<Texture>;
  66222. /**
  66223. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66224. * flare effect by taking account of the dirt texture
  66225. */
  66226. lensFlareDirtTexture: Nullable<Texture>;
  66227. /**
  66228. * Represents the focal length for the depth of field effect
  66229. */
  66230. depthOfFieldDistance: number;
  66231. /**
  66232. * Represents the blur intensity for the blurred part of the depth of field effect
  66233. */
  66234. depthOfFieldBlurWidth: number;
  66235. /**
  66236. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66237. */
  66238. /**
  66239. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66240. */
  66241. motionStrength: number;
  66242. /**
  66243. * Gets wether or not the motion blur post-process is object based or screen based.
  66244. */
  66245. /**
  66246. * Sets wether or not the motion blur post-process should be object based or screen based
  66247. */
  66248. objectBasedMotionBlur: boolean;
  66249. /**
  66250. * List of animations for the pipeline (IAnimatable implementation)
  66251. */
  66252. animations: Animation[];
  66253. /**
  66254. * Private members
  66255. */
  66256. private _scene;
  66257. private _currentDepthOfFieldSource;
  66258. private _basePostProcess;
  66259. private _fixedExposure;
  66260. private _currentExposure;
  66261. private _hdrAutoExposure;
  66262. private _hdrCurrentLuminance;
  66263. private _motionStrength;
  66264. private _isObjectBasedMotionBlur;
  66265. private _floatTextureType;
  66266. private _camerasToBeAttached;
  66267. private _ratio;
  66268. private _bloomEnabled;
  66269. private _depthOfFieldEnabled;
  66270. private _vlsEnabled;
  66271. private _lensFlareEnabled;
  66272. private _hdrEnabled;
  66273. private _motionBlurEnabled;
  66274. private _fxaaEnabled;
  66275. private _motionBlurSamples;
  66276. private _volumetricLightStepsCount;
  66277. private _samples;
  66278. /**
  66279. * @ignore
  66280. * Specifies if the bloom pipeline is enabled
  66281. */
  66282. BloomEnabled: boolean;
  66283. /**
  66284. * @ignore
  66285. * Specifies if the depth of field pipeline is enabed
  66286. */
  66287. DepthOfFieldEnabled: boolean;
  66288. /**
  66289. * @ignore
  66290. * Specifies if the lens flare pipeline is enabed
  66291. */
  66292. LensFlareEnabled: boolean;
  66293. /**
  66294. * @ignore
  66295. * Specifies if the HDR pipeline is enabled
  66296. */
  66297. HDREnabled: boolean;
  66298. /**
  66299. * @ignore
  66300. * Specifies if the volumetric lights scattering effect is enabled
  66301. */
  66302. VLSEnabled: boolean;
  66303. /**
  66304. * @ignore
  66305. * Specifies if the motion blur effect is enabled
  66306. */
  66307. MotionBlurEnabled: boolean;
  66308. /**
  66309. * Specifies if anti-aliasing is enabled
  66310. */
  66311. fxaaEnabled: boolean;
  66312. /**
  66313. * Specifies the number of steps used to calculate the volumetric lights
  66314. * Typically in interval [50, 200]
  66315. */
  66316. volumetricLightStepsCount: number;
  66317. /**
  66318. * Specifies the number of samples used for the motion blur effect
  66319. * Typically in interval [16, 64]
  66320. */
  66321. motionBlurSamples: number;
  66322. /**
  66323. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66324. */
  66325. samples: number;
  66326. /**
  66327. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66328. * @constructor
  66329. * @param name The rendering pipeline name
  66330. * @param scene The scene linked to this pipeline
  66331. * @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)
  66332. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66334. */
  66335. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66336. private _buildPipeline;
  66337. private _createDownSampleX4PostProcess;
  66338. private _createBrightPassPostProcess;
  66339. private _createBlurPostProcesses;
  66340. private _createTextureAdderPostProcess;
  66341. private _createVolumetricLightPostProcess;
  66342. private _createLuminancePostProcesses;
  66343. private _createHdrPostProcess;
  66344. private _createLensFlarePostProcess;
  66345. private _createDepthOfFieldPostProcess;
  66346. private _createMotionBlurPostProcess;
  66347. private _getDepthTexture;
  66348. private _disposePostProcesses;
  66349. /**
  66350. * Dispose of the pipeline and stop all post processes
  66351. */
  66352. dispose(): void;
  66353. /**
  66354. * Serialize the rendering pipeline (Used when exporting)
  66355. * @returns the serialized object
  66356. */
  66357. serialize(): any;
  66358. /**
  66359. * Parse the serialized pipeline
  66360. * @param source Source pipeline.
  66361. * @param scene The scene to load the pipeline to.
  66362. * @param rootUrl The URL of the serialized pipeline.
  66363. * @returns An instantiated pipeline from the serialized object.
  66364. */
  66365. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66366. /**
  66367. * Luminance steps
  66368. */
  66369. static LuminanceSteps: number;
  66370. }
  66371. }
  66372. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66373. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66374. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66375. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66376. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66377. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66378. }
  66379. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66380. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66381. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66382. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66383. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66384. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66385. }
  66386. declare module "babylonjs/Shaders/tonemap.fragment" {
  66387. /** @hidden */
  66388. export var tonemapPixelShader: {
  66389. name: string;
  66390. shader: string;
  66391. };
  66392. }
  66393. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66394. import { Camera } from "babylonjs/Cameras/camera";
  66395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66396. import "babylonjs/Shaders/tonemap.fragment";
  66397. import { Engine } from "babylonjs/Engines/engine";
  66398. /** Defines operator used for tonemapping */
  66399. export enum TonemappingOperator {
  66400. /** Hable */
  66401. Hable = 0,
  66402. /** Reinhard */
  66403. Reinhard = 1,
  66404. /** HejiDawson */
  66405. HejiDawson = 2,
  66406. /** Photographic */
  66407. Photographic = 3
  66408. }
  66409. /**
  66410. * Defines a post process to apply tone mapping
  66411. */
  66412. export class TonemapPostProcess extends PostProcess {
  66413. private _operator;
  66414. /** Defines the required exposure adjustement */
  66415. exposureAdjustment: number;
  66416. /**
  66417. * Creates a new TonemapPostProcess
  66418. * @param name defines the name of the postprocess
  66419. * @param _operator defines the operator to use
  66420. * @param exposureAdjustment defines the required exposure adjustement
  66421. * @param camera defines the camera to use (can be null)
  66422. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66423. * @param engine defines the hosting engine (can be ignore if camera is set)
  66424. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66425. */
  66426. constructor(name: string, _operator: TonemappingOperator,
  66427. /** Defines the required exposure adjustement */
  66428. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66429. }
  66430. }
  66431. declare module "babylonjs/Shaders/depth.vertex" {
  66432. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66434. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66435. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66439. /** @hidden */
  66440. export var depthVertexShader: {
  66441. name: string;
  66442. shader: string;
  66443. };
  66444. }
  66445. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66446. /** @hidden */
  66447. export var volumetricLightScatteringPixelShader: {
  66448. name: string;
  66449. shader: string;
  66450. };
  66451. }
  66452. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66455. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66458. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66459. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66460. /** @hidden */
  66461. export var volumetricLightScatteringPassVertexShader: {
  66462. name: string;
  66463. shader: string;
  66464. };
  66465. }
  66466. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66467. /** @hidden */
  66468. export var volumetricLightScatteringPassPixelShader: {
  66469. name: string;
  66470. shader: string;
  66471. };
  66472. }
  66473. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66474. import { Vector3 } from "babylonjs/Maths/math.vector";
  66475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66476. import { Mesh } from "babylonjs/Meshes/mesh";
  66477. import { Camera } from "babylonjs/Cameras/camera";
  66478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66479. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66480. import { Scene } from "babylonjs/scene";
  66481. import "babylonjs/Meshes/Builders/planeBuilder";
  66482. import "babylonjs/Shaders/depth.vertex";
  66483. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66484. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66485. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66486. import { Engine } from "babylonjs/Engines/engine";
  66487. /**
  66488. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66489. */
  66490. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66491. private _volumetricLightScatteringPass;
  66492. private _volumetricLightScatteringRTT;
  66493. private _viewPort;
  66494. private _screenCoordinates;
  66495. private _cachedDefines;
  66496. /**
  66497. * If not undefined, the mesh position is computed from the attached node position
  66498. */
  66499. attachedNode: {
  66500. position: Vector3;
  66501. };
  66502. /**
  66503. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66504. */
  66505. customMeshPosition: Vector3;
  66506. /**
  66507. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66508. */
  66509. useCustomMeshPosition: boolean;
  66510. /**
  66511. * If the post-process should inverse the light scattering direction
  66512. */
  66513. invert: boolean;
  66514. /**
  66515. * The internal mesh used by the post-process
  66516. */
  66517. mesh: Mesh;
  66518. /**
  66519. * @hidden
  66520. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66521. */
  66522. useDiffuseColor: boolean;
  66523. /**
  66524. * Array containing the excluded meshes not rendered in the internal pass
  66525. */
  66526. excludedMeshes: AbstractMesh[];
  66527. /**
  66528. * Controls the overall intensity of the post-process
  66529. */
  66530. exposure: number;
  66531. /**
  66532. * Dissipates each sample's contribution in range [0, 1]
  66533. */
  66534. decay: number;
  66535. /**
  66536. * Controls the overall intensity of each sample
  66537. */
  66538. weight: number;
  66539. /**
  66540. * Controls the density of each sample
  66541. */
  66542. density: number;
  66543. /**
  66544. * @constructor
  66545. * @param name The post-process name
  66546. * @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)
  66547. * @param camera The camera that the post-process will be attached to
  66548. * @param mesh The mesh used to create the light scattering
  66549. * @param samples The post-process quality, default 100
  66550. * @param samplingModeThe post-process filtering mode
  66551. * @param engine The babylon engine
  66552. * @param reusable If the post-process is reusable
  66553. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66554. */
  66555. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66556. /**
  66557. * Returns the string "VolumetricLightScatteringPostProcess"
  66558. * @returns "VolumetricLightScatteringPostProcess"
  66559. */
  66560. getClassName(): string;
  66561. private _isReady;
  66562. /**
  66563. * Sets the new light position for light scattering effect
  66564. * @param position The new custom light position
  66565. */
  66566. setCustomMeshPosition(position: Vector3): void;
  66567. /**
  66568. * Returns the light position for light scattering effect
  66569. * @return Vector3 The custom light position
  66570. */
  66571. getCustomMeshPosition(): Vector3;
  66572. /**
  66573. * Disposes the internal assets and detaches the post-process from the camera
  66574. */
  66575. dispose(camera: Camera): void;
  66576. /**
  66577. * Returns the render target texture used by the post-process
  66578. * @return the render target texture used by the post-process
  66579. */
  66580. getPass(): RenderTargetTexture;
  66581. private _meshExcluded;
  66582. private _createPass;
  66583. private _updateMeshScreenCoordinates;
  66584. /**
  66585. * Creates a default mesh for the Volumeric Light Scattering post-process
  66586. * @param name The mesh name
  66587. * @param scene The scene where to create the mesh
  66588. * @return the default mesh
  66589. */
  66590. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66591. }
  66592. }
  66593. declare module "babylonjs/PostProcesses/index" {
  66594. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66595. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66596. export * from "babylonjs/PostProcesses/bloomEffect";
  66597. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66598. export * from "babylonjs/PostProcesses/blurPostProcess";
  66599. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66600. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66601. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66602. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66603. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66604. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66605. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66606. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66607. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66608. export * from "babylonjs/PostProcesses/filterPostProcess";
  66609. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66610. export * from "babylonjs/PostProcesses/grainPostProcess";
  66611. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66612. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66613. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66614. export * from "babylonjs/PostProcesses/passPostProcess";
  66615. export * from "babylonjs/PostProcesses/postProcess";
  66616. export * from "babylonjs/PostProcesses/postProcessManager";
  66617. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66618. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66619. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66620. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66621. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66622. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66623. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66624. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66625. }
  66626. declare module "babylonjs/Probes/index" {
  66627. export * from "babylonjs/Probes/reflectionProbe";
  66628. }
  66629. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66630. import { Scene } from "babylonjs/scene";
  66631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66632. import { SmartArray } from "babylonjs/Misc/smartArray";
  66633. import { ISceneComponent } from "babylonjs/sceneComponent";
  66634. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66635. import "babylonjs/Meshes/Builders/boxBuilder";
  66636. import "babylonjs/Shaders/color.fragment";
  66637. import "babylonjs/Shaders/color.vertex";
  66638. import { Color3 } from "babylonjs/Maths/math.color";
  66639. module "babylonjs/scene" {
  66640. interface Scene {
  66641. /** @hidden (Backing field) */
  66642. _boundingBoxRenderer: BoundingBoxRenderer;
  66643. /** @hidden (Backing field) */
  66644. _forceShowBoundingBoxes: boolean;
  66645. /**
  66646. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66647. */
  66648. forceShowBoundingBoxes: boolean;
  66649. /**
  66650. * Gets the bounding box renderer associated with the scene
  66651. * @returns a BoundingBoxRenderer
  66652. */
  66653. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66654. }
  66655. }
  66656. module "babylonjs/Meshes/abstractMesh" {
  66657. interface AbstractMesh {
  66658. /** @hidden (Backing field) */
  66659. _showBoundingBox: boolean;
  66660. /**
  66661. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66662. */
  66663. showBoundingBox: boolean;
  66664. }
  66665. }
  66666. /**
  66667. * Component responsible of rendering the bounding box of the meshes in a scene.
  66668. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66669. */
  66670. export class BoundingBoxRenderer implements ISceneComponent {
  66671. /**
  66672. * The component name helpfull to identify the component in the list of scene components.
  66673. */
  66674. readonly name: string;
  66675. /**
  66676. * The scene the component belongs to.
  66677. */
  66678. scene: Scene;
  66679. /**
  66680. * Color of the bounding box lines placed in front of an object
  66681. */
  66682. frontColor: Color3;
  66683. /**
  66684. * Color of the bounding box lines placed behind an object
  66685. */
  66686. backColor: Color3;
  66687. /**
  66688. * Defines if the renderer should show the back lines or not
  66689. */
  66690. showBackLines: boolean;
  66691. /**
  66692. * @hidden
  66693. */
  66694. renderList: SmartArray<BoundingBox>;
  66695. private _colorShader;
  66696. private _vertexBuffers;
  66697. private _indexBuffer;
  66698. private _fillIndexBuffer;
  66699. private _fillIndexData;
  66700. /**
  66701. * Instantiates a new bounding box renderer in a scene.
  66702. * @param scene the scene the renderer renders in
  66703. */
  66704. constructor(scene: Scene);
  66705. /**
  66706. * Registers the component in a given scene
  66707. */
  66708. register(): void;
  66709. private _evaluateSubMesh;
  66710. private _activeMesh;
  66711. private _prepareRessources;
  66712. private _createIndexBuffer;
  66713. /**
  66714. * Rebuilds the elements related to this component in case of
  66715. * context lost for instance.
  66716. */
  66717. rebuild(): void;
  66718. /**
  66719. * @hidden
  66720. */
  66721. reset(): void;
  66722. /**
  66723. * Render the bounding boxes of a specific rendering group
  66724. * @param renderingGroupId defines the rendering group to render
  66725. */
  66726. render(renderingGroupId: number): void;
  66727. /**
  66728. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66729. * @param mesh Define the mesh to render the occlusion bounding box for
  66730. */
  66731. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66732. /**
  66733. * Dispose and release the resources attached to this renderer.
  66734. */
  66735. dispose(): void;
  66736. }
  66737. }
  66738. declare module "babylonjs/Shaders/depth.fragment" {
  66739. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66740. /** @hidden */
  66741. export var depthPixelShader: {
  66742. name: string;
  66743. shader: string;
  66744. };
  66745. }
  66746. declare module "babylonjs/Rendering/depthRenderer" {
  66747. import { Nullable } from "babylonjs/types";
  66748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66749. import { Scene } from "babylonjs/scene";
  66750. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66751. import { Camera } from "babylonjs/Cameras/camera";
  66752. import "babylonjs/Shaders/depth.fragment";
  66753. import "babylonjs/Shaders/depth.vertex";
  66754. /**
  66755. * This represents a depth renderer in Babylon.
  66756. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66757. */
  66758. export class DepthRenderer {
  66759. private _scene;
  66760. private _depthMap;
  66761. private _effect;
  66762. private readonly _storeNonLinearDepth;
  66763. private readonly _clearColor;
  66764. /** Get if the depth renderer is using packed depth or not */
  66765. readonly isPacked: boolean;
  66766. private _cachedDefines;
  66767. private _camera;
  66768. /**
  66769. * Specifiess that the depth renderer will only be used within
  66770. * the camera it is created for.
  66771. * This can help forcing its rendering during the camera processing.
  66772. */
  66773. useOnlyInActiveCamera: boolean;
  66774. /** @hidden */
  66775. static _SceneComponentInitialization: (scene: Scene) => void;
  66776. /**
  66777. * Instantiates a depth renderer
  66778. * @param scene The scene the renderer belongs to
  66779. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66780. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66781. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66782. */
  66783. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66784. /**
  66785. * Creates the depth rendering effect and checks if the effect is ready.
  66786. * @param subMesh The submesh to be used to render the depth map of
  66787. * @param useInstances If multiple world instances should be used
  66788. * @returns if the depth renderer is ready to render the depth map
  66789. */
  66790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66791. /**
  66792. * Gets the texture which the depth map will be written to.
  66793. * @returns The depth map texture
  66794. */
  66795. getDepthMap(): RenderTargetTexture;
  66796. /**
  66797. * Disposes of the depth renderer.
  66798. */
  66799. dispose(): void;
  66800. }
  66801. }
  66802. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66803. import { Nullable } from "babylonjs/types";
  66804. import { Scene } from "babylonjs/scene";
  66805. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66806. import { Camera } from "babylonjs/Cameras/camera";
  66807. import { ISceneComponent } from "babylonjs/sceneComponent";
  66808. module "babylonjs/scene" {
  66809. interface Scene {
  66810. /** @hidden (Backing field) */
  66811. _depthRenderer: {
  66812. [id: string]: DepthRenderer;
  66813. };
  66814. /**
  66815. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66816. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66817. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66818. * @returns the created depth renderer
  66819. */
  66820. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66821. /**
  66822. * Disables a depth renderer for a given camera
  66823. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66824. */
  66825. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66826. }
  66827. }
  66828. /**
  66829. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66830. * in several rendering techniques.
  66831. */
  66832. export class DepthRendererSceneComponent implements ISceneComponent {
  66833. /**
  66834. * The component name helpfull to identify the component in the list of scene components.
  66835. */
  66836. readonly name: string;
  66837. /**
  66838. * The scene the component belongs to.
  66839. */
  66840. scene: Scene;
  66841. /**
  66842. * Creates a new instance of the component for the given scene
  66843. * @param scene Defines the scene to register the component in
  66844. */
  66845. constructor(scene: Scene);
  66846. /**
  66847. * Registers the component in a given scene
  66848. */
  66849. register(): void;
  66850. /**
  66851. * Rebuilds the elements related to this component in case of
  66852. * context lost for instance.
  66853. */
  66854. rebuild(): void;
  66855. /**
  66856. * Disposes the component and the associated ressources
  66857. */
  66858. dispose(): void;
  66859. private _gatherRenderTargets;
  66860. private _gatherActiveCameraRenderTargets;
  66861. }
  66862. }
  66863. declare module "babylonjs/Shaders/outline.fragment" {
  66864. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66865. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66866. /** @hidden */
  66867. export var outlinePixelShader: {
  66868. name: string;
  66869. shader: string;
  66870. };
  66871. }
  66872. declare module "babylonjs/Shaders/outline.vertex" {
  66873. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66874. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66875. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66876. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66877. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66878. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66879. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66880. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66881. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66882. /** @hidden */
  66883. export var outlineVertexShader: {
  66884. name: string;
  66885. shader: string;
  66886. };
  66887. }
  66888. declare module "babylonjs/Rendering/outlineRenderer" {
  66889. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66890. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66891. import { Scene } from "babylonjs/scene";
  66892. import { ISceneComponent } from "babylonjs/sceneComponent";
  66893. import "babylonjs/Shaders/outline.fragment";
  66894. import "babylonjs/Shaders/outline.vertex";
  66895. module "babylonjs/scene" {
  66896. interface Scene {
  66897. /** @hidden */
  66898. _outlineRenderer: OutlineRenderer;
  66899. /**
  66900. * Gets the outline renderer associated with the scene
  66901. * @returns a OutlineRenderer
  66902. */
  66903. getOutlineRenderer(): OutlineRenderer;
  66904. }
  66905. }
  66906. module "babylonjs/Meshes/abstractMesh" {
  66907. interface AbstractMesh {
  66908. /** @hidden (Backing field) */
  66909. _renderOutline: boolean;
  66910. /**
  66911. * Gets or sets a boolean indicating if the outline must be rendered as well
  66912. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66913. */
  66914. renderOutline: boolean;
  66915. /** @hidden (Backing field) */
  66916. _renderOverlay: boolean;
  66917. /**
  66918. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66919. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66920. */
  66921. renderOverlay: boolean;
  66922. }
  66923. }
  66924. /**
  66925. * This class is responsible to draw bothe outline/overlay of meshes.
  66926. * It should not be used directly but through the available method on mesh.
  66927. */
  66928. export class OutlineRenderer implements ISceneComponent {
  66929. /**
  66930. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66931. */
  66932. private static _StencilReference;
  66933. /**
  66934. * The name of the component. Each component must have a unique name.
  66935. */
  66936. name: string;
  66937. /**
  66938. * The scene the component belongs to.
  66939. */
  66940. scene: Scene;
  66941. /**
  66942. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66943. */
  66944. zOffset: number;
  66945. private _engine;
  66946. private _effect;
  66947. private _cachedDefines;
  66948. private _savedDepthWrite;
  66949. /**
  66950. * Instantiates a new outline renderer. (There could be only one per scene).
  66951. * @param scene Defines the scene it belongs to
  66952. */
  66953. constructor(scene: Scene);
  66954. /**
  66955. * Register the component to one instance of a scene.
  66956. */
  66957. register(): void;
  66958. /**
  66959. * Rebuilds the elements related to this component in case of
  66960. * context lost for instance.
  66961. */
  66962. rebuild(): void;
  66963. /**
  66964. * Disposes the component and the associated ressources.
  66965. */
  66966. dispose(): void;
  66967. /**
  66968. * Renders the outline in the canvas.
  66969. * @param subMesh Defines the sumesh to render
  66970. * @param batch Defines the batch of meshes in case of instances
  66971. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66972. */
  66973. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66974. /**
  66975. * Returns whether or not the outline renderer is ready for a given submesh.
  66976. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66977. * @param subMesh Defines the submesh to check readyness for
  66978. * @param useInstances Defines wheter wee are trying to render instances or not
  66979. * @returns true if ready otherwise false
  66980. */
  66981. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66982. private _beforeRenderingMesh;
  66983. private _afterRenderingMesh;
  66984. }
  66985. }
  66986. declare module "babylonjs/Rendering/index" {
  66987. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66988. export * from "babylonjs/Rendering/depthRenderer";
  66989. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66990. export * from "babylonjs/Rendering/edgesRenderer";
  66991. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66992. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66993. export * from "babylonjs/Rendering/outlineRenderer";
  66994. export * from "babylonjs/Rendering/renderingGroup";
  66995. export * from "babylonjs/Rendering/renderingManager";
  66996. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66997. }
  66998. declare module "babylonjs/Sprites/spritePackedManager" {
  66999. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67000. import { Scene } from "babylonjs/scene";
  67001. /**
  67002. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67003. * @see http://doc.babylonjs.com/babylon101/sprites
  67004. */
  67005. export class SpritePackedManager extends SpriteManager {
  67006. /** defines the packed manager's name */
  67007. name: string;
  67008. /**
  67009. * Creates a new sprite manager from a packed sprite sheet
  67010. * @param name defines the manager's name
  67011. * @param imgUrl defines the sprite sheet url
  67012. * @param capacity defines the maximum allowed number of sprites
  67013. * @param scene defines the hosting scene
  67014. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67015. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67016. * @param samplingMode defines the smapling mode to use with spritesheet
  67017. * @param fromPacked set to true; do not alter
  67018. */
  67019. constructor(
  67020. /** defines the packed manager's name */
  67021. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67022. }
  67023. }
  67024. declare module "babylonjs/Sprites/index" {
  67025. export * from "babylonjs/Sprites/sprite";
  67026. export * from "babylonjs/Sprites/spriteManager";
  67027. export * from "babylonjs/Sprites/spritePackedManager";
  67028. export * from "babylonjs/Sprites/spriteSceneComponent";
  67029. }
  67030. declare module "babylonjs/States/index" {
  67031. export * from "babylonjs/States/alphaCullingState";
  67032. export * from "babylonjs/States/depthCullingState";
  67033. export * from "babylonjs/States/stencilState";
  67034. }
  67035. declare module "babylonjs/Misc/assetsManager" {
  67036. import { Scene } from "babylonjs/scene";
  67037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67038. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67039. import { Skeleton } from "babylonjs/Bones/skeleton";
  67040. import { Observable } from "babylonjs/Misc/observable";
  67041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67042. import { Texture } from "babylonjs/Materials/Textures/texture";
  67043. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67044. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67045. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67046. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67047. /**
  67048. * Defines the list of states available for a task inside a AssetsManager
  67049. */
  67050. export enum AssetTaskState {
  67051. /**
  67052. * Initialization
  67053. */
  67054. INIT = 0,
  67055. /**
  67056. * Running
  67057. */
  67058. RUNNING = 1,
  67059. /**
  67060. * Done
  67061. */
  67062. DONE = 2,
  67063. /**
  67064. * Error
  67065. */
  67066. ERROR = 3
  67067. }
  67068. /**
  67069. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67070. */
  67071. export abstract class AbstractAssetTask {
  67072. /**
  67073. * Task name
  67074. */ name: string;
  67075. /**
  67076. * Callback called when the task is successful
  67077. */
  67078. onSuccess: (task: any) => void;
  67079. /**
  67080. * Callback called when the task is not successful
  67081. */
  67082. onError: (task: any, message?: string, exception?: any) => void;
  67083. /**
  67084. * Creates a new AssetsManager
  67085. * @param name defines the name of the task
  67086. */
  67087. constructor(
  67088. /**
  67089. * Task name
  67090. */ name: string);
  67091. private _isCompleted;
  67092. private _taskState;
  67093. private _errorObject;
  67094. /**
  67095. * Get if the task is completed
  67096. */
  67097. readonly isCompleted: boolean;
  67098. /**
  67099. * Gets the current state of the task
  67100. */
  67101. readonly taskState: AssetTaskState;
  67102. /**
  67103. * Gets the current error object (if task is in error)
  67104. */
  67105. readonly errorObject: {
  67106. message?: string;
  67107. exception?: any;
  67108. };
  67109. /**
  67110. * Internal only
  67111. * @hidden
  67112. */
  67113. _setErrorObject(message?: string, exception?: any): void;
  67114. /**
  67115. * Execute the current task
  67116. * @param scene defines the scene where you want your assets to be loaded
  67117. * @param onSuccess is a callback called when the task is successfully executed
  67118. * @param onError is a callback called if an error occurs
  67119. */
  67120. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67121. /**
  67122. * Execute the current task
  67123. * @param scene defines the scene where you want your assets to be loaded
  67124. * @param onSuccess is a callback called when the task is successfully executed
  67125. * @param onError is a callback called if an error occurs
  67126. */
  67127. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67128. /**
  67129. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67130. * This can be used with failed tasks that have the reason for failure fixed.
  67131. */
  67132. reset(): void;
  67133. private onErrorCallback;
  67134. private onDoneCallback;
  67135. }
  67136. /**
  67137. * Define the interface used by progress events raised during assets loading
  67138. */
  67139. export interface IAssetsProgressEvent {
  67140. /**
  67141. * Defines the number of remaining tasks to process
  67142. */
  67143. remainingCount: number;
  67144. /**
  67145. * Defines the total number of tasks
  67146. */
  67147. totalCount: number;
  67148. /**
  67149. * Defines the task that was just processed
  67150. */
  67151. task: AbstractAssetTask;
  67152. }
  67153. /**
  67154. * Class used to share progress information about assets loading
  67155. */
  67156. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67157. /**
  67158. * Defines the number of remaining tasks to process
  67159. */
  67160. remainingCount: number;
  67161. /**
  67162. * Defines the total number of tasks
  67163. */
  67164. totalCount: number;
  67165. /**
  67166. * Defines the task that was just processed
  67167. */
  67168. task: AbstractAssetTask;
  67169. /**
  67170. * Creates a AssetsProgressEvent
  67171. * @param remainingCount defines the number of remaining tasks to process
  67172. * @param totalCount defines the total number of tasks
  67173. * @param task defines the task that was just processed
  67174. */
  67175. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67176. }
  67177. /**
  67178. * Define a task used by AssetsManager to load meshes
  67179. */
  67180. export class MeshAssetTask extends AbstractAssetTask {
  67181. /**
  67182. * Defines the name of the task
  67183. */
  67184. name: string;
  67185. /**
  67186. * Defines the list of mesh's names you want to load
  67187. */
  67188. meshesNames: any;
  67189. /**
  67190. * Defines the root url to use as a base to load your meshes and associated resources
  67191. */
  67192. rootUrl: string;
  67193. /**
  67194. * Defines the filename of the scene to load from
  67195. */
  67196. sceneFilename: string;
  67197. /**
  67198. * Gets the list of loaded meshes
  67199. */
  67200. loadedMeshes: Array<AbstractMesh>;
  67201. /**
  67202. * Gets the list of loaded particle systems
  67203. */
  67204. loadedParticleSystems: Array<IParticleSystem>;
  67205. /**
  67206. * Gets the list of loaded skeletons
  67207. */
  67208. loadedSkeletons: Array<Skeleton>;
  67209. /**
  67210. * Gets the list of loaded animation groups
  67211. */
  67212. loadedAnimationGroups: Array<AnimationGroup>;
  67213. /**
  67214. * Callback called when the task is successful
  67215. */
  67216. onSuccess: (task: MeshAssetTask) => void;
  67217. /**
  67218. * Callback called when the task is successful
  67219. */
  67220. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67221. /**
  67222. * Creates a new MeshAssetTask
  67223. * @param name defines the name of the task
  67224. * @param meshesNames defines the list of mesh's names you want to load
  67225. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67226. * @param sceneFilename defines the filename of the scene to load from
  67227. */
  67228. constructor(
  67229. /**
  67230. * Defines the name of the task
  67231. */
  67232. name: string,
  67233. /**
  67234. * Defines the list of mesh's names you want to load
  67235. */
  67236. meshesNames: any,
  67237. /**
  67238. * Defines the root url to use as a base to load your meshes and associated resources
  67239. */
  67240. rootUrl: string,
  67241. /**
  67242. * Defines the filename of the scene to load from
  67243. */
  67244. sceneFilename: string);
  67245. /**
  67246. * Execute the current task
  67247. * @param scene defines the scene where you want your assets to be loaded
  67248. * @param onSuccess is a callback called when the task is successfully executed
  67249. * @param onError is a callback called if an error occurs
  67250. */
  67251. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67252. }
  67253. /**
  67254. * Define a task used by AssetsManager to load text content
  67255. */
  67256. export class TextFileAssetTask extends AbstractAssetTask {
  67257. /**
  67258. * Defines the name of the task
  67259. */
  67260. name: string;
  67261. /**
  67262. * Defines the location of the file to load
  67263. */
  67264. url: string;
  67265. /**
  67266. * Gets the loaded text string
  67267. */
  67268. text: string;
  67269. /**
  67270. * Callback called when the task is successful
  67271. */
  67272. onSuccess: (task: TextFileAssetTask) => void;
  67273. /**
  67274. * Callback called when the task is successful
  67275. */
  67276. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67277. /**
  67278. * Creates a new TextFileAssetTask object
  67279. * @param name defines the name of the task
  67280. * @param url defines the location of the file to load
  67281. */
  67282. constructor(
  67283. /**
  67284. * Defines the name of the task
  67285. */
  67286. name: string,
  67287. /**
  67288. * Defines the location of the file to load
  67289. */
  67290. url: string);
  67291. /**
  67292. * Execute the current task
  67293. * @param scene defines the scene where you want your assets to be loaded
  67294. * @param onSuccess is a callback called when the task is successfully executed
  67295. * @param onError is a callback called if an error occurs
  67296. */
  67297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67298. }
  67299. /**
  67300. * Define a task used by AssetsManager to load binary data
  67301. */
  67302. export class BinaryFileAssetTask extends AbstractAssetTask {
  67303. /**
  67304. * Defines the name of the task
  67305. */
  67306. name: string;
  67307. /**
  67308. * Defines the location of the file to load
  67309. */
  67310. url: string;
  67311. /**
  67312. * Gets the lodaded data (as an array buffer)
  67313. */
  67314. data: ArrayBuffer;
  67315. /**
  67316. * Callback called when the task is successful
  67317. */
  67318. onSuccess: (task: BinaryFileAssetTask) => void;
  67319. /**
  67320. * Callback called when the task is successful
  67321. */
  67322. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67323. /**
  67324. * Creates a new BinaryFileAssetTask object
  67325. * @param name defines the name of the new task
  67326. * @param url defines the location of the file to load
  67327. */
  67328. constructor(
  67329. /**
  67330. * Defines the name of the task
  67331. */
  67332. name: string,
  67333. /**
  67334. * Defines the location of the file to load
  67335. */
  67336. url: string);
  67337. /**
  67338. * Execute the current task
  67339. * @param scene defines the scene where you want your assets to be loaded
  67340. * @param onSuccess is a callback called when the task is successfully executed
  67341. * @param onError is a callback called if an error occurs
  67342. */
  67343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67344. }
  67345. /**
  67346. * Define a task used by AssetsManager to load images
  67347. */
  67348. export class ImageAssetTask extends AbstractAssetTask {
  67349. /**
  67350. * Defines the name of the task
  67351. */
  67352. name: string;
  67353. /**
  67354. * Defines the location of the image to load
  67355. */
  67356. url: string;
  67357. /**
  67358. * Gets the loaded images
  67359. */
  67360. image: HTMLImageElement;
  67361. /**
  67362. * Callback called when the task is successful
  67363. */
  67364. onSuccess: (task: ImageAssetTask) => void;
  67365. /**
  67366. * Callback called when the task is successful
  67367. */
  67368. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67369. /**
  67370. * Creates a new ImageAssetTask
  67371. * @param name defines the name of the task
  67372. * @param url defines the location of the image to load
  67373. */
  67374. constructor(
  67375. /**
  67376. * Defines the name of the task
  67377. */
  67378. name: string,
  67379. /**
  67380. * Defines the location of the image to load
  67381. */
  67382. url: string);
  67383. /**
  67384. * Execute the current task
  67385. * @param scene defines the scene where you want your assets to be loaded
  67386. * @param onSuccess is a callback called when the task is successfully executed
  67387. * @param onError is a callback called if an error occurs
  67388. */
  67389. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67390. }
  67391. /**
  67392. * Defines the interface used by texture loading tasks
  67393. */
  67394. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67395. /**
  67396. * Gets the loaded texture
  67397. */
  67398. texture: TEX;
  67399. }
  67400. /**
  67401. * Define a task used by AssetsManager to load 2D textures
  67402. */
  67403. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67404. /**
  67405. * Defines the name of the task
  67406. */
  67407. name: string;
  67408. /**
  67409. * Defines the location of the file to load
  67410. */
  67411. url: string;
  67412. /**
  67413. * Defines if mipmap should not be generated (default is false)
  67414. */
  67415. noMipmap?: boolean | undefined;
  67416. /**
  67417. * Defines if texture must be inverted on Y axis (default is false)
  67418. */
  67419. invertY?: boolean | undefined;
  67420. /**
  67421. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67422. */
  67423. samplingMode: number;
  67424. /**
  67425. * Gets the loaded texture
  67426. */
  67427. texture: Texture;
  67428. /**
  67429. * Callback called when the task is successful
  67430. */
  67431. onSuccess: (task: TextureAssetTask) => void;
  67432. /**
  67433. * Callback called when the task is successful
  67434. */
  67435. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67436. /**
  67437. * Creates a new TextureAssetTask object
  67438. * @param name defines the name of the task
  67439. * @param url defines the location of the file to load
  67440. * @param noMipmap defines if mipmap should not be generated (default is false)
  67441. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67442. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67443. */
  67444. constructor(
  67445. /**
  67446. * Defines the name of the task
  67447. */
  67448. name: string,
  67449. /**
  67450. * Defines the location of the file to load
  67451. */
  67452. url: string,
  67453. /**
  67454. * Defines if mipmap should not be generated (default is false)
  67455. */
  67456. noMipmap?: boolean | undefined,
  67457. /**
  67458. * Defines if texture must be inverted on Y axis (default is false)
  67459. */
  67460. invertY?: boolean | undefined,
  67461. /**
  67462. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67463. */
  67464. samplingMode?: number);
  67465. /**
  67466. * Execute the current task
  67467. * @param scene defines the scene where you want your assets to be loaded
  67468. * @param onSuccess is a callback called when the task is successfully executed
  67469. * @param onError is a callback called if an error occurs
  67470. */
  67471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67472. }
  67473. /**
  67474. * Define a task used by AssetsManager to load cube textures
  67475. */
  67476. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67477. /**
  67478. * Defines the name of the task
  67479. */
  67480. name: string;
  67481. /**
  67482. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67483. */
  67484. url: string;
  67485. /**
  67486. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67487. */
  67488. extensions?: string[] | undefined;
  67489. /**
  67490. * Defines if mipmaps should not be generated (default is false)
  67491. */
  67492. noMipmap?: boolean | undefined;
  67493. /**
  67494. * Defines the explicit list of files (undefined by default)
  67495. */
  67496. files?: string[] | undefined;
  67497. /**
  67498. * Gets the loaded texture
  67499. */
  67500. texture: CubeTexture;
  67501. /**
  67502. * Callback called when the task is successful
  67503. */
  67504. onSuccess: (task: CubeTextureAssetTask) => void;
  67505. /**
  67506. * Callback called when the task is successful
  67507. */
  67508. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67509. /**
  67510. * Creates a new CubeTextureAssetTask
  67511. * @param name defines the name of the task
  67512. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67513. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67514. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67515. * @param files defines the explicit list of files (undefined by default)
  67516. */
  67517. constructor(
  67518. /**
  67519. * Defines the name of the task
  67520. */
  67521. name: string,
  67522. /**
  67523. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67524. */
  67525. url: string,
  67526. /**
  67527. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67528. */
  67529. extensions?: string[] | undefined,
  67530. /**
  67531. * Defines if mipmaps should not be generated (default is false)
  67532. */
  67533. noMipmap?: boolean | undefined,
  67534. /**
  67535. * Defines the explicit list of files (undefined by default)
  67536. */
  67537. files?: string[] | undefined);
  67538. /**
  67539. * Execute the current task
  67540. * @param scene defines the scene where you want your assets to be loaded
  67541. * @param onSuccess is a callback called when the task is successfully executed
  67542. * @param onError is a callback called if an error occurs
  67543. */
  67544. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67545. }
  67546. /**
  67547. * Define a task used by AssetsManager to load HDR cube textures
  67548. */
  67549. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67550. /**
  67551. * Defines the name of the task
  67552. */
  67553. name: string;
  67554. /**
  67555. * Defines the location of the file to load
  67556. */
  67557. url: string;
  67558. /**
  67559. * Defines the desired size (the more it increases the longer the generation will be)
  67560. */
  67561. size: number;
  67562. /**
  67563. * Defines if mipmaps should not be generated (default is false)
  67564. */
  67565. noMipmap: boolean;
  67566. /**
  67567. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67568. */
  67569. generateHarmonics: boolean;
  67570. /**
  67571. * 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)
  67572. */
  67573. gammaSpace: boolean;
  67574. /**
  67575. * Internal Use Only
  67576. */
  67577. reserved: boolean;
  67578. /**
  67579. * Gets the loaded texture
  67580. */
  67581. texture: HDRCubeTexture;
  67582. /**
  67583. * Callback called when the task is successful
  67584. */
  67585. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67586. /**
  67587. * Callback called when the task is successful
  67588. */
  67589. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67590. /**
  67591. * Creates a new HDRCubeTextureAssetTask object
  67592. * @param name defines the name of the task
  67593. * @param url defines the location of the file to load
  67594. * @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.
  67595. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67596. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67597. * @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)
  67598. * @param reserved Internal use only
  67599. */
  67600. constructor(
  67601. /**
  67602. * Defines the name of the task
  67603. */
  67604. name: string,
  67605. /**
  67606. * Defines the location of the file to load
  67607. */
  67608. url: string,
  67609. /**
  67610. * Defines the desired size (the more it increases the longer the generation will be)
  67611. */
  67612. size: number,
  67613. /**
  67614. * Defines if mipmaps should not be generated (default is false)
  67615. */
  67616. noMipmap?: boolean,
  67617. /**
  67618. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67619. */
  67620. generateHarmonics?: boolean,
  67621. /**
  67622. * 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)
  67623. */
  67624. gammaSpace?: boolean,
  67625. /**
  67626. * Internal Use Only
  67627. */
  67628. reserved?: boolean);
  67629. /**
  67630. * Execute the current task
  67631. * @param scene defines the scene where you want your assets to be loaded
  67632. * @param onSuccess is a callback called when the task is successfully executed
  67633. * @param onError is a callback called if an error occurs
  67634. */
  67635. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67636. }
  67637. /**
  67638. * Define a task used by AssetsManager to load Equirectangular cube textures
  67639. */
  67640. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67641. /**
  67642. * Defines the name of the task
  67643. */
  67644. name: string;
  67645. /**
  67646. * Defines the location of the file to load
  67647. */
  67648. url: string;
  67649. /**
  67650. * Defines the desired size (the more it increases the longer the generation will be)
  67651. */
  67652. size: number;
  67653. /**
  67654. * Defines if mipmaps should not be generated (default is false)
  67655. */
  67656. noMipmap: boolean;
  67657. /**
  67658. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67659. * but the standard material would require them in Gamma space) (default is true)
  67660. */
  67661. gammaSpace: boolean;
  67662. /**
  67663. * Gets the loaded texture
  67664. */
  67665. texture: EquiRectangularCubeTexture;
  67666. /**
  67667. * Callback called when the task is successful
  67668. */
  67669. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67670. /**
  67671. * Callback called when the task is successful
  67672. */
  67673. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67674. /**
  67675. * Creates a new EquiRectangularCubeTextureAssetTask object
  67676. * @param name defines the name of the task
  67677. * @param url defines the location of the file to load
  67678. * @param size defines the desired size (the more it increases the longer the generation will be)
  67679. * If the size is omitted this implies you are using a preprocessed cubemap.
  67680. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67681. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67682. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67683. * (default is true)
  67684. */
  67685. constructor(
  67686. /**
  67687. * Defines the name of the task
  67688. */
  67689. name: string,
  67690. /**
  67691. * Defines the location of the file to load
  67692. */
  67693. url: string,
  67694. /**
  67695. * Defines the desired size (the more it increases the longer the generation will be)
  67696. */
  67697. size: number,
  67698. /**
  67699. * Defines if mipmaps should not be generated (default is false)
  67700. */
  67701. noMipmap?: boolean,
  67702. /**
  67703. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67704. * but the standard material would require them in Gamma space) (default is true)
  67705. */
  67706. gammaSpace?: boolean);
  67707. /**
  67708. * Execute the current task
  67709. * @param scene defines the scene where you want your assets to be loaded
  67710. * @param onSuccess is a callback called when the task is successfully executed
  67711. * @param onError is a callback called if an error occurs
  67712. */
  67713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67714. }
  67715. /**
  67716. * This class can be used to easily import assets into a scene
  67717. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67718. */
  67719. export class AssetsManager {
  67720. private _scene;
  67721. private _isLoading;
  67722. protected _tasks: AbstractAssetTask[];
  67723. protected _waitingTasksCount: number;
  67724. protected _totalTasksCount: number;
  67725. /**
  67726. * Callback called when all tasks are processed
  67727. */
  67728. onFinish: (tasks: AbstractAssetTask[]) => void;
  67729. /**
  67730. * Callback called when a task is successful
  67731. */
  67732. onTaskSuccess: (task: AbstractAssetTask) => void;
  67733. /**
  67734. * Callback called when a task had an error
  67735. */
  67736. onTaskError: (task: AbstractAssetTask) => void;
  67737. /**
  67738. * Callback called when a task is done (whatever the result is)
  67739. */
  67740. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67741. /**
  67742. * Observable called when all tasks are processed
  67743. */
  67744. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67745. /**
  67746. * Observable called when a task had an error
  67747. */
  67748. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67749. /**
  67750. * Observable called when all tasks were executed
  67751. */
  67752. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67753. /**
  67754. * Observable called when a task is done (whatever the result is)
  67755. */
  67756. onProgressObservable: Observable<IAssetsProgressEvent>;
  67757. /**
  67758. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67759. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67760. */
  67761. useDefaultLoadingScreen: boolean;
  67762. /**
  67763. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67764. * when all assets have been downloaded.
  67765. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67766. */
  67767. autoHideLoadingUI: boolean;
  67768. /**
  67769. * Creates a new AssetsManager
  67770. * @param scene defines the scene to work on
  67771. */
  67772. constructor(scene: Scene);
  67773. /**
  67774. * Add a MeshAssetTask to the list of active tasks
  67775. * @param taskName defines the name of the new task
  67776. * @param meshesNames defines the name of meshes to load
  67777. * @param rootUrl defines the root url to use to locate files
  67778. * @param sceneFilename defines the filename of the scene file
  67779. * @returns a new MeshAssetTask object
  67780. */
  67781. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67782. /**
  67783. * Add a TextFileAssetTask to the list of active tasks
  67784. * @param taskName defines the name of the new task
  67785. * @param url defines the url of the file to load
  67786. * @returns a new TextFileAssetTask object
  67787. */
  67788. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67789. /**
  67790. * Add a BinaryFileAssetTask to the list of active tasks
  67791. * @param taskName defines the name of the new task
  67792. * @param url defines the url of the file to load
  67793. * @returns a new BinaryFileAssetTask object
  67794. */
  67795. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67796. /**
  67797. * Add a ImageAssetTask to the list of active tasks
  67798. * @param taskName defines the name of the new task
  67799. * @param url defines the url of the file to load
  67800. * @returns a new ImageAssetTask object
  67801. */
  67802. addImageTask(taskName: string, url: string): ImageAssetTask;
  67803. /**
  67804. * Add a TextureAssetTask to the list of active tasks
  67805. * @param taskName defines the name of the new task
  67806. * @param url defines the url of the file to load
  67807. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67808. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67809. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67810. * @returns a new TextureAssetTask object
  67811. */
  67812. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67813. /**
  67814. * Add a CubeTextureAssetTask to the list of active tasks
  67815. * @param taskName defines the name of the new task
  67816. * @param url defines the url of the file to load
  67817. * @param extensions defines the extension to use to load the cube map (can be null)
  67818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67819. * @param files defines the list of files to load (can be null)
  67820. * @returns a new CubeTextureAssetTask object
  67821. */
  67822. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67823. /**
  67824. *
  67825. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67826. * @param taskName defines the name of the new task
  67827. * @param url defines the url of the file to load
  67828. * @param size defines the size you want for the cubemap (can be null)
  67829. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67830. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67831. * @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)
  67832. * @param reserved Internal use only
  67833. * @returns a new HDRCubeTextureAssetTask object
  67834. */
  67835. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67836. /**
  67837. *
  67838. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67839. * @param taskName defines the name of the new task
  67840. * @param url defines the url of the file to load
  67841. * @param size defines the size you want for the cubemap (can be null)
  67842. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67843. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67844. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67845. * @returns a new EquiRectangularCubeTextureAssetTask object
  67846. */
  67847. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67848. /**
  67849. * Remove a task from the assets manager.
  67850. * @param task the task to remove
  67851. */
  67852. removeTask(task: AbstractAssetTask): void;
  67853. private _decreaseWaitingTasksCount;
  67854. private _runTask;
  67855. /**
  67856. * Reset the AssetsManager and remove all tasks
  67857. * @return the current instance of the AssetsManager
  67858. */
  67859. reset(): AssetsManager;
  67860. /**
  67861. * Start the loading process
  67862. * @return the current instance of the AssetsManager
  67863. */
  67864. load(): AssetsManager;
  67865. /**
  67866. * Start the loading process as an async operation
  67867. * @return a promise returning the list of failed tasks
  67868. */
  67869. loadAsync(): Promise<void>;
  67870. }
  67871. }
  67872. declare module "babylonjs/Misc/deferred" {
  67873. /**
  67874. * Wrapper class for promise with external resolve and reject.
  67875. */
  67876. export class Deferred<T> {
  67877. /**
  67878. * The promise associated with this deferred object.
  67879. */
  67880. readonly promise: Promise<T>;
  67881. private _resolve;
  67882. private _reject;
  67883. /**
  67884. * The resolve method of the promise associated with this deferred object.
  67885. */
  67886. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67887. /**
  67888. * The reject method of the promise associated with this deferred object.
  67889. */
  67890. readonly reject: (reason?: any) => void;
  67891. /**
  67892. * Constructor for this deferred object.
  67893. */
  67894. constructor();
  67895. }
  67896. }
  67897. declare module "babylonjs/Misc/meshExploder" {
  67898. import { Mesh } from "babylonjs/Meshes/mesh";
  67899. /**
  67900. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67901. */
  67902. export class MeshExploder {
  67903. private _centerMesh;
  67904. private _meshes;
  67905. private _meshesOrigins;
  67906. private _toCenterVectors;
  67907. private _scaledDirection;
  67908. private _newPosition;
  67909. private _centerPosition;
  67910. /**
  67911. * Explodes meshes from a center mesh.
  67912. * @param meshes The meshes to explode.
  67913. * @param centerMesh The mesh to be center of explosion.
  67914. */
  67915. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67916. private _setCenterMesh;
  67917. /**
  67918. * Get class name
  67919. * @returns "MeshExploder"
  67920. */
  67921. getClassName(): string;
  67922. /**
  67923. * "Exploded meshes"
  67924. * @returns Array of meshes with the centerMesh at index 0.
  67925. */
  67926. getMeshes(): Array<Mesh>;
  67927. /**
  67928. * Explodes meshes giving a specific direction
  67929. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67930. */
  67931. explode(direction?: number): void;
  67932. }
  67933. }
  67934. declare module "babylonjs/Misc/filesInput" {
  67935. import { Engine } from "babylonjs/Engines/engine";
  67936. import { Scene } from "babylonjs/scene";
  67937. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67938. /**
  67939. * Class used to help managing file picking and drag'n'drop
  67940. */
  67941. export class FilesInput {
  67942. /**
  67943. * List of files ready to be loaded
  67944. */
  67945. static readonly FilesToLoad: {
  67946. [key: string]: File;
  67947. };
  67948. /**
  67949. * Callback called when a file is processed
  67950. */
  67951. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67952. private _engine;
  67953. private _currentScene;
  67954. private _sceneLoadedCallback;
  67955. private _progressCallback;
  67956. private _additionalRenderLoopLogicCallback;
  67957. private _textureLoadingCallback;
  67958. private _startingProcessingFilesCallback;
  67959. private _onReloadCallback;
  67960. private _errorCallback;
  67961. private _elementToMonitor;
  67962. private _sceneFileToLoad;
  67963. private _filesToLoad;
  67964. /**
  67965. * Creates a new FilesInput
  67966. * @param engine defines the rendering engine
  67967. * @param scene defines the hosting scene
  67968. * @param sceneLoadedCallback callback called when scene is loaded
  67969. * @param progressCallback callback called to track progress
  67970. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67971. * @param textureLoadingCallback callback called when a texture is loading
  67972. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67973. * @param onReloadCallback callback called when a reload is requested
  67974. * @param errorCallback callback call if an error occurs
  67975. */
  67976. 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);
  67977. private _dragEnterHandler;
  67978. private _dragOverHandler;
  67979. private _dropHandler;
  67980. /**
  67981. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67982. * @param elementToMonitor defines the DOM element to track
  67983. */
  67984. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67985. /**
  67986. * Release all associated resources
  67987. */
  67988. dispose(): void;
  67989. private renderFunction;
  67990. private drag;
  67991. private drop;
  67992. private _traverseFolder;
  67993. private _processFiles;
  67994. /**
  67995. * Load files from a drop event
  67996. * @param event defines the drop event to use as source
  67997. */
  67998. loadFiles(event: any): void;
  67999. private _processReload;
  68000. /**
  68001. * Reload the current scene from the loaded files
  68002. */
  68003. reload(): void;
  68004. }
  68005. }
  68006. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68007. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68008. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68009. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68010. }
  68011. declare module "babylonjs/Misc/sceneOptimizer" {
  68012. import { Scene, IDisposable } from "babylonjs/scene";
  68013. import { Observable } from "babylonjs/Misc/observable";
  68014. /**
  68015. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68017. */
  68018. export class SceneOptimization {
  68019. /**
  68020. * Defines the priority of this optimization (0 by default which means first in the list)
  68021. */
  68022. priority: number;
  68023. /**
  68024. * Gets a string describing the action executed by the current optimization
  68025. * @returns description string
  68026. */
  68027. getDescription(): string;
  68028. /**
  68029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68030. * @param scene defines the current scene where to apply this optimization
  68031. * @param optimizer defines the current optimizer
  68032. * @returns true if everything that can be done was applied
  68033. */
  68034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68035. /**
  68036. * Creates the SceneOptimization object
  68037. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68038. * @param desc defines the description associated with the optimization
  68039. */
  68040. constructor(
  68041. /**
  68042. * Defines the priority of this optimization (0 by default which means first in the list)
  68043. */
  68044. priority?: number);
  68045. }
  68046. /**
  68047. * Defines an optimization used to reduce the size of render target textures
  68048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68049. */
  68050. export class TextureOptimization extends SceneOptimization {
  68051. /**
  68052. * Defines the priority of this optimization (0 by default which means first in the list)
  68053. */
  68054. priority: number;
  68055. /**
  68056. * 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
  68057. */
  68058. maximumSize: number;
  68059. /**
  68060. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68061. */
  68062. step: number;
  68063. /**
  68064. * Gets a string describing the action executed by the current optimization
  68065. * @returns description string
  68066. */
  68067. getDescription(): string;
  68068. /**
  68069. * Creates the TextureOptimization object
  68070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68071. * @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
  68072. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68073. */
  68074. constructor(
  68075. /**
  68076. * Defines the priority of this optimization (0 by default which means first in the list)
  68077. */
  68078. priority?: number,
  68079. /**
  68080. * 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
  68081. */
  68082. maximumSize?: number,
  68083. /**
  68084. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68085. */
  68086. step?: number);
  68087. /**
  68088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68089. * @param scene defines the current scene where to apply this optimization
  68090. * @param optimizer defines the current optimizer
  68091. * @returns true if everything that can be done was applied
  68092. */
  68093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68094. }
  68095. /**
  68096. * Defines an optimization used to increase or decrease the rendering resolution
  68097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68098. */
  68099. export class HardwareScalingOptimization extends SceneOptimization {
  68100. /**
  68101. * Defines the priority of this optimization (0 by default which means first in the list)
  68102. */
  68103. priority: number;
  68104. /**
  68105. * Defines the maximum scale to use (2 by default)
  68106. */
  68107. maximumScale: number;
  68108. /**
  68109. * Defines the step to use between two passes (0.5 by default)
  68110. */
  68111. step: number;
  68112. private _currentScale;
  68113. private _directionOffset;
  68114. /**
  68115. * Gets a string describing the action executed by the current optimization
  68116. * @return description string
  68117. */
  68118. getDescription(): string;
  68119. /**
  68120. * Creates the HardwareScalingOptimization object
  68121. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68122. * @param maximumScale defines the maximum scale to use (2 by default)
  68123. * @param step defines the step to use between two passes (0.5 by default)
  68124. */
  68125. constructor(
  68126. /**
  68127. * Defines the priority of this optimization (0 by default which means first in the list)
  68128. */
  68129. priority?: number,
  68130. /**
  68131. * Defines the maximum scale to use (2 by default)
  68132. */
  68133. maximumScale?: number,
  68134. /**
  68135. * Defines the step to use between two passes (0.5 by default)
  68136. */
  68137. step?: number);
  68138. /**
  68139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68140. * @param scene defines the current scene where to apply this optimization
  68141. * @param optimizer defines the current optimizer
  68142. * @returns true if everything that can be done was applied
  68143. */
  68144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68145. }
  68146. /**
  68147. * Defines an optimization used to remove shadows
  68148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68149. */
  68150. export class ShadowsOptimization extends SceneOptimization {
  68151. /**
  68152. * Gets a string describing the action executed by the current optimization
  68153. * @return description string
  68154. */
  68155. getDescription(): string;
  68156. /**
  68157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68158. * @param scene defines the current scene where to apply this optimization
  68159. * @param optimizer defines the current optimizer
  68160. * @returns true if everything that can be done was applied
  68161. */
  68162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68163. }
  68164. /**
  68165. * Defines an optimization used to turn post-processes off
  68166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68167. */
  68168. export class PostProcessesOptimization extends SceneOptimization {
  68169. /**
  68170. * Gets a string describing the action executed by the current optimization
  68171. * @return description string
  68172. */
  68173. getDescription(): string;
  68174. /**
  68175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68176. * @param scene defines the current scene where to apply this optimization
  68177. * @param optimizer defines the current optimizer
  68178. * @returns true if everything that can be done was applied
  68179. */
  68180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68181. }
  68182. /**
  68183. * Defines an optimization used to turn lens flares off
  68184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68185. */
  68186. export class LensFlaresOptimization extends SceneOptimization {
  68187. /**
  68188. * Gets a string describing the action executed by the current optimization
  68189. * @return description string
  68190. */
  68191. getDescription(): string;
  68192. /**
  68193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68194. * @param scene defines the current scene where to apply this optimization
  68195. * @param optimizer defines the current optimizer
  68196. * @returns true if everything that can be done was applied
  68197. */
  68198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68199. }
  68200. /**
  68201. * Defines an optimization based on user defined callback.
  68202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68203. */
  68204. export class CustomOptimization extends SceneOptimization {
  68205. /**
  68206. * Callback called to apply the custom optimization.
  68207. */
  68208. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68209. /**
  68210. * Callback called to get custom description
  68211. */
  68212. onGetDescription: () => string;
  68213. /**
  68214. * Gets a string describing the action executed by the current optimization
  68215. * @returns description string
  68216. */
  68217. getDescription(): string;
  68218. /**
  68219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68220. * @param scene defines the current scene where to apply this optimization
  68221. * @param optimizer defines the current optimizer
  68222. * @returns true if everything that can be done was applied
  68223. */
  68224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68225. }
  68226. /**
  68227. * Defines an optimization used to turn particles off
  68228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68229. */
  68230. export class ParticlesOptimization extends SceneOptimization {
  68231. /**
  68232. * Gets a string describing the action executed by the current optimization
  68233. * @return description string
  68234. */
  68235. getDescription(): string;
  68236. /**
  68237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68238. * @param scene defines the current scene where to apply this optimization
  68239. * @param optimizer defines the current optimizer
  68240. * @returns true if everything that can be done was applied
  68241. */
  68242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68243. }
  68244. /**
  68245. * Defines an optimization used to turn render targets off
  68246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68247. */
  68248. export class RenderTargetsOptimization extends SceneOptimization {
  68249. /**
  68250. * Gets a string describing the action executed by the current optimization
  68251. * @return description string
  68252. */
  68253. getDescription(): string;
  68254. /**
  68255. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68256. * @param scene defines the current scene where to apply this optimization
  68257. * @param optimizer defines the current optimizer
  68258. * @returns true if everything that can be done was applied
  68259. */
  68260. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68261. }
  68262. /**
  68263. * Defines an optimization used to merge meshes with compatible materials
  68264. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68265. */
  68266. export class MergeMeshesOptimization extends SceneOptimization {
  68267. private static _UpdateSelectionTree;
  68268. /**
  68269. * Gets or sets a boolean which defines if optimization octree has to be updated
  68270. */
  68271. /**
  68272. * Gets or sets a boolean which defines if optimization octree has to be updated
  68273. */
  68274. static UpdateSelectionTree: boolean;
  68275. /**
  68276. * Gets a string describing the action executed by the current optimization
  68277. * @return description string
  68278. */
  68279. getDescription(): string;
  68280. private _canBeMerged;
  68281. /**
  68282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68283. * @param scene defines the current scene where to apply this optimization
  68284. * @param optimizer defines the current optimizer
  68285. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68286. * @returns true if everything that can be done was applied
  68287. */
  68288. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68289. }
  68290. /**
  68291. * Defines a list of options used by SceneOptimizer
  68292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68293. */
  68294. export class SceneOptimizerOptions {
  68295. /**
  68296. * Defines the target frame rate to reach (60 by default)
  68297. */
  68298. targetFrameRate: number;
  68299. /**
  68300. * Defines the interval between two checkes (2000ms by default)
  68301. */
  68302. trackerDuration: number;
  68303. /**
  68304. * Gets the list of optimizations to apply
  68305. */
  68306. optimizations: SceneOptimization[];
  68307. /**
  68308. * Creates a new list of options used by SceneOptimizer
  68309. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68310. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68311. */
  68312. constructor(
  68313. /**
  68314. * Defines the target frame rate to reach (60 by default)
  68315. */
  68316. targetFrameRate?: number,
  68317. /**
  68318. * Defines the interval between two checkes (2000ms by default)
  68319. */
  68320. trackerDuration?: number);
  68321. /**
  68322. * Add a new optimization
  68323. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68324. * @returns the current SceneOptimizerOptions
  68325. */
  68326. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68327. /**
  68328. * Add a new custom optimization
  68329. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68330. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68331. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68332. * @returns the current SceneOptimizerOptions
  68333. */
  68334. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68335. /**
  68336. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68337. * @param targetFrameRate defines the target frame rate (60 by default)
  68338. * @returns a SceneOptimizerOptions object
  68339. */
  68340. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68341. /**
  68342. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68343. * @param targetFrameRate defines the target frame rate (60 by default)
  68344. * @returns a SceneOptimizerOptions object
  68345. */
  68346. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68347. /**
  68348. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68349. * @param targetFrameRate defines the target frame rate (60 by default)
  68350. * @returns a SceneOptimizerOptions object
  68351. */
  68352. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68353. }
  68354. /**
  68355. * Class used to run optimizations in order to reach a target frame rate
  68356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68357. */
  68358. export class SceneOptimizer implements IDisposable {
  68359. private _isRunning;
  68360. private _options;
  68361. private _scene;
  68362. private _currentPriorityLevel;
  68363. private _targetFrameRate;
  68364. private _trackerDuration;
  68365. private _currentFrameRate;
  68366. private _sceneDisposeObserver;
  68367. private _improvementMode;
  68368. /**
  68369. * Defines an observable called when the optimizer reaches the target frame rate
  68370. */
  68371. onSuccessObservable: Observable<SceneOptimizer>;
  68372. /**
  68373. * Defines an observable called when the optimizer enables an optimization
  68374. */
  68375. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68376. /**
  68377. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68378. */
  68379. onFailureObservable: Observable<SceneOptimizer>;
  68380. /**
  68381. * Gets a boolean indicating if the optimizer is in improvement mode
  68382. */
  68383. readonly isInImprovementMode: boolean;
  68384. /**
  68385. * Gets the current priority level (0 at start)
  68386. */
  68387. readonly currentPriorityLevel: number;
  68388. /**
  68389. * Gets the current frame rate checked by the SceneOptimizer
  68390. */
  68391. readonly currentFrameRate: number;
  68392. /**
  68393. * Gets or sets the current target frame rate (60 by default)
  68394. */
  68395. /**
  68396. * Gets or sets the current target frame rate (60 by default)
  68397. */
  68398. targetFrameRate: number;
  68399. /**
  68400. * Gets or sets the current interval between two checks (every 2000ms by default)
  68401. */
  68402. /**
  68403. * Gets or sets the current interval between two checks (every 2000ms by default)
  68404. */
  68405. trackerDuration: number;
  68406. /**
  68407. * Gets the list of active optimizations
  68408. */
  68409. readonly optimizations: SceneOptimization[];
  68410. /**
  68411. * Creates a new SceneOptimizer
  68412. * @param scene defines the scene to work on
  68413. * @param options defines the options to use with the SceneOptimizer
  68414. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68415. * @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)
  68416. */
  68417. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68418. /**
  68419. * Stops the current optimizer
  68420. */
  68421. stop(): void;
  68422. /**
  68423. * Reset the optimizer to initial step (current priority level = 0)
  68424. */
  68425. reset(): void;
  68426. /**
  68427. * Start the optimizer. By default it will try to reach a specific framerate
  68428. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68429. */
  68430. start(): void;
  68431. private _checkCurrentState;
  68432. /**
  68433. * Release all resources
  68434. */
  68435. dispose(): void;
  68436. /**
  68437. * Helper function to create a SceneOptimizer with one single line of code
  68438. * @param scene defines the scene to work on
  68439. * @param options defines the options to use with the SceneOptimizer
  68440. * @param onSuccess defines a callback to call on success
  68441. * @param onFailure defines a callback to call on failure
  68442. * @returns the new SceneOptimizer object
  68443. */
  68444. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68445. }
  68446. }
  68447. declare module "babylonjs/Misc/sceneSerializer" {
  68448. import { Scene } from "babylonjs/scene";
  68449. /**
  68450. * Class used to serialize a scene into a string
  68451. */
  68452. export class SceneSerializer {
  68453. /**
  68454. * Clear cache used by a previous serialization
  68455. */
  68456. static ClearCache(): void;
  68457. /**
  68458. * Serialize a scene into a JSON compatible object
  68459. * @param scene defines the scene to serialize
  68460. * @returns a JSON compatible object
  68461. */
  68462. static Serialize(scene: Scene): any;
  68463. /**
  68464. * Serialize a mesh into a JSON compatible object
  68465. * @param toSerialize defines the mesh to serialize
  68466. * @param withParents defines if parents must be serialized as well
  68467. * @param withChildren defines if children must be serialized as well
  68468. * @returns a JSON compatible object
  68469. */
  68470. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68471. }
  68472. }
  68473. declare module "babylonjs/Misc/textureTools" {
  68474. import { Texture } from "babylonjs/Materials/Textures/texture";
  68475. /**
  68476. * Class used to host texture specific utilities
  68477. */
  68478. export class TextureTools {
  68479. /**
  68480. * Uses the GPU to create a copy texture rescaled at a given size
  68481. * @param texture Texture to copy from
  68482. * @param width defines the desired width
  68483. * @param height defines the desired height
  68484. * @param useBilinearMode defines if bilinear mode has to be used
  68485. * @return the generated texture
  68486. */
  68487. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68488. }
  68489. }
  68490. declare module "babylonjs/Misc/videoRecorder" {
  68491. import { Nullable } from "babylonjs/types";
  68492. import { Engine } from "babylonjs/Engines/engine";
  68493. /**
  68494. * This represents the different options available for the video capture.
  68495. */
  68496. export interface VideoRecorderOptions {
  68497. /** Defines the mime type of the video. */
  68498. mimeType: string;
  68499. /** Defines the FPS the video should be recorded at. */
  68500. fps: number;
  68501. /** Defines the chunk size for the recording data. */
  68502. recordChunckSize: number;
  68503. /** The audio tracks to attach to the recording. */
  68504. audioTracks?: MediaStreamTrack[];
  68505. }
  68506. /**
  68507. * This can help with recording videos from BabylonJS.
  68508. * This is based on the available WebRTC functionalities of the browser.
  68509. *
  68510. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68511. */
  68512. export class VideoRecorder {
  68513. private static readonly _defaultOptions;
  68514. /**
  68515. * Returns whether or not the VideoRecorder is available in your browser.
  68516. * @param engine Defines the Babylon Engine.
  68517. * @returns true if supported otherwise false.
  68518. */
  68519. static IsSupported(engine: Engine): boolean;
  68520. private readonly _options;
  68521. private _canvas;
  68522. private _mediaRecorder;
  68523. private _recordedChunks;
  68524. private _fileName;
  68525. private _resolve;
  68526. private _reject;
  68527. /**
  68528. * True when a recording is already in progress.
  68529. */
  68530. readonly isRecording: boolean;
  68531. /**
  68532. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68533. * @param engine Defines the BabylonJS Engine you wish to record.
  68534. * @param options Defines options that can be used to customize the capture.
  68535. */
  68536. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68537. /**
  68538. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68539. */
  68540. stopRecording(): void;
  68541. /**
  68542. * Starts recording the canvas for a max duration specified in parameters.
  68543. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68544. * If null no automatic download will start and you can rely on the promise to get the data back.
  68545. * @param maxDuration Defines the maximum recording time in seconds.
  68546. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68547. * @return A promise callback at the end of the recording with the video data in Blob.
  68548. */
  68549. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68550. /**
  68551. * Releases internal resources used during the recording.
  68552. */
  68553. dispose(): void;
  68554. private _handleDataAvailable;
  68555. private _handleError;
  68556. private _handleStop;
  68557. }
  68558. }
  68559. declare module "babylonjs/Misc/screenshotTools" {
  68560. import { Camera } from "babylonjs/Cameras/camera";
  68561. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68562. import { Engine } from "babylonjs/Engines/engine";
  68563. /**
  68564. * Class containing a set of static utilities functions for screenshots
  68565. */
  68566. export class ScreenshotTools {
  68567. /**
  68568. * Captures a screenshot of the current rendering
  68569. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68570. * @param engine defines the rendering engine
  68571. * @param camera defines the source camera
  68572. * @param size This parameter can be set to a single number or to an object with the
  68573. * following (optional) properties: precision, width, height. If a single number is passed,
  68574. * it will be used for both width and height. If an object is passed, the screenshot size
  68575. * will be derived from the parameters. The precision property is a multiplier allowing
  68576. * rendering at a higher or lower resolution
  68577. * @param successCallback defines the callback receives a single parameter which contains the
  68578. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68579. * src parameter of an <img> to display it
  68580. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68581. * Check your browser for supported MIME types
  68582. */
  68583. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68584. /**
  68585. * Captures a screenshot of the current rendering
  68586. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68587. * @param engine defines the rendering engine
  68588. * @param camera defines the source camera
  68589. * @param size This parameter can be set to a single number or to an object with the
  68590. * following (optional) properties: precision, width, height. If a single number is passed,
  68591. * it will be used for both width and height. If an object is passed, the screenshot size
  68592. * will be derived from the parameters. The precision property is a multiplier allowing
  68593. * rendering at a higher or lower resolution
  68594. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68595. * Check your browser for supported MIME types
  68596. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68597. * to the src parameter of an <img> to display it
  68598. */
  68599. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68600. /**
  68601. * Generates an image screenshot from the specified camera.
  68602. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68603. * @param engine The engine to use for rendering
  68604. * @param camera The camera to use for rendering
  68605. * @param size This parameter can be set to a single number or to an object with the
  68606. * following (optional) properties: precision, width, height. If a single number is passed,
  68607. * it will be used for both width and height. If an object is passed, the screenshot size
  68608. * will be derived from the parameters. The precision property is a multiplier allowing
  68609. * rendering at a higher or lower resolution
  68610. * @param successCallback The callback receives a single parameter which contains the
  68611. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68612. * src parameter of an <img> to display it
  68613. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68614. * Check your browser for supported MIME types
  68615. * @param samples Texture samples (default: 1)
  68616. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68617. * @param fileName A name for for the downloaded file.
  68618. */
  68619. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68620. /**
  68621. * Generates an image screenshot from the specified camera.
  68622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68623. * @param engine The engine to use for rendering
  68624. * @param camera The camera to use for rendering
  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 mimeType The MIME type of the screenshot image (default: image/png).
  68631. * Check your browser for supported MIME types
  68632. * @param samples Texture samples (default: 1)
  68633. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68634. * @param fileName A name for for the downloaded file.
  68635. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68636. * to the src parameter of an <img> to display it
  68637. */
  68638. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68639. /**
  68640. * Gets height and width for screenshot size
  68641. * @private
  68642. */
  68643. private static _getScreenshotSize;
  68644. }
  68645. }
  68646. declare module "babylonjs/Misc/dataReader" {
  68647. /**
  68648. * Interface for a data buffer
  68649. */
  68650. export interface IDataBuffer {
  68651. /**
  68652. * Reads bytes from the data buffer.
  68653. * @param byteOffset The byte offset to read
  68654. * @param byteLength The byte length to read
  68655. * @returns A promise that resolves when the bytes are read
  68656. */
  68657. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68658. /**
  68659. * The byte length of the buffer.
  68660. */
  68661. readonly byteLength: number;
  68662. }
  68663. /**
  68664. * Utility class for reading from a data buffer
  68665. */
  68666. export class DataReader {
  68667. /**
  68668. * The data buffer associated with this data reader.
  68669. */
  68670. readonly buffer: IDataBuffer;
  68671. /**
  68672. * The current byte offset from the beginning of the data buffer.
  68673. */
  68674. byteOffset: number;
  68675. private _dataView;
  68676. private _dataByteOffset;
  68677. /**
  68678. * Constructor
  68679. * @param buffer The buffer to read
  68680. */
  68681. constructor(buffer: IDataBuffer);
  68682. /**
  68683. * Loads the given byte length.
  68684. * @param byteLength The byte length to load
  68685. * @returns A promise that resolves when the load is complete
  68686. */
  68687. loadAsync(byteLength: number): Promise<void>;
  68688. /**
  68689. * Read a unsigned 32-bit integer from the currently loaded data range.
  68690. * @returns The 32-bit integer read
  68691. */
  68692. readUint32(): number;
  68693. /**
  68694. * Read a byte array from the currently loaded data range.
  68695. * @param byteLength The byte length to read
  68696. * @returns The byte array read
  68697. */
  68698. readUint8Array(byteLength: number): Uint8Array;
  68699. /**
  68700. * Read a string from the currently loaded data range.
  68701. * @param byteLength The byte length to read
  68702. * @returns The string read
  68703. */
  68704. readString(byteLength: number): string;
  68705. /**
  68706. * Skips the given byte length the currently loaded data range.
  68707. * @param byteLength The byte length to skip
  68708. */
  68709. skipBytes(byteLength: number): void;
  68710. }
  68711. }
  68712. declare module "babylonjs/Misc/index" {
  68713. export * from "babylonjs/Misc/andOrNotEvaluator";
  68714. export * from "babylonjs/Misc/assetsManager";
  68715. export * from "babylonjs/Misc/basis";
  68716. export * from "babylonjs/Misc/dds";
  68717. export * from "babylonjs/Misc/decorators";
  68718. export * from "babylonjs/Misc/deferred";
  68719. export * from "babylonjs/Misc/environmentTextureTools";
  68720. export * from "babylonjs/Misc/meshExploder";
  68721. export * from "babylonjs/Misc/filesInput";
  68722. export * from "babylonjs/Misc/HighDynamicRange/index";
  68723. export * from "babylonjs/Misc/khronosTextureContainer";
  68724. export * from "babylonjs/Misc/observable";
  68725. export * from "babylonjs/Misc/performanceMonitor";
  68726. export * from "babylonjs/Misc/promise";
  68727. export * from "babylonjs/Misc/sceneOptimizer";
  68728. export * from "babylonjs/Misc/sceneSerializer";
  68729. export * from "babylonjs/Misc/smartArray";
  68730. export * from "babylonjs/Misc/stringDictionary";
  68731. export * from "babylonjs/Misc/tags";
  68732. export * from "babylonjs/Misc/textureTools";
  68733. export * from "babylonjs/Misc/tga";
  68734. export * from "babylonjs/Misc/tools";
  68735. export * from "babylonjs/Misc/videoRecorder";
  68736. export * from "babylonjs/Misc/virtualJoystick";
  68737. export * from "babylonjs/Misc/workerPool";
  68738. export * from "babylonjs/Misc/logger";
  68739. export * from "babylonjs/Misc/typeStore";
  68740. export * from "babylonjs/Misc/filesInputStore";
  68741. export * from "babylonjs/Misc/deepCopier";
  68742. export * from "babylonjs/Misc/pivotTools";
  68743. export * from "babylonjs/Misc/precisionDate";
  68744. export * from "babylonjs/Misc/screenshotTools";
  68745. export * from "babylonjs/Misc/typeStore";
  68746. export * from "babylonjs/Misc/webRequest";
  68747. export * from "babylonjs/Misc/iInspectable";
  68748. export * from "babylonjs/Misc/brdfTextureTools";
  68749. export * from "babylonjs/Misc/rgbdTextureTools";
  68750. export * from "babylonjs/Misc/gradients";
  68751. export * from "babylonjs/Misc/perfCounter";
  68752. export * from "babylonjs/Misc/fileRequest";
  68753. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68754. export * from "babylonjs/Misc/retryStrategy";
  68755. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68756. export * from "babylonjs/Misc/canvasGenerator";
  68757. export * from "babylonjs/Misc/fileTools";
  68758. export * from "babylonjs/Misc/stringTools";
  68759. export * from "babylonjs/Misc/dataReader";
  68760. }
  68761. declare module "babylonjs/index" {
  68762. export * from "babylonjs/abstractScene";
  68763. export * from "babylonjs/Actions/index";
  68764. export * from "babylonjs/Animations/index";
  68765. export * from "babylonjs/assetContainer";
  68766. export * from "babylonjs/Audio/index";
  68767. export * from "babylonjs/Behaviors/index";
  68768. export * from "babylonjs/Bones/index";
  68769. export * from "babylonjs/Cameras/index";
  68770. export * from "babylonjs/Collisions/index";
  68771. export * from "babylonjs/Culling/index";
  68772. export * from "babylonjs/Debug/index";
  68773. export * from "babylonjs/Engines/index";
  68774. export * from "babylonjs/Events/index";
  68775. export * from "babylonjs/Gamepads/index";
  68776. export * from "babylonjs/Gizmos/index";
  68777. export * from "babylonjs/Helpers/index";
  68778. export * from "babylonjs/Instrumentation/index";
  68779. export * from "babylonjs/Layers/index";
  68780. export * from "babylonjs/LensFlares/index";
  68781. export * from "babylonjs/Lights/index";
  68782. export * from "babylonjs/Loading/index";
  68783. export * from "babylonjs/Materials/index";
  68784. export * from "babylonjs/Maths/index";
  68785. export * from "babylonjs/Meshes/index";
  68786. export * from "babylonjs/Morph/index";
  68787. export * from "babylonjs/Navigation/index";
  68788. export * from "babylonjs/node";
  68789. export * from "babylonjs/Offline/index";
  68790. export * from "babylonjs/Particles/index";
  68791. export * from "babylonjs/Physics/index";
  68792. export * from "babylonjs/PostProcesses/index";
  68793. export * from "babylonjs/Probes/index";
  68794. export * from "babylonjs/Rendering/index";
  68795. export * from "babylonjs/scene";
  68796. export * from "babylonjs/sceneComponent";
  68797. export * from "babylonjs/Sprites/index";
  68798. export * from "babylonjs/States/index";
  68799. export * from "babylonjs/Misc/index";
  68800. export * from "babylonjs/types";
  68801. }
  68802. declare module "babylonjs/Animations/pathCursor" {
  68803. import { Vector3 } from "babylonjs/Maths/math.vector";
  68804. import { Path2 } from "babylonjs/Maths/math.path";
  68805. /**
  68806. * A cursor which tracks a point on a path
  68807. */
  68808. export class PathCursor {
  68809. private path;
  68810. /**
  68811. * Stores path cursor callbacks for when an onchange event is triggered
  68812. */
  68813. private _onchange;
  68814. /**
  68815. * The value of the path cursor
  68816. */
  68817. value: number;
  68818. /**
  68819. * The animation array of the path cursor
  68820. */
  68821. animations: Animation[];
  68822. /**
  68823. * Initializes the path cursor
  68824. * @param path The path to track
  68825. */
  68826. constructor(path: Path2);
  68827. /**
  68828. * Gets the cursor point on the path
  68829. * @returns A point on the path cursor at the cursor location
  68830. */
  68831. getPoint(): Vector3;
  68832. /**
  68833. * Moves the cursor ahead by the step amount
  68834. * @param step The amount to move the cursor forward
  68835. * @returns This path cursor
  68836. */
  68837. moveAhead(step?: number): PathCursor;
  68838. /**
  68839. * Moves the cursor behind by the step amount
  68840. * @param step The amount to move the cursor back
  68841. * @returns This path cursor
  68842. */
  68843. moveBack(step?: number): PathCursor;
  68844. /**
  68845. * Moves the cursor by the step amount
  68846. * If the step amount is greater than one, an exception is thrown
  68847. * @param step The amount to move the cursor
  68848. * @returns This path cursor
  68849. */
  68850. move(step: number): PathCursor;
  68851. /**
  68852. * Ensures that the value is limited between zero and one
  68853. * @returns This path cursor
  68854. */
  68855. private ensureLimits;
  68856. /**
  68857. * Runs onchange callbacks on change (used by the animation engine)
  68858. * @returns This path cursor
  68859. */
  68860. private raiseOnChange;
  68861. /**
  68862. * Executes a function on change
  68863. * @param f A path cursor onchange callback
  68864. * @returns This path cursor
  68865. */
  68866. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68867. }
  68868. }
  68869. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68870. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68871. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68872. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68873. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68874. }
  68875. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68876. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68877. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68878. }
  68879. declare module "babylonjs/Engines/Processors/index" {
  68880. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68881. export * from "babylonjs/Engines/Processors/Expressions/index";
  68882. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68883. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68884. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68885. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68886. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68887. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68888. }
  68889. declare module "babylonjs/Legacy/legacy" {
  68890. import * as Babylon from "babylonjs/index";
  68891. export * from "babylonjs/index";
  68892. }
  68893. declare module "babylonjs/Shaders/blur.fragment" {
  68894. /** @hidden */
  68895. export var blurPixelShader: {
  68896. name: string;
  68897. shader: string;
  68898. };
  68899. }
  68900. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68901. /** @hidden */
  68902. export var pointCloudVertexDeclaration: {
  68903. name: string;
  68904. shader: string;
  68905. };
  68906. }
  68907. declare module "babylonjs" {
  68908. export * from "babylonjs/Legacy/legacy";
  68909. }
  68910. declare module BABYLON {
  68911. /** Alias type for value that can be null */
  68912. export type Nullable<T> = T | null;
  68913. /**
  68914. * Alias type for number that are floats
  68915. * @ignorenaming
  68916. */
  68917. export type float = number;
  68918. /**
  68919. * Alias type for number that are doubles.
  68920. * @ignorenaming
  68921. */
  68922. export type double = number;
  68923. /**
  68924. * Alias type for number that are integer
  68925. * @ignorenaming
  68926. */
  68927. export type int = number;
  68928. /** Alias type for number array or Float32Array */
  68929. export type FloatArray = number[] | Float32Array;
  68930. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68931. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68932. /**
  68933. * Alias for types that can be used by a Buffer or VertexBuffer.
  68934. */
  68935. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68936. /**
  68937. * Alias type for primitive types
  68938. * @ignorenaming
  68939. */
  68940. type Primitive = undefined | null | boolean | string | number | Function;
  68941. /**
  68942. * Type modifier to make all the properties of an object Readonly
  68943. */
  68944. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68945. /**
  68946. * Type modifier to make all the properties of an object Readonly recursively
  68947. */
  68948. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68949. /**
  68950. * Type modifier to make object properties readonly.
  68951. */
  68952. export type DeepImmutableObject<T> = {
  68953. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68954. };
  68955. /** @hidden */
  68956. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68957. }
  68958. }
  68959. declare module BABYLON {
  68960. /**
  68961. * A class serves as a medium between the observable and its observers
  68962. */
  68963. export class EventState {
  68964. /**
  68965. * Create a new EventState
  68966. * @param mask defines the mask associated with this state
  68967. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68968. * @param target defines the original target of the state
  68969. * @param currentTarget defines the current target of the state
  68970. */
  68971. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68972. /**
  68973. * Initialize the current event state
  68974. * @param mask defines the mask associated with this state
  68975. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68976. * @param target defines the original target of the state
  68977. * @param currentTarget defines the current target of the state
  68978. * @returns the current event state
  68979. */
  68980. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68981. /**
  68982. * An Observer can set this property to true to prevent subsequent observers of being notified
  68983. */
  68984. skipNextObservers: boolean;
  68985. /**
  68986. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68987. */
  68988. mask: number;
  68989. /**
  68990. * The object that originally notified the event
  68991. */
  68992. target?: any;
  68993. /**
  68994. * The current object in the bubbling phase
  68995. */
  68996. currentTarget?: any;
  68997. /**
  68998. * This will be populated with the return value of the last function that was executed.
  68999. * If it is the first function in the callback chain it will be the event data.
  69000. */
  69001. lastReturnValue?: any;
  69002. }
  69003. /**
  69004. * Represent an Observer registered to a given Observable object.
  69005. */
  69006. export class Observer<T> {
  69007. /**
  69008. * Defines the callback to call when the observer is notified
  69009. */
  69010. callback: (eventData: T, eventState: EventState) => void;
  69011. /**
  69012. * Defines the mask of the observer (used to filter notifications)
  69013. */
  69014. mask: number;
  69015. /**
  69016. * Defines the current scope used to restore the JS context
  69017. */
  69018. scope: any;
  69019. /** @hidden */
  69020. _willBeUnregistered: boolean;
  69021. /**
  69022. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69023. */
  69024. unregisterOnNextCall: boolean;
  69025. /**
  69026. * Creates a new observer
  69027. * @param callback defines the callback to call when the observer is notified
  69028. * @param mask defines the mask of the observer (used to filter notifications)
  69029. * @param scope defines the current scope used to restore the JS context
  69030. */
  69031. constructor(
  69032. /**
  69033. * Defines the callback to call when the observer is notified
  69034. */
  69035. callback: (eventData: T, eventState: EventState) => void,
  69036. /**
  69037. * Defines the mask of the observer (used to filter notifications)
  69038. */
  69039. mask: number,
  69040. /**
  69041. * Defines the current scope used to restore the JS context
  69042. */
  69043. scope?: any);
  69044. }
  69045. /**
  69046. * Represent a list of observers registered to multiple Observables object.
  69047. */
  69048. export class MultiObserver<T> {
  69049. private _observers;
  69050. private _observables;
  69051. /**
  69052. * Release associated resources
  69053. */
  69054. dispose(): void;
  69055. /**
  69056. * Raise a callback when one of the observable will notify
  69057. * @param observables defines a list of observables to watch
  69058. * @param callback defines the callback to call on notification
  69059. * @param mask defines the mask used to filter notifications
  69060. * @param scope defines the current scope used to restore the JS context
  69061. * @returns the new MultiObserver
  69062. */
  69063. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69064. }
  69065. /**
  69066. * The Observable class is a simple implementation of the Observable pattern.
  69067. *
  69068. * 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.
  69069. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69070. * 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).
  69071. * 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.
  69072. */
  69073. export class Observable<T> {
  69074. private _observers;
  69075. private _eventState;
  69076. private _onObserverAdded;
  69077. /**
  69078. * Gets the list of observers
  69079. */
  69080. readonly observers: Array<Observer<T>>;
  69081. /**
  69082. * Creates a new observable
  69083. * @param onObserverAdded defines a callback to call when a new observer is added
  69084. */
  69085. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69086. /**
  69087. * Create a new Observer with the specified callback
  69088. * @param callback the callback that will be executed for that Observer
  69089. * @param mask the mask used to filter observers
  69090. * @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.
  69091. * @param scope optional scope for the callback to be called from
  69092. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69093. * @returns the new observer created for the callback
  69094. */
  69095. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69096. /**
  69097. * Create a new Observer with the specified callback and unregisters after the next notification
  69098. * @param callback the callback that will be executed for that Observer
  69099. * @returns the new observer created for the callback
  69100. */
  69101. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69102. /**
  69103. * Remove an Observer from the Observable object
  69104. * @param observer the instance of the Observer to remove
  69105. * @returns false if it doesn't belong to this Observable
  69106. */
  69107. remove(observer: Nullable<Observer<T>>): boolean;
  69108. /**
  69109. * Remove a callback from the Observable object
  69110. * @param callback the callback to remove
  69111. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69112. * @returns false if it doesn't belong to this Observable
  69113. */
  69114. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69115. private _deferUnregister;
  69116. private _remove;
  69117. /**
  69118. * Moves the observable to the top of the observer list making it get called first when notified
  69119. * @param observer the observer to move
  69120. */
  69121. makeObserverTopPriority(observer: Observer<T>): void;
  69122. /**
  69123. * Moves the observable to the bottom of the observer list making it get called last when notified
  69124. * @param observer the observer to move
  69125. */
  69126. makeObserverBottomPriority(observer: Observer<T>): void;
  69127. /**
  69128. * Notify all Observers by calling their respective callback with the given data
  69129. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69130. * @param eventData defines the data to send to all observers
  69131. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69132. * @param target defines the original target of the state
  69133. * @param currentTarget defines the current target of the state
  69134. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69135. */
  69136. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69137. /**
  69138. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69139. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69140. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69141. * and it is crucial that all callbacks will be executed.
  69142. * The order of the callbacks is kept, callbacks are not executed parallel.
  69143. *
  69144. * @param eventData The data to be sent to each callback
  69145. * @param mask is used to filter observers defaults to -1
  69146. * @param target defines the callback target (see EventState)
  69147. * @param currentTarget defines he current object in the bubbling phase
  69148. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69149. */
  69150. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69151. /**
  69152. * Notify a specific observer
  69153. * @param observer defines the observer to notify
  69154. * @param eventData defines the data to be sent to each callback
  69155. * @param mask is used to filter observers defaults to -1
  69156. */
  69157. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69158. /**
  69159. * Gets a boolean indicating if the observable has at least one observer
  69160. * @returns true is the Observable has at least one Observer registered
  69161. */
  69162. hasObservers(): boolean;
  69163. /**
  69164. * Clear the list of observers
  69165. */
  69166. clear(): void;
  69167. /**
  69168. * Clone the current observable
  69169. * @returns a new observable
  69170. */
  69171. clone(): Observable<T>;
  69172. /**
  69173. * Does this observable handles observer registered with a given mask
  69174. * @param mask defines the mask to be tested
  69175. * @return whether or not one observer registered with the given mask is handeled
  69176. **/
  69177. hasSpecificMask(mask?: number): boolean;
  69178. }
  69179. }
  69180. declare module BABYLON {
  69181. /**
  69182. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69183. * Babylon.js
  69184. */
  69185. export class DomManagement {
  69186. /**
  69187. * Checks if the window object exists
  69188. * @returns true if the window object exists
  69189. */
  69190. static IsWindowObjectExist(): boolean;
  69191. /**
  69192. * Checks if the navigator object exists
  69193. * @returns true if the navigator object exists
  69194. */
  69195. static IsNavigatorAvailable(): boolean;
  69196. /**
  69197. * Extracts text content from a DOM element hierarchy
  69198. * @param element defines the root element
  69199. * @returns a string
  69200. */
  69201. static GetDOMTextContent(element: HTMLElement): string;
  69202. }
  69203. }
  69204. declare module BABYLON {
  69205. /**
  69206. * Logger used througouht the application to allow configuration of
  69207. * the log level required for the messages.
  69208. */
  69209. export class Logger {
  69210. /**
  69211. * No log
  69212. */
  69213. static readonly NoneLogLevel: number;
  69214. /**
  69215. * Only message logs
  69216. */
  69217. static readonly MessageLogLevel: number;
  69218. /**
  69219. * Only warning logs
  69220. */
  69221. static readonly WarningLogLevel: number;
  69222. /**
  69223. * Only error logs
  69224. */
  69225. static readonly ErrorLogLevel: number;
  69226. /**
  69227. * All logs
  69228. */
  69229. static readonly AllLogLevel: number;
  69230. private static _LogCache;
  69231. /**
  69232. * Gets a value indicating the number of loading errors
  69233. * @ignorenaming
  69234. */
  69235. static errorsCount: number;
  69236. /**
  69237. * Callback called when a new log is added
  69238. */
  69239. static OnNewCacheEntry: (entry: string) => void;
  69240. private static _AddLogEntry;
  69241. private static _FormatMessage;
  69242. private static _LogDisabled;
  69243. private static _LogEnabled;
  69244. private static _WarnDisabled;
  69245. private static _WarnEnabled;
  69246. private static _ErrorDisabled;
  69247. private static _ErrorEnabled;
  69248. /**
  69249. * Log a message to the console
  69250. */
  69251. static Log: (message: string) => void;
  69252. /**
  69253. * Write a warning message to the console
  69254. */
  69255. static Warn: (message: string) => void;
  69256. /**
  69257. * Write an error message to the console
  69258. */
  69259. static Error: (message: string) => void;
  69260. /**
  69261. * Gets current log cache (list of logs)
  69262. */
  69263. static readonly LogCache: string;
  69264. /**
  69265. * Clears the log cache
  69266. */
  69267. static ClearLogCache(): void;
  69268. /**
  69269. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69270. */
  69271. static LogLevels: number;
  69272. }
  69273. }
  69274. declare module BABYLON {
  69275. /** @hidden */
  69276. export class _TypeStore {
  69277. /** @hidden */
  69278. static RegisteredTypes: {
  69279. [key: string]: Object;
  69280. };
  69281. /** @hidden */
  69282. static GetClass(fqdn: string): any;
  69283. }
  69284. }
  69285. declare module BABYLON {
  69286. /**
  69287. * Helper to manipulate strings
  69288. */
  69289. export class StringTools {
  69290. /**
  69291. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69292. * @param str Source string
  69293. * @param suffix Suffix to search for in the source string
  69294. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69295. */
  69296. static EndsWith(str: string, suffix: string): boolean;
  69297. /**
  69298. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69299. * @param str Source string
  69300. * @param suffix Suffix to search for in the source string
  69301. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69302. */
  69303. static StartsWith(str: string, suffix: string): boolean;
  69304. /**
  69305. * Decodes a buffer into a string
  69306. * @param buffer The buffer to decode
  69307. * @returns The decoded string
  69308. */
  69309. static Decode(buffer: Uint8Array | Uint16Array): string;
  69310. /**
  69311. * Encode a buffer to a base64 string
  69312. * @param buffer defines the buffer to encode
  69313. * @returns the encoded string
  69314. */
  69315. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69316. }
  69317. }
  69318. declare module BABYLON {
  69319. /**
  69320. * Class containing a set of static utilities functions for deep copy.
  69321. */
  69322. export class DeepCopier {
  69323. /**
  69324. * Tries to copy an object by duplicating every property
  69325. * @param source defines the source object
  69326. * @param destination defines the target object
  69327. * @param doNotCopyList defines a list of properties to avoid
  69328. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69329. */
  69330. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69331. }
  69332. }
  69333. declare module BABYLON {
  69334. /**
  69335. * Class containing a set of static utilities functions for precision date
  69336. */
  69337. export class PrecisionDate {
  69338. /**
  69339. * Gets either window.performance.now() if supported or Date.now() else
  69340. */
  69341. static readonly Now: number;
  69342. }
  69343. }
  69344. declare module BABYLON {
  69345. /** @hidden */
  69346. export class _DevTools {
  69347. static WarnImport(name: string): string;
  69348. }
  69349. }
  69350. declare module BABYLON {
  69351. /**
  69352. * Interface used to define the mechanism to get data from the network
  69353. */
  69354. export interface IWebRequest {
  69355. /**
  69356. * Returns client's response url
  69357. */
  69358. responseURL: string;
  69359. /**
  69360. * Returns client's status
  69361. */
  69362. status: number;
  69363. /**
  69364. * Returns client's status as a text
  69365. */
  69366. statusText: string;
  69367. }
  69368. }
  69369. declare module BABYLON {
  69370. /**
  69371. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69372. */
  69373. export class WebRequest implements IWebRequest {
  69374. private _xhr;
  69375. /**
  69376. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69377. * i.e. when loading files, where the server/service expects an Authorization header
  69378. */
  69379. static CustomRequestHeaders: {
  69380. [key: string]: string;
  69381. };
  69382. /**
  69383. * Add callback functions in this array to update all the requests before they get sent to the network
  69384. */
  69385. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69386. private _injectCustomRequestHeaders;
  69387. /**
  69388. * Gets or sets a function to be called when loading progress changes
  69389. */
  69390. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69391. /**
  69392. * Returns client's state
  69393. */
  69394. readonly readyState: number;
  69395. /**
  69396. * Returns client's status
  69397. */
  69398. readonly status: number;
  69399. /**
  69400. * Returns client's status as a text
  69401. */
  69402. readonly statusText: string;
  69403. /**
  69404. * Returns client's response
  69405. */
  69406. readonly response: any;
  69407. /**
  69408. * Returns client's response url
  69409. */
  69410. readonly responseURL: string;
  69411. /**
  69412. * Returns client's response as text
  69413. */
  69414. readonly responseText: string;
  69415. /**
  69416. * Gets or sets the expected response type
  69417. */
  69418. responseType: XMLHttpRequestResponseType;
  69419. /** @hidden */
  69420. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69421. /** @hidden */
  69422. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69423. /**
  69424. * Cancels any network activity
  69425. */
  69426. abort(): void;
  69427. /**
  69428. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69429. * @param body defines an optional request body
  69430. */
  69431. send(body?: Document | BodyInit | null): void;
  69432. /**
  69433. * Sets the request method, request URL
  69434. * @param method defines the method to use (GET, POST, etc..)
  69435. * @param url defines the url to connect with
  69436. */
  69437. open(method: string, url: string): void;
  69438. /**
  69439. * Sets the value of a request header.
  69440. * @param name The name of the header whose value is to be set
  69441. * @param value The value to set as the body of the header
  69442. */
  69443. setRequestHeader(name: string, value: string): void;
  69444. /**
  69445. * Get the string containing the text of a particular header's value.
  69446. * @param name The name of the header
  69447. * @returns The string containing the text of the given header name
  69448. */
  69449. getResponseHeader(name: string): Nullable<string>;
  69450. }
  69451. }
  69452. declare module BABYLON {
  69453. /**
  69454. * File request interface
  69455. */
  69456. export interface IFileRequest {
  69457. /**
  69458. * Raised when the request is complete (success or error).
  69459. */
  69460. onCompleteObservable: Observable<IFileRequest>;
  69461. /**
  69462. * Aborts the request for a file.
  69463. */
  69464. abort: () => void;
  69465. }
  69466. }
  69467. declare module BABYLON {
  69468. /**
  69469. * Define options used to create a render target texture
  69470. */
  69471. export class RenderTargetCreationOptions {
  69472. /**
  69473. * Specifies is mipmaps must be generated
  69474. */
  69475. generateMipMaps?: boolean;
  69476. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69477. generateDepthBuffer?: boolean;
  69478. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69479. generateStencilBuffer?: boolean;
  69480. /** Defines texture type (int by default) */
  69481. type?: number;
  69482. /** Defines sampling mode (trilinear by default) */
  69483. samplingMode?: number;
  69484. /** Defines format (RGBA by default) */
  69485. format?: number;
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. * @hidden
  69491. **/
  69492. export class _TimeToken {
  69493. _startTimeQuery: Nullable<WebGLQuery>;
  69494. _endTimeQuery: Nullable<WebGLQuery>;
  69495. _timeElapsedQuery: Nullable<WebGLQuery>;
  69496. _timeElapsedQueryEnded: boolean;
  69497. }
  69498. }
  69499. declare module BABYLON {
  69500. /** Defines the cross module used constants to avoid circular dependncies */
  69501. export class Constants {
  69502. /** Defines that alpha blending is disabled */
  69503. static readonly ALPHA_DISABLE: number;
  69504. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69505. static readonly ALPHA_ADD: number;
  69506. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69507. static readonly ALPHA_COMBINE: number;
  69508. /** Defines that alpha blending to DEST - SRC * DEST */
  69509. static readonly ALPHA_SUBTRACT: number;
  69510. /** Defines that alpha blending to SRC * DEST */
  69511. static readonly ALPHA_MULTIPLY: number;
  69512. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69513. static readonly ALPHA_MAXIMIZED: number;
  69514. /** Defines that alpha blending to SRC + DEST */
  69515. static readonly ALPHA_ONEONE: number;
  69516. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69517. static readonly ALPHA_PREMULTIPLIED: number;
  69518. /**
  69519. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69520. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69521. */
  69522. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69523. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69524. static readonly ALPHA_INTERPOLATE: number;
  69525. /**
  69526. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69527. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69528. */
  69529. static readonly ALPHA_SCREENMODE: number;
  69530. /**
  69531. * Defines that alpha blending to SRC + DST
  69532. * Alpha will be set to SRC ALPHA + DST ALPHA
  69533. */
  69534. static readonly ALPHA_ONEONE_ONEONE: number;
  69535. /**
  69536. * Defines that alpha blending to SRC * DST ALPHA + DST
  69537. * Alpha will be set to 0
  69538. */
  69539. static readonly ALPHA_ALPHATOCOLOR: number;
  69540. /**
  69541. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69542. */
  69543. static readonly ALPHA_REVERSEONEMINUS: number;
  69544. /**
  69545. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69546. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69547. */
  69548. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69549. /**
  69550. * Defines that alpha blending to SRC + DST
  69551. * Alpha will be set to SRC ALPHA
  69552. */
  69553. static readonly ALPHA_ONEONE_ONEZERO: number;
  69554. /** Defines that alpha blending equation a SUM */
  69555. static readonly ALPHA_EQUATION_ADD: number;
  69556. /** Defines that alpha blending equation a SUBSTRACTION */
  69557. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69558. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69559. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69560. /** Defines that alpha blending equation a MAX operation */
  69561. static readonly ALPHA_EQUATION_MAX: number;
  69562. /** Defines that alpha blending equation a MIN operation */
  69563. static readonly ALPHA_EQUATION_MIN: number;
  69564. /**
  69565. * Defines that alpha blending equation a DARKEN operation:
  69566. * It takes the min of the src and sums the alpha channels.
  69567. */
  69568. static readonly ALPHA_EQUATION_DARKEN: number;
  69569. /** Defines that the ressource is not delayed*/
  69570. static readonly DELAYLOADSTATE_NONE: number;
  69571. /** Defines that the ressource was successfully delay loaded */
  69572. static readonly DELAYLOADSTATE_LOADED: number;
  69573. /** Defines that the ressource is currently delay loading */
  69574. static readonly DELAYLOADSTATE_LOADING: number;
  69575. /** Defines that the ressource is delayed and has not started loading */
  69576. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69577. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69578. static readonly NEVER: number;
  69579. /** 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 */
  69580. static readonly ALWAYS: number;
  69581. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69582. static readonly LESS: number;
  69583. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69584. static readonly EQUAL: number;
  69585. /** 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 */
  69586. static readonly LEQUAL: number;
  69587. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69588. static readonly GREATER: number;
  69589. /** 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 */
  69590. static readonly GEQUAL: number;
  69591. /** 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 */
  69592. static readonly NOTEQUAL: number;
  69593. /** Passed to stencilOperation to specify that stencil value must be kept */
  69594. static readonly KEEP: number;
  69595. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69596. static readonly REPLACE: number;
  69597. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69598. static readonly INCR: number;
  69599. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69600. static readonly DECR: number;
  69601. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69602. static readonly INVERT: number;
  69603. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69604. static readonly INCR_WRAP: number;
  69605. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69606. static readonly DECR_WRAP: number;
  69607. /** Texture is not repeating outside of 0..1 UVs */
  69608. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69609. /** Texture is repeating outside of 0..1 UVs */
  69610. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69611. /** Texture is repeating and mirrored */
  69612. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69613. /** ALPHA */
  69614. static readonly TEXTUREFORMAT_ALPHA: number;
  69615. /** LUMINANCE */
  69616. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69617. /** LUMINANCE_ALPHA */
  69618. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69619. /** RGB */
  69620. static readonly TEXTUREFORMAT_RGB: number;
  69621. /** RGBA */
  69622. static readonly TEXTUREFORMAT_RGBA: number;
  69623. /** RED */
  69624. static readonly TEXTUREFORMAT_RED: number;
  69625. /** RED (2nd reference) */
  69626. static readonly TEXTUREFORMAT_R: number;
  69627. /** RG */
  69628. static readonly TEXTUREFORMAT_RG: number;
  69629. /** RED_INTEGER */
  69630. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69631. /** RED_INTEGER (2nd reference) */
  69632. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69633. /** RG_INTEGER */
  69634. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69635. /** RGB_INTEGER */
  69636. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69637. /** RGBA_INTEGER */
  69638. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69639. /** UNSIGNED_BYTE */
  69640. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69641. /** UNSIGNED_BYTE (2nd reference) */
  69642. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69643. /** FLOAT */
  69644. static readonly TEXTURETYPE_FLOAT: number;
  69645. /** HALF_FLOAT */
  69646. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69647. /** BYTE */
  69648. static readonly TEXTURETYPE_BYTE: number;
  69649. /** SHORT */
  69650. static readonly TEXTURETYPE_SHORT: number;
  69651. /** UNSIGNED_SHORT */
  69652. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69653. /** INT */
  69654. static readonly TEXTURETYPE_INT: number;
  69655. /** UNSIGNED_INT */
  69656. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69657. /** UNSIGNED_SHORT_4_4_4_4 */
  69658. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69659. /** UNSIGNED_SHORT_5_5_5_1 */
  69660. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69661. /** UNSIGNED_SHORT_5_6_5 */
  69662. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69663. /** UNSIGNED_INT_2_10_10_10_REV */
  69664. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69665. /** UNSIGNED_INT_24_8 */
  69666. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69667. /** UNSIGNED_INT_10F_11F_11F_REV */
  69668. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69669. /** UNSIGNED_INT_5_9_9_9_REV */
  69670. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69671. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69672. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69673. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69674. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69676. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69677. /** Trilinear is mag = linear and min = linear and mip = linear */
  69678. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69679. /** nearest is mag = nearest and min = nearest and mip = linear */
  69680. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69681. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69682. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69683. /** Trilinear is mag = linear and min = linear and mip = linear */
  69684. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69685. /** mag = nearest and min = nearest and mip = nearest */
  69686. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69687. /** mag = nearest and min = linear and mip = nearest */
  69688. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69689. /** mag = nearest and min = linear and mip = linear */
  69690. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69691. /** mag = nearest and min = linear and mip = none */
  69692. static readonly TEXTURE_NEAREST_LINEAR: number;
  69693. /** mag = nearest and min = nearest and mip = none */
  69694. static readonly TEXTURE_NEAREST_NEAREST: number;
  69695. /** mag = linear and min = nearest and mip = nearest */
  69696. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69697. /** mag = linear and min = nearest and mip = linear */
  69698. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69699. /** mag = linear and min = linear and mip = none */
  69700. static readonly TEXTURE_LINEAR_LINEAR: number;
  69701. /** mag = linear and min = nearest and mip = none */
  69702. static readonly TEXTURE_LINEAR_NEAREST: number;
  69703. /** Explicit coordinates mode */
  69704. static readonly TEXTURE_EXPLICIT_MODE: number;
  69705. /** Spherical coordinates mode */
  69706. static readonly TEXTURE_SPHERICAL_MODE: number;
  69707. /** Planar coordinates mode */
  69708. static readonly TEXTURE_PLANAR_MODE: number;
  69709. /** Cubic coordinates mode */
  69710. static readonly TEXTURE_CUBIC_MODE: number;
  69711. /** Projection coordinates mode */
  69712. static readonly TEXTURE_PROJECTION_MODE: number;
  69713. /** Skybox coordinates mode */
  69714. static readonly TEXTURE_SKYBOX_MODE: number;
  69715. /** Inverse Cubic coordinates mode */
  69716. static readonly TEXTURE_INVCUBIC_MODE: number;
  69717. /** Equirectangular coordinates mode */
  69718. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69719. /** Equirectangular Fixed coordinates mode */
  69720. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69721. /** Equirectangular Fixed Mirrored coordinates mode */
  69722. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69723. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69724. static readonly SCALEMODE_FLOOR: number;
  69725. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69726. static readonly SCALEMODE_NEAREST: number;
  69727. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69728. static readonly SCALEMODE_CEILING: number;
  69729. /**
  69730. * The dirty texture flag value
  69731. */
  69732. static readonly MATERIAL_TextureDirtyFlag: number;
  69733. /**
  69734. * The dirty light flag value
  69735. */
  69736. static readonly MATERIAL_LightDirtyFlag: number;
  69737. /**
  69738. * The dirty fresnel flag value
  69739. */
  69740. static readonly MATERIAL_FresnelDirtyFlag: number;
  69741. /**
  69742. * The dirty attribute flag value
  69743. */
  69744. static readonly MATERIAL_AttributesDirtyFlag: number;
  69745. /**
  69746. * The dirty misc flag value
  69747. */
  69748. static readonly MATERIAL_MiscDirtyFlag: number;
  69749. /**
  69750. * The all dirty flag value
  69751. */
  69752. static readonly MATERIAL_AllDirtyFlag: number;
  69753. /**
  69754. * Returns the triangle fill mode
  69755. */
  69756. static readonly MATERIAL_TriangleFillMode: number;
  69757. /**
  69758. * Returns the wireframe mode
  69759. */
  69760. static readonly MATERIAL_WireFrameFillMode: number;
  69761. /**
  69762. * Returns the point fill mode
  69763. */
  69764. static readonly MATERIAL_PointFillMode: number;
  69765. /**
  69766. * Returns the point list draw mode
  69767. */
  69768. static readonly MATERIAL_PointListDrawMode: number;
  69769. /**
  69770. * Returns the line list draw mode
  69771. */
  69772. static readonly MATERIAL_LineListDrawMode: number;
  69773. /**
  69774. * Returns the line loop draw mode
  69775. */
  69776. static readonly MATERIAL_LineLoopDrawMode: number;
  69777. /**
  69778. * Returns the line strip draw mode
  69779. */
  69780. static readonly MATERIAL_LineStripDrawMode: number;
  69781. /**
  69782. * Returns the triangle strip draw mode
  69783. */
  69784. static readonly MATERIAL_TriangleStripDrawMode: number;
  69785. /**
  69786. * Returns the triangle fan draw mode
  69787. */
  69788. static readonly MATERIAL_TriangleFanDrawMode: number;
  69789. /**
  69790. * Stores the clock-wise side orientation
  69791. */
  69792. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69793. /**
  69794. * Stores the counter clock-wise side orientation
  69795. */
  69796. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69797. /**
  69798. * Nothing
  69799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69800. */
  69801. static readonly ACTION_NothingTrigger: number;
  69802. /**
  69803. * On pick
  69804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69805. */
  69806. static readonly ACTION_OnPickTrigger: number;
  69807. /**
  69808. * On left pick
  69809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69810. */
  69811. static readonly ACTION_OnLeftPickTrigger: number;
  69812. /**
  69813. * On right pick
  69814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69815. */
  69816. static readonly ACTION_OnRightPickTrigger: number;
  69817. /**
  69818. * On center pick
  69819. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69820. */
  69821. static readonly ACTION_OnCenterPickTrigger: number;
  69822. /**
  69823. * On pick down
  69824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69825. */
  69826. static readonly ACTION_OnPickDownTrigger: number;
  69827. /**
  69828. * On double pick
  69829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69830. */
  69831. static readonly ACTION_OnDoublePickTrigger: number;
  69832. /**
  69833. * On pick up
  69834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69835. */
  69836. static readonly ACTION_OnPickUpTrigger: number;
  69837. /**
  69838. * On pick out.
  69839. * This trigger will only be raised if you also declared a OnPickDown
  69840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69841. */
  69842. static readonly ACTION_OnPickOutTrigger: number;
  69843. /**
  69844. * On long press
  69845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69846. */
  69847. static readonly ACTION_OnLongPressTrigger: number;
  69848. /**
  69849. * On pointer over
  69850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69851. */
  69852. static readonly ACTION_OnPointerOverTrigger: number;
  69853. /**
  69854. * On pointer out
  69855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69856. */
  69857. static readonly ACTION_OnPointerOutTrigger: number;
  69858. /**
  69859. * On every frame
  69860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69861. */
  69862. static readonly ACTION_OnEveryFrameTrigger: number;
  69863. /**
  69864. * On intersection enter
  69865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69866. */
  69867. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69868. /**
  69869. * On intersection exit
  69870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69871. */
  69872. static readonly ACTION_OnIntersectionExitTrigger: number;
  69873. /**
  69874. * On key down
  69875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69876. */
  69877. static readonly ACTION_OnKeyDownTrigger: number;
  69878. /**
  69879. * On key up
  69880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69881. */
  69882. static readonly ACTION_OnKeyUpTrigger: number;
  69883. /**
  69884. * Billboard mode will only apply to Y axis
  69885. */
  69886. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69887. /**
  69888. * Billboard mode will apply to all axes
  69889. */
  69890. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69891. /**
  69892. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69893. */
  69894. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69895. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69896. * Test order :
  69897. * Is the bounding sphere outside the frustum ?
  69898. * If not, are the bounding box vertices outside the frustum ?
  69899. * It not, then the cullable object is in the frustum.
  69900. */
  69901. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69902. /** Culling strategy : Bounding Sphere Only.
  69903. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69904. * It's also less accurate than the standard because some not visible objects can still be selected.
  69905. * Test : is the bounding sphere outside the frustum ?
  69906. * If not, then the cullable object is in the frustum.
  69907. */
  69908. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69909. /** Culling strategy : Optimistic Inclusion.
  69910. * This in an inclusion test first, then the standard exclusion test.
  69911. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69912. * 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.
  69913. * Anyway, it's as accurate as the standard strategy.
  69914. * Test :
  69915. * Is the cullable object bounding sphere center in the frustum ?
  69916. * If not, apply the default culling strategy.
  69917. */
  69918. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69919. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69920. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69921. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69922. * 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.
  69923. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69924. * Test :
  69925. * Is the cullable object bounding sphere center in the frustum ?
  69926. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69927. */
  69928. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69929. /**
  69930. * No logging while loading
  69931. */
  69932. static readonly SCENELOADER_NO_LOGGING: number;
  69933. /**
  69934. * Minimal logging while loading
  69935. */
  69936. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69937. /**
  69938. * Summary logging while loading
  69939. */
  69940. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69941. /**
  69942. * Detailled logging while loading
  69943. */
  69944. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69945. }
  69946. }
  69947. declare module BABYLON {
  69948. /**
  69949. * This represents the required contract to create a new type of texture loader.
  69950. */
  69951. export interface IInternalTextureLoader {
  69952. /**
  69953. * Defines wether the loader supports cascade loading the different faces.
  69954. */
  69955. supportCascades: boolean;
  69956. /**
  69957. * This returns if the loader support the current file information.
  69958. * @param extension defines the file extension of the file being loaded
  69959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69960. * @param fallback defines the fallback internal texture if any
  69961. * @param isBase64 defines whether the texture is encoded as a base64
  69962. * @param isBuffer defines whether the texture data are stored as a buffer
  69963. * @returns true if the loader can load the specified file
  69964. */
  69965. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69966. /**
  69967. * Transform the url before loading if required.
  69968. * @param rootUrl the url of the texture
  69969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69970. * @returns the transformed texture
  69971. */
  69972. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69973. /**
  69974. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69975. * @param rootUrl the url of the texture
  69976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69977. * @returns the fallback texture
  69978. */
  69979. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69980. /**
  69981. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69982. * @param data contains the texture data
  69983. * @param texture defines the BabylonJS internal texture
  69984. * @param createPolynomials will be true if polynomials have been requested
  69985. * @param onLoad defines the callback to trigger once the texture is ready
  69986. * @param onError defines the callback to trigger in case of error
  69987. */
  69988. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69989. /**
  69990. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69991. * @param data contains the texture data
  69992. * @param texture defines the BabylonJS internal texture
  69993. * @param callback defines the method to call once ready to upload
  69994. */
  69995. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69996. }
  69997. }
  69998. declare module BABYLON {
  69999. /**
  70000. * Class used to store and describe the pipeline context associated with an effect
  70001. */
  70002. export interface IPipelineContext {
  70003. /**
  70004. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70005. */
  70006. isAsync: boolean;
  70007. /**
  70008. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70009. */
  70010. isReady: boolean;
  70011. /** @hidden */
  70012. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70013. }
  70014. }
  70015. declare module BABYLON {
  70016. /**
  70017. * Class used to store gfx data (like WebGLBuffer)
  70018. */
  70019. export class DataBuffer {
  70020. /**
  70021. * Gets or sets the number of objects referencing this buffer
  70022. */
  70023. references: number;
  70024. /** Gets or sets the size of the underlying buffer */
  70025. capacity: number;
  70026. /**
  70027. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70028. */
  70029. is32Bits: boolean;
  70030. /**
  70031. * Gets the underlying buffer
  70032. */
  70033. readonly underlyingResource: any;
  70034. }
  70035. }
  70036. declare module BABYLON {
  70037. /** @hidden */
  70038. export interface IShaderProcessor {
  70039. attributeProcessor?: (attribute: string) => string;
  70040. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70041. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70042. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70043. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70044. lineProcessor?: (line: string, isFragment: boolean) => string;
  70045. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70046. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70047. }
  70048. }
  70049. declare module BABYLON {
  70050. /** @hidden */
  70051. export interface ProcessingOptions {
  70052. defines: string[];
  70053. indexParameters: any;
  70054. isFragment: boolean;
  70055. shouldUseHighPrecisionShader: boolean;
  70056. supportsUniformBuffers: boolean;
  70057. shadersRepository: string;
  70058. includesShadersStore: {
  70059. [key: string]: string;
  70060. };
  70061. processor?: IShaderProcessor;
  70062. version: string;
  70063. platformName: string;
  70064. lookForClosingBracketForUniformBuffer?: boolean;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. /** @hidden */
  70069. export class ShaderCodeNode {
  70070. line: string;
  70071. children: ShaderCodeNode[];
  70072. additionalDefineKey?: string;
  70073. additionalDefineValue?: string;
  70074. isValid(preprocessors: {
  70075. [key: string]: string;
  70076. }): boolean;
  70077. process(preprocessors: {
  70078. [key: string]: string;
  70079. }, options: ProcessingOptions): string;
  70080. }
  70081. }
  70082. declare module BABYLON {
  70083. /** @hidden */
  70084. export class ShaderCodeCursor {
  70085. private _lines;
  70086. lineIndex: number;
  70087. readonly currentLine: string;
  70088. readonly canRead: boolean;
  70089. lines: string[];
  70090. }
  70091. }
  70092. declare module BABYLON {
  70093. /** @hidden */
  70094. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70095. process(preprocessors: {
  70096. [key: string]: string;
  70097. }, options: ProcessingOptions): string;
  70098. }
  70099. }
  70100. declare module BABYLON {
  70101. /** @hidden */
  70102. export class ShaderDefineExpression {
  70103. isTrue(preprocessors: {
  70104. [key: string]: string;
  70105. }): boolean;
  70106. }
  70107. }
  70108. declare module BABYLON {
  70109. /** @hidden */
  70110. export class ShaderCodeTestNode extends ShaderCodeNode {
  70111. testExpression: ShaderDefineExpression;
  70112. isValid(preprocessors: {
  70113. [key: string]: string;
  70114. }): boolean;
  70115. }
  70116. }
  70117. declare module BABYLON {
  70118. /** @hidden */
  70119. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70120. define: string;
  70121. not: boolean;
  70122. constructor(define: string, not?: boolean);
  70123. isTrue(preprocessors: {
  70124. [key: string]: string;
  70125. }): boolean;
  70126. }
  70127. }
  70128. declare module BABYLON {
  70129. /** @hidden */
  70130. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70131. leftOperand: ShaderDefineExpression;
  70132. rightOperand: ShaderDefineExpression;
  70133. isTrue(preprocessors: {
  70134. [key: string]: string;
  70135. }): boolean;
  70136. }
  70137. }
  70138. declare module BABYLON {
  70139. /** @hidden */
  70140. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70141. leftOperand: ShaderDefineExpression;
  70142. rightOperand: ShaderDefineExpression;
  70143. isTrue(preprocessors: {
  70144. [key: string]: string;
  70145. }): boolean;
  70146. }
  70147. }
  70148. declare module BABYLON {
  70149. /** @hidden */
  70150. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70151. define: string;
  70152. operand: string;
  70153. testValue: string;
  70154. constructor(define: string, operand: string, testValue: string);
  70155. isTrue(preprocessors: {
  70156. [key: string]: string;
  70157. }): boolean;
  70158. }
  70159. }
  70160. declare module BABYLON {
  70161. /**
  70162. * Class used to enable access to offline support
  70163. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70164. */
  70165. export interface IOfflineProvider {
  70166. /**
  70167. * Gets a boolean indicating if scene must be saved in the database
  70168. */
  70169. enableSceneOffline: boolean;
  70170. /**
  70171. * Gets a boolean indicating if textures must be saved in the database
  70172. */
  70173. enableTexturesOffline: boolean;
  70174. /**
  70175. * Open the offline support and make it available
  70176. * @param successCallback defines the callback to call on success
  70177. * @param errorCallback defines the callback to call on error
  70178. */
  70179. open(successCallback: () => void, errorCallback: () => void): void;
  70180. /**
  70181. * Loads an image from the offline support
  70182. * @param url defines the url to load from
  70183. * @param image defines the target DOM image
  70184. */
  70185. loadImage(url: string, image: HTMLImageElement): void;
  70186. /**
  70187. * Loads a file from offline support
  70188. * @param url defines the URL to load from
  70189. * @param sceneLoaded defines a callback to call on success
  70190. * @param progressCallBack defines a callback to call when progress changed
  70191. * @param errorCallback defines a callback to call on error
  70192. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70193. */
  70194. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70195. }
  70196. }
  70197. declare module BABYLON {
  70198. /**
  70199. * Class used to help managing file picking and drag'n'drop
  70200. * File Storage
  70201. */
  70202. export class FilesInputStore {
  70203. /**
  70204. * List of files ready to be loaded
  70205. */
  70206. static FilesToLoad: {
  70207. [key: string]: File;
  70208. };
  70209. }
  70210. }
  70211. declare module BABYLON {
  70212. /**
  70213. * Class used to define a retry strategy when error happens while loading assets
  70214. */
  70215. export class RetryStrategy {
  70216. /**
  70217. * Function used to defines an exponential back off strategy
  70218. * @param maxRetries defines the maximum number of retries (3 by default)
  70219. * @param baseInterval defines the interval between retries
  70220. * @returns the strategy function to use
  70221. */
  70222. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70223. }
  70224. }
  70225. declare module BABYLON {
  70226. /**
  70227. * @ignore
  70228. * Application error to support additional information when loading a file
  70229. */
  70230. export abstract class BaseError extends Error {
  70231. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70232. }
  70233. }
  70234. declare module BABYLON {
  70235. /** @ignore */
  70236. export class LoadFileError extends BaseError {
  70237. request?: WebRequest;
  70238. file?: File;
  70239. /**
  70240. * Creates a new LoadFileError
  70241. * @param message defines the message of the error
  70242. * @param request defines the optional web request
  70243. * @param file defines the optional file
  70244. */
  70245. constructor(message: string, object?: WebRequest | File);
  70246. }
  70247. /** @ignore */
  70248. export class RequestFileError extends BaseError {
  70249. request: WebRequest;
  70250. /**
  70251. * Creates a new LoadFileError
  70252. * @param message defines the message of the error
  70253. * @param request defines the optional web request
  70254. */
  70255. constructor(message: string, request: WebRequest);
  70256. }
  70257. /** @ignore */
  70258. export class ReadFileError extends BaseError {
  70259. file: File;
  70260. /**
  70261. * Creates a new ReadFileError
  70262. * @param message defines the message of the error
  70263. * @param file defines the optional file
  70264. */
  70265. constructor(message: string, file: File);
  70266. }
  70267. /**
  70268. * @hidden
  70269. */
  70270. export class FileTools {
  70271. /**
  70272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70273. */
  70274. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70275. /**
  70276. * Gets or sets the base URL to use to load assets
  70277. */
  70278. static BaseUrl: string;
  70279. /**
  70280. * Default behaviour for cors in the application.
  70281. * It can be a string if the expected behavior is identical in the entire app.
  70282. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70283. */
  70284. static CorsBehavior: string | ((url: string | string[]) => string);
  70285. /**
  70286. * Gets or sets a function used to pre-process url before using them to load assets
  70287. */
  70288. static PreprocessUrl: (url: string) => string;
  70289. /**
  70290. * Removes unwanted characters from an url
  70291. * @param url defines the url to clean
  70292. * @returns the cleaned url
  70293. */
  70294. private static _CleanUrl;
  70295. /**
  70296. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70297. * @param url define the url we are trying
  70298. * @param element define the dom element where to configure the cors policy
  70299. */
  70300. static SetCorsBehavior(url: string | string[], element: {
  70301. crossOrigin: string | null;
  70302. }): void;
  70303. /**
  70304. * Loads an image as an HTMLImageElement.
  70305. * @param input url string, ArrayBuffer, or Blob to load
  70306. * @param onLoad callback called when the image successfully loads
  70307. * @param onError callback called when the image fails to load
  70308. * @param offlineProvider offline provider for caching
  70309. * @param mimeType optional mime type
  70310. * @returns the HTMLImageElement of the loaded image
  70311. */
  70312. 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>;
  70313. /**
  70314. * Reads a file from a File object
  70315. * @param file defines the file to load
  70316. * @param onSuccess defines the callback to call when data is loaded
  70317. * @param onProgress defines the callback to call during loading process
  70318. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70319. * @param onError defines the callback to call when an error occurs
  70320. * @returns a file request object
  70321. */
  70322. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70323. /**
  70324. * Loads a file from a url
  70325. * @param url url to load
  70326. * @param onSuccess callback called when the file successfully loads
  70327. * @param onProgress callback called while file is loading (if the server supports this mode)
  70328. * @param offlineProvider defines the offline provider for caching
  70329. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70330. * @param onError callback called when the file fails to load
  70331. * @returns a file request object
  70332. */
  70333. 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;
  70334. /**
  70335. * Loads a file
  70336. * @param url url to load
  70337. * @param onSuccess callback called when the file successfully loads
  70338. * @param onProgress callback called while file is loading (if the server supports this mode)
  70339. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70340. * @param onError callback called when the file fails to load
  70341. * @param onOpened callback called when the web request is opened
  70342. * @returns a file request object
  70343. */
  70344. 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;
  70345. /**
  70346. * Checks if the loaded document was accessed via `file:`-Protocol.
  70347. * @returns boolean
  70348. */
  70349. static IsFileURL(): boolean;
  70350. }
  70351. }
  70352. declare module BABYLON {
  70353. /** @hidden */
  70354. export class ShaderProcessor {
  70355. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70356. private static _ProcessPrecision;
  70357. private static _ExtractOperation;
  70358. private static _BuildSubExpression;
  70359. private static _BuildExpression;
  70360. private static _MoveCursorWithinIf;
  70361. private static _MoveCursor;
  70362. private static _EvaluatePreProcessors;
  70363. private static _PreparePreProcessors;
  70364. private static _ProcessShaderConversion;
  70365. private static _ProcessIncludes;
  70366. }
  70367. }
  70368. declare module BABYLON {
  70369. /**
  70370. * @hidden
  70371. */
  70372. export interface IColor4Like {
  70373. r: float;
  70374. g: float;
  70375. b: float;
  70376. a: float;
  70377. }
  70378. /**
  70379. * @hidden
  70380. */
  70381. export interface IColor3Like {
  70382. r: float;
  70383. g: float;
  70384. b: float;
  70385. }
  70386. /**
  70387. * @hidden
  70388. */
  70389. export interface IVector4Like {
  70390. x: float;
  70391. y: float;
  70392. z: float;
  70393. w: float;
  70394. }
  70395. /**
  70396. * @hidden
  70397. */
  70398. export interface IVector3Like {
  70399. x: float;
  70400. y: float;
  70401. z: float;
  70402. }
  70403. /**
  70404. * @hidden
  70405. */
  70406. export interface IVector2Like {
  70407. x: float;
  70408. y: float;
  70409. }
  70410. /**
  70411. * @hidden
  70412. */
  70413. export interface IMatrixLike {
  70414. toArray(): DeepImmutable<Float32Array>;
  70415. updateFlag: int;
  70416. }
  70417. /**
  70418. * @hidden
  70419. */
  70420. export interface IViewportLike {
  70421. x: float;
  70422. y: float;
  70423. width: float;
  70424. height: float;
  70425. }
  70426. /**
  70427. * @hidden
  70428. */
  70429. export interface IPlaneLike {
  70430. normal: IVector3Like;
  70431. d: float;
  70432. normalize(): void;
  70433. }
  70434. }
  70435. declare module BABYLON {
  70436. /**
  70437. * Interface used to define common properties for effect fallbacks
  70438. */
  70439. export interface IEffectFallbacks {
  70440. /**
  70441. * Removes the defines that should be removed when falling back.
  70442. * @param currentDefines defines the current define statements for the shader.
  70443. * @param effect defines the current effect we try to compile
  70444. * @returns The resulting defines with defines of the current rank removed.
  70445. */
  70446. reduce(currentDefines: string, effect: Effect): string;
  70447. /**
  70448. * Removes the fallback from the bound mesh.
  70449. */
  70450. unBindMesh(): void;
  70451. /**
  70452. * Checks to see if more fallbacks are still availible.
  70453. */
  70454. hasMoreFallbacks: boolean;
  70455. }
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. * Class used to evalaute queries containing `and` and `or` operators
  70460. */
  70461. export class AndOrNotEvaluator {
  70462. /**
  70463. * Evaluate a query
  70464. * @param query defines the query to evaluate
  70465. * @param evaluateCallback defines the callback used to filter result
  70466. * @returns true if the query matches
  70467. */
  70468. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70469. private static _HandleParenthesisContent;
  70470. private static _SimplifyNegation;
  70471. }
  70472. }
  70473. declare module BABYLON {
  70474. /**
  70475. * Class used to store custom tags
  70476. */
  70477. export class Tags {
  70478. /**
  70479. * Adds support for tags on the given object
  70480. * @param obj defines the object to use
  70481. */
  70482. static EnableFor(obj: any): void;
  70483. /**
  70484. * Removes tags support
  70485. * @param obj defines the object to use
  70486. */
  70487. static DisableFor(obj: any): void;
  70488. /**
  70489. * Gets a boolean indicating if the given object has tags
  70490. * @param obj defines the object to use
  70491. * @returns a boolean
  70492. */
  70493. static HasTags(obj: any): boolean;
  70494. /**
  70495. * Gets the tags available on a given object
  70496. * @param obj defines the object to use
  70497. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70498. * @returns the tags
  70499. */
  70500. static GetTags(obj: any, asString?: boolean): any;
  70501. /**
  70502. * Adds tags to an object
  70503. * @param obj defines the object to use
  70504. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70505. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70506. */
  70507. static AddTagsTo(obj: any, tagsString: string): void;
  70508. /**
  70509. * @hidden
  70510. */
  70511. static _AddTagTo(obj: any, tag: string): void;
  70512. /**
  70513. * Removes specific tags from a specific object
  70514. * @param obj defines the object to use
  70515. * @param tagsString defines the tags to remove
  70516. */
  70517. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70518. /**
  70519. * @hidden
  70520. */
  70521. static _RemoveTagFrom(obj: any, tag: string): void;
  70522. /**
  70523. * Defines if tags hosted on an object match a given query
  70524. * @param obj defines the object to use
  70525. * @param tagsQuery defines the tag query
  70526. * @returns a boolean
  70527. */
  70528. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70529. }
  70530. }
  70531. declare module BABYLON {
  70532. /**
  70533. * Scalar computation library
  70534. */
  70535. export class Scalar {
  70536. /**
  70537. * Two pi constants convenient for computation.
  70538. */
  70539. static TwoPi: number;
  70540. /**
  70541. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70542. * @param a number
  70543. * @param b number
  70544. * @param epsilon (default = 1.401298E-45)
  70545. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70546. */
  70547. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70548. /**
  70549. * Returns a string : the upper case translation of the number i to hexadecimal.
  70550. * @param i number
  70551. * @returns the upper case translation of the number i to hexadecimal.
  70552. */
  70553. static ToHex(i: number): string;
  70554. /**
  70555. * Returns -1 if value is negative and +1 is value is positive.
  70556. * @param value the value
  70557. * @returns the value itself if it's equal to zero.
  70558. */
  70559. static Sign(value: number): number;
  70560. /**
  70561. * Returns the value itself if it's between min and max.
  70562. * Returns min if the value is lower than min.
  70563. * Returns max if the value is greater than max.
  70564. * @param value the value to clmap
  70565. * @param min the min value to clamp to (default: 0)
  70566. * @param max the max value to clamp to (default: 1)
  70567. * @returns the clamped value
  70568. */
  70569. static Clamp(value: number, min?: number, max?: number): number;
  70570. /**
  70571. * the log2 of value.
  70572. * @param value the value to compute log2 of
  70573. * @returns the log2 of value.
  70574. */
  70575. static Log2(value: number): number;
  70576. /**
  70577. * Loops the value, so that it is never larger than length and never smaller than 0.
  70578. *
  70579. * This is similar to the modulo operator but it works with floating point numbers.
  70580. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70581. * With t = 5 and length = 2.5, the result would be 0.0.
  70582. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70583. * @param value the value
  70584. * @param length the length
  70585. * @returns the looped value
  70586. */
  70587. static Repeat(value: number, length: number): number;
  70588. /**
  70589. * Normalize the value between 0.0 and 1.0 using min and max values
  70590. * @param value value to normalize
  70591. * @param min max to normalize between
  70592. * @param max min to normalize between
  70593. * @returns the normalized value
  70594. */
  70595. static Normalize(value: number, min: number, max: number): number;
  70596. /**
  70597. * Denormalize the value from 0.0 and 1.0 using min and max values
  70598. * @param normalized value to denormalize
  70599. * @param min max to denormalize between
  70600. * @param max min to denormalize between
  70601. * @returns the denormalized value
  70602. */
  70603. static Denormalize(normalized: number, min: number, max: number): number;
  70604. /**
  70605. * Calculates the shortest difference between two given angles given in degrees.
  70606. * @param current current angle in degrees
  70607. * @param target target angle in degrees
  70608. * @returns the delta
  70609. */
  70610. static DeltaAngle(current: number, target: number): number;
  70611. /**
  70612. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70613. * @param tx value
  70614. * @param length length
  70615. * @returns The returned value will move back and forth between 0 and length
  70616. */
  70617. static PingPong(tx: number, length: number): number;
  70618. /**
  70619. * Interpolates between min and max with smoothing at the limits.
  70620. *
  70621. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70622. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70623. * @param from from
  70624. * @param to to
  70625. * @param tx value
  70626. * @returns the smooth stepped value
  70627. */
  70628. static SmoothStep(from: number, to: number, tx: number): number;
  70629. /**
  70630. * Moves a value current towards target.
  70631. *
  70632. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70633. * Negative values of maxDelta pushes the value away from target.
  70634. * @param current current value
  70635. * @param target target value
  70636. * @param maxDelta max distance to move
  70637. * @returns resulting value
  70638. */
  70639. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70640. /**
  70641. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70642. *
  70643. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70644. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70645. * @param current current value
  70646. * @param target target value
  70647. * @param maxDelta max distance to move
  70648. * @returns resulting angle
  70649. */
  70650. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70651. /**
  70652. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70653. * @param start start value
  70654. * @param end target value
  70655. * @param amount amount to lerp between
  70656. * @returns the lerped value
  70657. */
  70658. static Lerp(start: number, end: number, amount: number): number;
  70659. /**
  70660. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70661. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70662. * @param start start value
  70663. * @param end target value
  70664. * @param amount amount to lerp between
  70665. * @returns the lerped value
  70666. */
  70667. static LerpAngle(start: number, end: number, amount: number): number;
  70668. /**
  70669. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70670. * @param a start value
  70671. * @param b target value
  70672. * @param value value between a and b
  70673. * @returns the inverseLerp value
  70674. */
  70675. static InverseLerp(a: number, b: number, value: number): number;
  70676. /**
  70677. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70678. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70679. * @param value1 spline value
  70680. * @param tangent1 spline value
  70681. * @param value2 spline value
  70682. * @param tangent2 spline value
  70683. * @param amount input value
  70684. * @returns hermite result
  70685. */
  70686. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70687. /**
  70688. * Returns a random float number between and min and max values
  70689. * @param min min value of random
  70690. * @param max max value of random
  70691. * @returns random value
  70692. */
  70693. static RandomRange(min: number, max: number): number;
  70694. /**
  70695. * This function returns percentage of a number in a given range.
  70696. *
  70697. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70698. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70699. * @param number to convert to percentage
  70700. * @param min min range
  70701. * @param max max range
  70702. * @returns the percentage
  70703. */
  70704. static RangeToPercent(number: number, min: number, max: number): number;
  70705. /**
  70706. * This function returns number that corresponds to the percentage in a given range.
  70707. *
  70708. * PercentToRange(0.34,0,100) will return 34.
  70709. * @param percent to convert to number
  70710. * @param min min range
  70711. * @param max max range
  70712. * @returns the number
  70713. */
  70714. static PercentToRange(percent: number, min: number, max: number): number;
  70715. /**
  70716. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70717. * @param angle The angle to normalize in radian.
  70718. * @return The converted angle.
  70719. */
  70720. static NormalizeRadians(angle: number): number;
  70721. }
  70722. }
  70723. declare module BABYLON {
  70724. /**
  70725. * Constant used to convert a value to gamma space
  70726. * @ignorenaming
  70727. */
  70728. export const ToGammaSpace: number;
  70729. /**
  70730. * Constant used to convert a value to linear space
  70731. * @ignorenaming
  70732. */
  70733. export const ToLinearSpace = 2.2;
  70734. /**
  70735. * Constant used to define the minimal number value in Babylon.js
  70736. * @ignorenaming
  70737. */
  70738. let Epsilon: number;
  70739. }
  70740. declare module BABYLON {
  70741. /**
  70742. * Class used to represent a viewport on screen
  70743. */
  70744. export class Viewport {
  70745. /** viewport left coordinate */
  70746. x: number;
  70747. /** viewport top coordinate */
  70748. y: number;
  70749. /**viewport width */
  70750. width: number;
  70751. /** viewport height */
  70752. height: number;
  70753. /**
  70754. * Creates a Viewport object located at (x, y) and sized (width, height)
  70755. * @param x defines viewport left coordinate
  70756. * @param y defines viewport top coordinate
  70757. * @param width defines the viewport width
  70758. * @param height defines the viewport height
  70759. */
  70760. constructor(
  70761. /** viewport left coordinate */
  70762. x: number,
  70763. /** viewport top coordinate */
  70764. y: number,
  70765. /**viewport width */
  70766. width: number,
  70767. /** viewport height */
  70768. height: number);
  70769. /**
  70770. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70771. * @param renderWidth defines the rendering width
  70772. * @param renderHeight defines the rendering height
  70773. * @returns a new Viewport
  70774. */
  70775. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70776. /**
  70777. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70778. * @param renderWidth defines the rendering width
  70779. * @param renderHeight defines the rendering height
  70780. * @param ref defines the target viewport
  70781. * @returns the current viewport
  70782. */
  70783. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70784. /**
  70785. * Returns a new Viewport copied from the current one
  70786. * @returns a new Viewport
  70787. */
  70788. clone(): Viewport;
  70789. }
  70790. }
  70791. declare module BABYLON {
  70792. /**
  70793. * Class containing a set of static utilities functions for arrays.
  70794. */
  70795. export class ArrayTools {
  70796. /**
  70797. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70798. * @param size the number of element to construct and put in the array
  70799. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70800. * @returns a new array filled with new objects
  70801. */
  70802. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70803. }
  70804. }
  70805. declare module BABYLON {
  70806. /**
  70807. * Class representing a vector containing 2 coordinates
  70808. */
  70809. export class Vector2 {
  70810. /** defines the first coordinate */
  70811. x: number;
  70812. /** defines the second coordinate */
  70813. y: number;
  70814. /**
  70815. * Creates a new Vector2 from the given x and y coordinates
  70816. * @param x defines the first coordinate
  70817. * @param y defines the second coordinate
  70818. */
  70819. constructor(
  70820. /** defines the first coordinate */
  70821. x?: number,
  70822. /** defines the second coordinate */
  70823. y?: number);
  70824. /**
  70825. * Gets a string with the Vector2 coordinates
  70826. * @returns a string with the Vector2 coordinates
  70827. */
  70828. toString(): string;
  70829. /**
  70830. * Gets class name
  70831. * @returns the string "Vector2"
  70832. */
  70833. getClassName(): string;
  70834. /**
  70835. * Gets current vector hash code
  70836. * @returns the Vector2 hash code as a number
  70837. */
  70838. getHashCode(): number;
  70839. /**
  70840. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70841. * @param array defines the source array
  70842. * @param index defines the offset in source array
  70843. * @returns the current Vector2
  70844. */
  70845. toArray(array: FloatArray, index?: number): Vector2;
  70846. /**
  70847. * Copy the current vector to an array
  70848. * @returns a new array with 2 elements: the Vector2 coordinates.
  70849. */
  70850. asArray(): number[];
  70851. /**
  70852. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70853. * @param source defines the source Vector2
  70854. * @returns the current updated Vector2
  70855. */
  70856. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70857. /**
  70858. * Sets the Vector2 coordinates with the given floats
  70859. * @param x defines the first coordinate
  70860. * @param y defines the second coordinate
  70861. * @returns the current updated Vector2
  70862. */
  70863. copyFromFloats(x: number, y: number): Vector2;
  70864. /**
  70865. * Sets the Vector2 coordinates with the given floats
  70866. * @param x defines the first coordinate
  70867. * @param y defines the second coordinate
  70868. * @returns the current updated Vector2
  70869. */
  70870. set(x: number, y: number): Vector2;
  70871. /**
  70872. * Add another vector with the current one
  70873. * @param otherVector defines the other vector
  70874. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70875. */
  70876. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70877. /**
  70878. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70879. * @param otherVector defines the other vector
  70880. * @param result defines the target vector
  70881. * @returns the unmodified current Vector2
  70882. */
  70883. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70884. /**
  70885. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70886. * @param otherVector defines the other vector
  70887. * @returns the current updated Vector2
  70888. */
  70889. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70890. /**
  70891. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70892. * @param otherVector defines the other vector
  70893. * @returns a new Vector2
  70894. */
  70895. addVector3(otherVector: Vector3): Vector2;
  70896. /**
  70897. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70898. * @param otherVector defines the other vector
  70899. * @returns a new Vector2
  70900. */
  70901. subtract(otherVector: Vector2): Vector2;
  70902. /**
  70903. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70904. * @param otherVector defines the other vector
  70905. * @param result defines the target vector
  70906. * @returns the unmodified current Vector2
  70907. */
  70908. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70909. /**
  70910. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70911. * @param otherVector defines the other vector
  70912. * @returns the current updated Vector2
  70913. */
  70914. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70915. /**
  70916. * Multiplies in place the current Vector2 coordinates by the given ones
  70917. * @param otherVector defines the other vector
  70918. * @returns the current updated Vector2
  70919. */
  70920. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70921. /**
  70922. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70923. * @param otherVector defines the other vector
  70924. * @returns a new Vector2
  70925. */
  70926. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70927. /**
  70928. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70929. * @param otherVector defines the other vector
  70930. * @param result defines the target vector
  70931. * @returns the unmodified current Vector2
  70932. */
  70933. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70934. /**
  70935. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70936. * @param x defines the first coordinate
  70937. * @param y defines the second coordinate
  70938. * @returns a new Vector2
  70939. */
  70940. multiplyByFloats(x: number, y: number): Vector2;
  70941. /**
  70942. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70943. * @param otherVector defines the other vector
  70944. * @returns a new Vector2
  70945. */
  70946. divide(otherVector: Vector2): Vector2;
  70947. /**
  70948. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70949. * @param otherVector defines the other vector
  70950. * @param result defines the target vector
  70951. * @returns the unmodified current Vector2
  70952. */
  70953. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70954. /**
  70955. * Divides the current Vector2 coordinates by the given ones
  70956. * @param otherVector defines the other vector
  70957. * @returns the current updated Vector2
  70958. */
  70959. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70960. /**
  70961. * Gets a new Vector2 with current Vector2 negated coordinates
  70962. * @returns a new Vector2
  70963. */
  70964. negate(): Vector2;
  70965. /**
  70966. * Multiply the Vector2 coordinates by scale
  70967. * @param scale defines the scaling factor
  70968. * @returns the current updated Vector2
  70969. */
  70970. scaleInPlace(scale: number): Vector2;
  70971. /**
  70972. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70973. * @param scale defines the scaling factor
  70974. * @returns a new Vector2
  70975. */
  70976. scale(scale: number): Vector2;
  70977. /**
  70978. * Scale the current Vector2 values by a factor to a given Vector2
  70979. * @param scale defines the scale factor
  70980. * @param result defines the Vector2 object where to store the result
  70981. * @returns the unmodified current Vector2
  70982. */
  70983. scaleToRef(scale: number, result: Vector2): Vector2;
  70984. /**
  70985. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70986. * @param scale defines the scale factor
  70987. * @param result defines the Vector2 object where to store the result
  70988. * @returns the unmodified current Vector2
  70989. */
  70990. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70991. /**
  70992. * Gets a boolean if two vectors are equals
  70993. * @param otherVector defines the other vector
  70994. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70995. */
  70996. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70997. /**
  70998. * Gets a boolean if two vectors are equals (using an epsilon value)
  70999. * @param otherVector defines the other vector
  71000. * @param epsilon defines the minimal distance to consider equality
  71001. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71002. */
  71003. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71004. /**
  71005. * Gets a new Vector2 from current Vector2 floored values
  71006. * @returns a new Vector2
  71007. */
  71008. floor(): Vector2;
  71009. /**
  71010. * Gets a new Vector2 from current Vector2 floored values
  71011. * @returns a new Vector2
  71012. */
  71013. fract(): Vector2;
  71014. /**
  71015. * Gets the length of the vector
  71016. * @returns the vector length (float)
  71017. */
  71018. length(): number;
  71019. /**
  71020. * Gets the vector squared length
  71021. * @returns the vector squared length (float)
  71022. */
  71023. lengthSquared(): number;
  71024. /**
  71025. * Normalize the vector
  71026. * @returns the current updated Vector2
  71027. */
  71028. normalize(): Vector2;
  71029. /**
  71030. * Gets a new Vector2 copied from the Vector2
  71031. * @returns a new Vector2
  71032. */
  71033. clone(): Vector2;
  71034. /**
  71035. * Gets a new Vector2(0, 0)
  71036. * @returns a new Vector2
  71037. */
  71038. static Zero(): Vector2;
  71039. /**
  71040. * Gets a new Vector2(1, 1)
  71041. * @returns a new Vector2
  71042. */
  71043. static One(): Vector2;
  71044. /**
  71045. * Gets a new Vector2 set from the given index element of the given array
  71046. * @param array defines the data source
  71047. * @param offset defines the offset in the data source
  71048. * @returns a new Vector2
  71049. */
  71050. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71051. /**
  71052. * Sets "result" from the given index element of the given array
  71053. * @param array defines the data source
  71054. * @param offset defines the offset in the data source
  71055. * @param result defines the target vector
  71056. */
  71057. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71058. /**
  71059. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71060. * @param value1 defines 1st point of control
  71061. * @param value2 defines 2nd point of control
  71062. * @param value3 defines 3rd point of control
  71063. * @param value4 defines 4th point of control
  71064. * @param amount defines the interpolation factor
  71065. * @returns a new Vector2
  71066. */
  71067. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71068. /**
  71069. * 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".
  71070. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71071. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71072. * @param value defines the value to clamp
  71073. * @param min defines the lower limit
  71074. * @param max defines the upper limit
  71075. * @returns a new Vector2
  71076. */
  71077. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71078. /**
  71079. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71080. * @param value1 defines the 1st control point
  71081. * @param tangent1 defines the outgoing tangent
  71082. * @param value2 defines the 2nd control point
  71083. * @param tangent2 defines the incoming tangent
  71084. * @param amount defines the interpolation factor
  71085. * @returns a new Vector2
  71086. */
  71087. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71088. /**
  71089. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71090. * @param start defines the start vector
  71091. * @param end defines the end vector
  71092. * @param amount defines the interpolation factor
  71093. * @returns a new Vector2
  71094. */
  71095. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71096. /**
  71097. * Gets the dot product of the vector "left" and the vector "right"
  71098. * @param left defines first vector
  71099. * @param right defines second vector
  71100. * @returns the dot product (float)
  71101. */
  71102. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71103. /**
  71104. * Returns a new Vector2 equal to the normalized given vector
  71105. * @param vector defines the vector to normalize
  71106. * @returns a new Vector2
  71107. */
  71108. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71109. /**
  71110. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71111. * @param left defines 1st vector
  71112. * @param right defines 2nd vector
  71113. * @returns a new Vector2
  71114. */
  71115. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71116. /**
  71117. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71118. * @param left defines 1st vector
  71119. * @param right defines 2nd vector
  71120. * @returns a new Vector2
  71121. */
  71122. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71123. /**
  71124. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71125. * @param vector defines the vector to transform
  71126. * @param transformation defines the matrix to apply
  71127. * @returns a new Vector2
  71128. */
  71129. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71130. /**
  71131. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71132. * @param vector defines the vector to transform
  71133. * @param transformation defines the matrix to apply
  71134. * @param result defines the target vector
  71135. */
  71136. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71137. /**
  71138. * Determines if a given vector is included in a triangle
  71139. * @param p defines the vector to test
  71140. * @param p0 defines 1st triangle point
  71141. * @param p1 defines 2nd triangle point
  71142. * @param p2 defines 3rd triangle point
  71143. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71144. */
  71145. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71146. /**
  71147. * Gets the distance between the vectors "value1" and "value2"
  71148. * @param value1 defines first vector
  71149. * @param value2 defines second vector
  71150. * @returns the distance between vectors
  71151. */
  71152. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71153. /**
  71154. * Returns the squared distance between the vectors "value1" and "value2"
  71155. * @param value1 defines first vector
  71156. * @param value2 defines second vector
  71157. * @returns the squared distance between vectors
  71158. */
  71159. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71160. /**
  71161. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71162. * @param value1 defines first vector
  71163. * @param value2 defines second vector
  71164. * @returns a new Vector2
  71165. */
  71166. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71167. /**
  71168. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71169. * @param p defines the middle point
  71170. * @param segA defines one point of the segment
  71171. * @param segB defines the other point of the segment
  71172. * @returns the shortest distance
  71173. */
  71174. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71175. }
  71176. /**
  71177. * Class used to store (x,y,z) vector representation
  71178. * A Vector3 is the main object used in 3D geometry
  71179. * It can represent etiher the coordinates of a point the space, either a direction
  71180. * Reminder: js uses a left handed forward facing system
  71181. */
  71182. export class Vector3 {
  71183. /**
  71184. * Defines the first coordinates (on X axis)
  71185. */
  71186. x: number;
  71187. /**
  71188. * Defines the second coordinates (on Y axis)
  71189. */
  71190. y: number;
  71191. /**
  71192. * Defines the third coordinates (on Z axis)
  71193. */
  71194. z: number;
  71195. private static _UpReadOnly;
  71196. private static _ZeroReadOnly;
  71197. /**
  71198. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71199. * @param x defines the first coordinates (on X axis)
  71200. * @param y defines the second coordinates (on Y axis)
  71201. * @param z defines the third coordinates (on Z axis)
  71202. */
  71203. constructor(
  71204. /**
  71205. * Defines the first coordinates (on X axis)
  71206. */
  71207. x?: number,
  71208. /**
  71209. * Defines the second coordinates (on Y axis)
  71210. */
  71211. y?: number,
  71212. /**
  71213. * Defines the third coordinates (on Z axis)
  71214. */
  71215. z?: number);
  71216. /**
  71217. * Creates a string representation of the Vector3
  71218. * @returns a string with the Vector3 coordinates.
  71219. */
  71220. toString(): string;
  71221. /**
  71222. * Gets the class name
  71223. * @returns the string "Vector3"
  71224. */
  71225. getClassName(): string;
  71226. /**
  71227. * Creates the Vector3 hash code
  71228. * @returns a number which tends to be unique between Vector3 instances
  71229. */
  71230. getHashCode(): number;
  71231. /**
  71232. * Creates an array containing three elements : the coordinates of the Vector3
  71233. * @returns a new array of numbers
  71234. */
  71235. asArray(): number[];
  71236. /**
  71237. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71238. * @param array defines the destination array
  71239. * @param index defines the offset in the destination array
  71240. * @returns the current Vector3
  71241. */
  71242. toArray(array: FloatArray, index?: number): Vector3;
  71243. /**
  71244. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71245. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71246. */
  71247. toQuaternion(): Quaternion;
  71248. /**
  71249. * Adds the given vector to the current Vector3
  71250. * @param otherVector defines the second operand
  71251. * @returns the current updated Vector3
  71252. */
  71253. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71254. /**
  71255. * Adds the given coordinates to the current Vector3
  71256. * @param x defines the x coordinate of the operand
  71257. * @param y defines the y coordinate of the operand
  71258. * @param z defines the z coordinate of the operand
  71259. * @returns the current updated Vector3
  71260. */
  71261. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71262. /**
  71263. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71264. * @param otherVector defines the second operand
  71265. * @returns the resulting Vector3
  71266. */
  71267. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71268. /**
  71269. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71270. * @param otherVector defines the second operand
  71271. * @param result defines the Vector3 object where to store the result
  71272. * @returns the current Vector3
  71273. */
  71274. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71275. /**
  71276. * Subtract the given vector from the current Vector3
  71277. * @param otherVector defines the second operand
  71278. * @returns the current updated Vector3
  71279. */
  71280. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71281. /**
  71282. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71283. * @param otherVector defines the second operand
  71284. * @returns the resulting Vector3
  71285. */
  71286. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71287. /**
  71288. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71289. * @param otherVector defines the second operand
  71290. * @param result defines the Vector3 object where to store the result
  71291. * @returns the current Vector3
  71292. */
  71293. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71294. /**
  71295. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71296. * @param x defines the x coordinate of the operand
  71297. * @param y defines the y coordinate of the operand
  71298. * @param z defines the z coordinate of the operand
  71299. * @returns the resulting Vector3
  71300. */
  71301. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71302. /**
  71303. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71304. * @param x defines the x coordinate of the operand
  71305. * @param y defines the y coordinate of the operand
  71306. * @param z defines the z coordinate of the operand
  71307. * @param result defines the Vector3 object where to store the result
  71308. * @returns the current Vector3
  71309. */
  71310. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71311. /**
  71312. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71313. * @returns a new Vector3
  71314. */
  71315. negate(): Vector3;
  71316. /**
  71317. * Multiplies the Vector3 coordinates by the float "scale"
  71318. * @param scale defines the multiplier factor
  71319. * @returns the current updated Vector3
  71320. */
  71321. scaleInPlace(scale: number): Vector3;
  71322. /**
  71323. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71324. * @param scale defines the multiplier factor
  71325. * @returns a new Vector3
  71326. */
  71327. scale(scale: number): Vector3;
  71328. /**
  71329. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71330. * @param scale defines the multiplier factor
  71331. * @param result defines the Vector3 object where to store the result
  71332. * @returns the current Vector3
  71333. */
  71334. scaleToRef(scale: number, result: Vector3): Vector3;
  71335. /**
  71336. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71337. * @param scale defines the scale factor
  71338. * @param result defines the Vector3 object where to store the result
  71339. * @returns the unmodified current Vector3
  71340. */
  71341. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71342. /**
  71343. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71344. * @param otherVector defines the second operand
  71345. * @returns true if both vectors are equals
  71346. */
  71347. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71348. /**
  71349. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71350. * @param otherVector defines the second operand
  71351. * @param epsilon defines the minimal distance to define values as equals
  71352. * @returns true if both vectors are distant less than epsilon
  71353. */
  71354. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71355. /**
  71356. * Returns true if the current Vector3 coordinates equals the given floats
  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. * @returns true if both vectors are equals
  71361. */
  71362. equalsToFloats(x: number, y: number, z: number): boolean;
  71363. /**
  71364. * Multiplies the current Vector3 coordinates by the given ones
  71365. * @param otherVector defines the second operand
  71366. * @returns the current updated Vector3
  71367. */
  71368. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71369. /**
  71370. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71371. * @param otherVector defines the second operand
  71372. * @returns the new Vector3
  71373. */
  71374. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71375. /**
  71376. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71377. * @param otherVector defines the second operand
  71378. * @param result defines the Vector3 object where to store the result
  71379. * @returns the current Vector3
  71380. */
  71381. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71382. /**
  71383. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71384. * @param x defines the x coordinate of the operand
  71385. * @param y defines the y coordinate of the operand
  71386. * @param z defines the z coordinate of the operand
  71387. * @returns the new Vector3
  71388. */
  71389. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71390. /**
  71391. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71392. * @param otherVector defines the second operand
  71393. * @returns the new Vector3
  71394. */
  71395. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71396. /**
  71397. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71398. * @param otherVector defines the second operand
  71399. * @param result defines the Vector3 object where to store the result
  71400. * @returns the current Vector3
  71401. */
  71402. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71403. /**
  71404. * Divides the current Vector3 coordinates by the given ones.
  71405. * @param otherVector defines the second operand
  71406. * @returns the current updated Vector3
  71407. */
  71408. divideInPlace(otherVector: Vector3): Vector3;
  71409. /**
  71410. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71411. * @param other defines the second operand
  71412. * @returns the current updated Vector3
  71413. */
  71414. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71415. /**
  71416. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71417. * @param other defines the second operand
  71418. * @returns the current updated Vector3
  71419. */
  71420. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71421. /**
  71422. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71423. * @param x defines the x coordinate of the operand
  71424. * @param y defines the y coordinate of the operand
  71425. * @param z defines the z coordinate of the operand
  71426. * @returns the current updated Vector3
  71427. */
  71428. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71429. /**
  71430. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71431. * @param x defines the x coordinate of the operand
  71432. * @param y defines the y coordinate of the operand
  71433. * @param z defines the z coordinate of the operand
  71434. * @returns the current updated Vector3
  71435. */
  71436. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71437. /**
  71438. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71439. * Check if is non uniform within a certain amount of decimal places to account for this
  71440. * @param epsilon the amount the values can differ
  71441. * @returns if the the vector is non uniform to a certain number of decimal places
  71442. */
  71443. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71444. /**
  71445. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71446. */
  71447. readonly isNonUniform: boolean;
  71448. /**
  71449. * Gets a new Vector3 from current Vector3 floored values
  71450. * @returns a new Vector3
  71451. */
  71452. floor(): Vector3;
  71453. /**
  71454. * Gets a new Vector3 from current Vector3 floored values
  71455. * @returns a new Vector3
  71456. */
  71457. fract(): Vector3;
  71458. /**
  71459. * Gets the length of the Vector3
  71460. * @returns the length of the Vector3
  71461. */
  71462. length(): number;
  71463. /**
  71464. * Gets the squared length of the Vector3
  71465. * @returns squared length of the Vector3
  71466. */
  71467. lengthSquared(): number;
  71468. /**
  71469. * Normalize the current Vector3.
  71470. * Please note that this is an in place operation.
  71471. * @returns the current updated Vector3
  71472. */
  71473. normalize(): Vector3;
  71474. /**
  71475. * Reorders the x y z properties of the vector in place
  71476. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71477. * @returns the current updated vector
  71478. */
  71479. reorderInPlace(order: string): this;
  71480. /**
  71481. * Rotates the vector around 0,0,0 by a quaternion
  71482. * @param quaternion the rotation quaternion
  71483. * @param result vector to store the result
  71484. * @returns the resulting vector
  71485. */
  71486. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71487. /**
  71488. * Rotates a vector around a given point
  71489. * @param quaternion the rotation quaternion
  71490. * @param point the point to rotate around
  71491. * @param result vector to store the result
  71492. * @returns the resulting vector
  71493. */
  71494. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71495. /**
  71496. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71497. * The cross product is then orthogonal to both current and "other"
  71498. * @param other defines the right operand
  71499. * @returns the cross product
  71500. */
  71501. cross(other: Vector3): Vector3;
  71502. /**
  71503. * Normalize the current Vector3 with the given input length.
  71504. * Please note that this is an in place operation.
  71505. * @param len the length of the vector
  71506. * @returns the current updated Vector3
  71507. */
  71508. normalizeFromLength(len: number): Vector3;
  71509. /**
  71510. * Normalize the current Vector3 to a new vector
  71511. * @returns the new Vector3
  71512. */
  71513. normalizeToNew(): Vector3;
  71514. /**
  71515. * Normalize the current Vector3 to the reference
  71516. * @param reference define the Vector3 to update
  71517. * @returns the updated Vector3
  71518. */
  71519. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71520. /**
  71521. * Creates a new Vector3 copied from the current Vector3
  71522. * @returns the new Vector3
  71523. */
  71524. clone(): Vector3;
  71525. /**
  71526. * Copies the given vector coordinates to the current Vector3 ones
  71527. * @param source defines the source Vector3
  71528. * @returns the current updated Vector3
  71529. */
  71530. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71531. /**
  71532. * Copies the given floats to the current Vector3 coordinates
  71533. * @param x defines the x coordinate of the operand
  71534. * @param y defines the y coordinate of the operand
  71535. * @param z defines the z coordinate of the operand
  71536. * @returns the current updated Vector3
  71537. */
  71538. copyFromFloats(x: number, y: number, z: number): Vector3;
  71539. /**
  71540. * Copies the given floats to the current Vector3 coordinates
  71541. * @param x defines the x coordinate of the operand
  71542. * @param y defines the y coordinate of the operand
  71543. * @param z defines the z coordinate of the operand
  71544. * @returns the current updated Vector3
  71545. */
  71546. set(x: number, y: number, z: number): Vector3;
  71547. /**
  71548. * Copies the given float to the current Vector3 coordinates
  71549. * @param v defines the x, y and z coordinates of the operand
  71550. * @returns the current updated Vector3
  71551. */
  71552. setAll(v: number): Vector3;
  71553. /**
  71554. * Get the clip factor between two vectors
  71555. * @param vector0 defines the first operand
  71556. * @param vector1 defines the second operand
  71557. * @param axis defines the axis to use
  71558. * @param size defines the size along the axis
  71559. * @returns the clip factor
  71560. */
  71561. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71562. /**
  71563. * Get angle between two vectors
  71564. * @param vector0 angle between vector0 and vector1
  71565. * @param vector1 angle between vector0 and vector1
  71566. * @param normal direction of the normal
  71567. * @return the angle between vector0 and vector1
  71568. */
  71569. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71570. /**
  71571. * Returns a new Vector3 set from the index "offset" of the given array
  71572. * @param array defines the source array
  71573. * @param offset defines the offset in the source array
  71574. * @returns the new Vector3
  71575. */
  71576. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71577. /**
  71578. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71579. * @param array defines the source array
  71580. * @param offset defines the offset in the source array
  71581. * @returns the new Vector3
  71582. * @deprecated Please use FromArray instead.
  71583. */
  71584. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71585. /**
  71586. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71587. * @param array defines the source array
  71588. * @param offset defines the offset in the source array
  71589. * @param result defines the Vector3 where to store the result
  71590. */
  71591. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71592. /**
  71593. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71594. * @param array defines the source array
  71595. * @param offset defines the offset in the source array
  71596. * @param result defines the Vector3 where to store the result
  71597. * @deprecated Please use FromArrayToRef instead.
  71598. */
  71599. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71600. /**
  71601. * Sets the given vector "result" with the given floats.
  71602. * @param x defines the x coordinate of the source
  71603. * @param y defines the y coordinate of the source
  71604. * @param z defines the z coordinate of the source
  71605. * @param result defines the Vector3 where to store the result
  71606. */
  71607. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71608. /**
  71609. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71610. * @returns a new empty Vector3
  71611. */
  71612. static Zero(): Vector3;
  71613. /**
  71614. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71615. * @returns a new unit Vector3
  71616. */
  71617. static One(): Vector3;
  71618. /**
  71619. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71620. * @returns a new up Vector3
  71621. */
  71622. static Up(): Vector3;
  71623. /**
  71624. * Gets a up Vector3 that must not be updated
  71625. */
  71626. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71627. /**
  71628. * Gets a zero Vector3 that must not be updated
  71629. */
  71630. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71631. /**
  71632. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71633. * @returns a new down Vector3
  71634. */
  71635. static Down(): Vector3;
  71636. /**
  71637. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71638. * @returns a new forward Vector3
  71639. */
  71640. static Forward(): Vector3;
  71641. /**
  71642. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71643. * @returns a new forward Vector3
  71644. */
  71645. static Backward(): Vector3;
  71646. /**
  71647. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71648. * @returns a new right Vector3
  71649. */
  71650. static Right(): Vector3;
  71651. /**
  71652. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71653. * @returns a new left Vector3
  71654. */
  71655. static Left(): Vector3;
  71656. /**
  71657. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71658. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71659. * @param vector defines the Vector3 to transform
  71660. * @param transformation defines the transformation matrix
  71661. * @returns the transformed Vector3
  71662. */
  71663. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71664. /**
  71665. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71666. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71667. * @param vector defines the Vector3 to transform
  71668. * @param transformation defines the transformation matrix
  71669. * @param result defines the Vector3 where to store the result
  71670. */
  71671. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71672. /**
  71673. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71674. * This method computes tranformed coordinates only, not transformed direction vectors
  71675. * @param x define the x coordinate of the source vector
  71676. * @param y define the y coordinate of the source vector
  71677. * @param z define the z coordinate of the source vector
  71678. * @param transformation defines the transformation matrix
  71679. * @param result defines the Vector3 where to store the result
  71680. */
  71681. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71682. /**
  71683. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71684. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71685. * @param vector defines the Vector3 to transform
  71686. * @param transformation defines the transformation matrix
  71687. * @returns the new Vector3
  71688. */
  71689. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71690. /**
  71691. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71692. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71693. * @param vector defines the Vector3 to transform
  71694. * @param transformation defines the transformation matrix
  71695. * @param result defines the Vector3 where to store the result
  71696. */
  71697. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71698. /**
  71699. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71700. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71701. * @param x define the x coordinate of the source vector
  71702. * @param y define the y coordinate of the source vector
  71703. * @param z define the z coordinate of the source vector
  71704. * @param transformation defines the transformation matrix
  71705. * @param result defines the Vector3 where to store the result
  71706. */
  71707. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71708. /**
  71709. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71710. * @param value1 defines the first control point
  71711. * @param value2 defines the second control point
  71712. * @param value3 defines the third control point
  71713. * @param value4 defines the fourth control point
  71714. * @param amount defines the amount on the spline to use
  71715. * @returns the new Vector3
  71716. */
  71717. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71718. /**
  71719. * 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"
  71720. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71721. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71722. * @param value defines the current value
  71723. * @param min defines the lower range value
  71724. * @param max defines the upper range value
  71725. * @returns the new Vector3
  71726. */
  71727. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71728. /**
  71729. * 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"
  71730. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71731. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71732. * @param value defines the current value
  71733. * @param min defines the lower range value
  71734. * @param max defines the upper range value
  71735. * @param result defines the Vector3 where to store the result
  71736. */
  71737. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71738. /**
  71739. * Checks if a given vector is inside a specific range
  71740. * @param v defines the vector to test
  71741. * @param min defines the minimum range
  71742. * @param max defines the maximum range
  71743. */
  71744. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71745. /**
  71746. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71747. * @param value1 defines the first control point
  71748. * @param tangent1 defines the first tangent vector
  71749. * @param value2 defines the second control point
  71750. * @param tangent2 defines the second tangent vector
  71751. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71752. * @returns the new Vector3
  71753. */
  71754. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71755. /**
  71756. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71757. * @param start defines the start value
  71758. * @param end defines the end value
  71759. * @param amount max defines amount between both (between 0 and 1)
  71760. * @returns the new Vector3
  71761. */
  71762. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71763. /**
  71764. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71765. * @param start defines the start value
  71766. * @param end defines the end value
  71767. * @param amount max defines amount between both (between 0 and 1)
  71768. * @param result defines the Vector3 where to store the result
  71769. */
  71770. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71771. /**
  71772. * Returns the dot product (float) between the vectors "left" and "right"
  71773. * @param left defines the left operand
  71774. * @param right defines the right operand
  71775. * @returns the dot product
  71776. */
  71777. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71778. /**
  71779. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71780. * The cross product is then orthogonal to both "left" and "right"
  71781. * @param left defines the left operand
  71782. * @param right defines the right operand
  71783. * @returns the cross product
  71784. */
  71785. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71786. /**
  71787. * Sets the given vector "result" with the cross product of "left" and "right"
  71788. * The cross product is then orthogonal to both "left" and "right"
  71789. * @param left defines the left operand
  71790. * @param right defines the right operand
  71791. * @param result defines the Vector3 where to store the result
  71792. */
  71793. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71794. /**
  71795. * Returns a new Vector3 as the normalization of the given vector
  71796. * @param vector defines the Vector3 to normalize
  71797. * @returns the new Vector3
  71798. */
  71799. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71800. /**
  71801. * Sets the given vector "result" with the normalization of the given first vector
  71802. * @param vector defines the Vector3 to normalize
  71803. * @param result defines the Vector3 where to store the result
  71804. */
  71805. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71806. /**
  71807. * Project a Vector3 onto screen space
  71808. * @param vector defines the Vector3 to project
  71809. * @param world defines the world matrix to use
  71810. * @param transform defines the transform (view x projection) matrix to use
  71811. * @param viewport defines the screen viewport to use
  71812. * @returns the new Vector3
  71813. */
  71814. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71815. /** @hidden */
  71816. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71817. /**
  71818. * Unproject from screen space to object space
  71819. * @param source defines the screen space Vector3 to use
  71820. * @param viewportWidth defines the current width of the viewport
  71821. * @param viewportHeight defines the current height of the viewport
  71822. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71823. * @param transform defines the transform (view x projection) matrix to use
  71824. * @returns the new Vector3
  71825. */
  71826. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71827. /**
  71828. * Unproject from screen space to object space
  71829. * @param source defines the screen space Vector3 to use
  71830. * @param viewportWidth defines the current width of the viewport
  71831. * @param viewportHeight defines the current height of the viewport
  71832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71833. * @param view defines the view matrix to use
  71834. * @param projection defines the projection matrix to use
  71835. * @returns the new Vector3
  71836. */
  71837. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71838. /**
  71839. * Unproject from screen space to object space
  71840. * @param source defines the screen space Vector3 to use
  71841. * @param viewportWidth defines the current width of the viewport
  71842. * @param viewportHeight defines the current height of the viewport
  71843. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71844. * @param view defines the view matrix to use
  71845. * @param projection defines the projection matrix to use
  71846. * @param result defines the Vector3 where to store the result
  71847. */
  71848. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71849. /**
  71850. * Unproject from screen space to object space
  71851. * @param sourceX defines the screen space x coordinate to use
  71852. * @param sourceY defines the screen space y coordinate to use
  71853. * @param sourceZ defines the screen space z coordinate to use
  71854. * @param viewportWidth defines the current width of the viewport
  71855. * @param viewportHeight defines the current height of the viewport
  71856. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71857. * @param view defines the view matrix to use
  71858. * @param projection defines the projection matrix to use
  71859. * @param result defines the Vector3 where to store the result
  71860. */
  71861. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71862. /**
  71863. * Gets the minimal coordinate values between two Vector3
  71864. * @param left defines the first operand
  71865. * @param right defines the second operand
  71866. * @returns the new Vector3
  71867. */
  71868. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71869. /**
  71870. * Gets the maximal coordinate values between two Vector3
  71871. * @param left defines the first operand
  71872. * @param right defines the second operand
  71873. * @returns the new Vector3
  71874. */
  71875. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71876. /**
  71877. * Returns the distance between the vectors "value1" and "value2"
  71878. * @param value1 defines the first operand
  71879. * @param value2 defines the second operand
  71880. * @returns the distance
  71881. */
  71882. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71883. /**
  71884. * Returns the squared distance between the vectors "value1" and "value2"
  71885. * @param value1 defines the first operand
  71886. * @param value2 defines the second operand
  71887. * @returns the squared distance
  71888. */
  71889. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71890. /**
  71891. * Returns a new Vector3 located at the center between "value1" and "value2"
  71892. * @param value1 defines the first operand
  71893. * @param value2 defines the second operand
  71894. * @returns the new Vector3
  71895. */
  71896. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71897. /**
  71898. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71899. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71900. * to something in order to rotate it from its local system to the given target system
  71901. * Note: axis1, axis2 and axis3 are normalized during this operation
  71902. * @param axis1 defines the first axis
  71903. * @param axis2 defines the second axis
  71904. * @param axis3 defines the third axis
  71905. * @returns a new Vector3
  71906. */
  71907. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71908. /**
  71909. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71910. * @param axis1 defines the first axis
  71911. * @param axis2 defines the second axis
  71912. * @param axis3 defines the third axis
  71913. * @param ref defines the Vector3 where to store the result
  71914. */
  71915. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71916. }
  71917. /**
  71918. * Vector4 class created for EulerAngle class conversion to Quaternion
  71919. */
  71920. export class Vector4 {
  71921. /** x value of the vector */
  71922. x: number;
  71923. /** y value of the vector */
  71924. y: number;
  71925. /** z value of the vector */
  71926. z: number;
  71927. /** w value of the vector */
  71928. w: number;
  71929. /**
  71930. * Creates a Vector4 object from the given floats.
  71931. * @param x x value of the vector
  71932. * @param y y value of the vector
  71933. * @param z z value of the vector
  71934. * @param w w value of the vector
  71935. */
  71936. constructor(
  71937. /** x value of the vector */
  71938. x: number,
  71939. /** y value of the vector */
  71940. y: number,
  71941. /** z value of the vector */
  71942. z: number,
  71943. /** w value of the vector */
  71944. w: number);
  71945. /**
  71946. * Returns the string with the Vector4 coordinates.
  71947. * @returns a string containing all the vector values
  71948. */
  71949. toString(): string;
  71950. /**
  71951. * Returns the string "Vector4".
  71952. * @returns "Vector4"
  71953. */
  71954. getClassName(): string;
  71955. /**
  71956. * Returns the Vector4 hash code.
  71957. * @returns a unique hash code
  71958. */
  71959. getHashCode(): number;
  71960. /**
  71961. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71962. * @returns the resulting array
  71963. */
  71964. asArray(): number[];
  71965. /**
  71966. * Populates the given array from the given index with the Vector4 coordinates.
  71967. * @param array array to populate
  71968. * @param index index of the array to start at (default: 0)
  71969. * @returns the Vector4.
  71970. */
  71971. toArray(array: FloatArray, index?: number): Vector4;
  71972. /**
  71973. * Adds the given vector to the current Vector4.
  71974. * @param otherVector the vector to add
  71975. * @returns the updated Vector4.
  71976. */
  71977. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71978. /**
  71979. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71980. * @param otherVector the vector to add
  71981. * @returns the resulting vector
  71982. */
  71983. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71984. /**
  71985. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71986. * @param otherVector the vector to add
  71987. * @param result the vector to store the result
  71988. * @returns the current Vector4.
  71989. */
  71990. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71991. /**
  71992. * Subtract in place the given vector from the current Vector4.
  71993. * @param otherVector the vector to subtract
  71994. * @returns the updated Vector4.
  71995. */
  71996. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71997. /**
  71998. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71999. * @param otherVector the vector to add
  72000. * @returns the new vector with the result
  72001. */
  72002. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72003. /**
  72004. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72005. * @param otherVector the vector to subtract
  72006. * @param result the vector to store the result
  72007. * @returns the current Vector4.
  72008. */
  72009. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72010. /**
  72011. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72012. */
  72013. /**
  72014. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72015. * @param x value to subtract
  72016. * @param y value to subtract
  72017. * @param z value to subtract
  72018. * @param w value to subtract
  72019. * @returns new vector containing the result
  72020. */
  72021. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72022. /**
  72023. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72024. * @param x value to subtract
  72025. * @param y value to subtract
  72026. * @param z value to subtract
  72027. * @param w value to subtract
  72028. * @param result the vector to store the result in
  72029. * @returns the current Vector4.
  72030. */
  72031. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72032. /**
  72033. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72034. * @returns a new vector with the negated values
  72035. */
  72036. negate(): Vector4;
  72037. /**
  72038. * Multiplies the current Vector4 coordinates by scale (float).
  72039. * @param scale the number to scale with
  72040. * @returns the updated Vector4.
  72041. */
  72042. scaleInPlace(scale: number): Vector4;
  72043. /**
  72044. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72045. * @param scale the number to scale with
  72046. * @returns a new vector with the result
  72047. */
  72048. scale(scale: number): Vector4;
  72049. /**
  72050. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72051. * @param scale the number to scale with
  72052. * @param result a vector to store the result in
  72053. * @returns the current Vector4.
  72054. */
  72055. scaleToRef(scale: number, result: Vector4): Vector4;
  72056. /**
  72057. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72058. * @param scale defines the scale factor
  72059. * @param result defines the Vector4 object where to store the result
  72060. * @returns the unmodified current Vector4
  72061. */
  72062. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72063. /**
  72064. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72065. * @param otherVector the vector to compare against
  72066. * @returns true if they are equal
  72067. */
  72068. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72069. /**
  72070. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72071. * @param otherVector vector to compare against
  72072. * @param epsilon (Default: very small number)
  72073. * @returns true if they are equal
  72074. */
  72075. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72076. /**
  72077. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72078. * @param x x value to compare against
  72079. * @param y y value to compare against
  72080. * @param z z value to compare against
  72081. * @param w w value to compare against
  72082. * @returns true if equal
  72083. */
  72084. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72085. /**
  72086. * Multiplies in place the current Vector4 by the given one.
  72087. * @param otherVector vector to multiple with
  72088. * @returns the updated Vector4.
  72089. */
  72090. multiplyInPlace(otherVector: Vector4): Vector4;
  72091. /**
  72092. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72093. * @param otherVector vector to multiple with
  72094. * @returns resulting new vector
  72095. */
  72096. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72097. /**
  72098. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72099. * @param otherVector vector to multiple with
  72100. * @param result vector to store the result
  72101. * @returns the current Vector4.
  72102. */
  72103. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72104. /**
  72105. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72106. * @param x x value multiply with
  72107. * @param y y value multiply with
  72108. * @param z z value multiply with
  72109. * @param w w value multiply with
  72110. * @returns resulting new vector
  72111. */
  72112. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72113. /**
  72114. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72115. * @param otherVector vector to devide with
  72116. * @returns resulting new vector
  72117. */
  72118. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72119. /**
  72120. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72121. * @param otherVector vector to devide with
  72122. * @param result vector to store the result
  72123. * @returns the current Vector4.
  72124. */
  72125. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72126. /**
  72127. * Divides the current Vector3 coordinates by the given ones.
  72128. * @param otherVector vector to devide with
  72129. * @returns the updated Vector3.
  72130. */
  72131. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72132. /**
  72133. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72134. * @param other defines the second operand
  72135. * @returns the current updated Vector4
  72136. */
  72137. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72138. /**
  72139. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72140. * @param other defines the second operand
  72141. * @returns the current updated Vector4
  72142. */
  72143. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72144. /**
  72145. * Gets a new Vector4 from current Vector4 floored values
  72146. * @returns a new Vector4
  72147. */
  72148. floor(): Vector4;
  72149. /**
  72150. * Gets a new Vector4 from current Vector3 floored values
  72151. * @returns a new Vector4
  72152. */
  72153. fract(): Vector4;
  72154. /**
  72155. * Returns the Vector4 length (float).
  72156. * @returns the length
  72157. */
  72158. length(): number;
  72159. /**
  72160. * Returns the Vector4 squared length (float).
  72161. * @returns the length squared
  72162. */
  72163. lengthSquared(): number;
  72164. /**
  72165. * Normalizes in place the Vector4.
  72166. * @returns the updated Vector4.
  72167. */
  72168. normalize(): Vector4;
  72169. /**
  72170. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72171. * @returns this converted to a new vector3
  72172. */
  72173. toVector3(): Vector3;
  72174. /**
  72175. * Returns a new Vector4 copied from the current one.
  72176. * @returns the new cloned vector
  72177. */
  72178. clone(): Vector4;
  72179. /**
  72180. * Updates the current Vector4 with the given one coordinates.
  72181. * @param source the source vector to copy from
  72182. * @returns the updated Vector4.
  72183. */
  72184. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72185. /**
  72186. * Updates the current Vector4 coordinates with the given floats.
  72187. * @param x float to copy from
  72188. * @param y float to copy from
  72189. * @param z float to copy from
  72190. * @param w float to copy from
  72191. * @returns the updated Vector4.
  72192. */
  72193. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72194. /**
  72195. * Updates the current Vector4 coordinates with the given floats.
  72196. * @param x float to set from
  72197. * @param y float to set from
  72198. * @param z float to set from
  72199. * @param w float to set from
  72200. * @returns the updated Vector4.
  72201. */
  72202. set(x: number, y: number, z: number, w: number): Vector4;
  72203. /**
  72204. * Copies the given float to the current Vector3 coordinates
  72205. * @param v defines the x, y, z and w coordinates of the operand
  72206. * @returns the current updated Vector3
  72207. */
  72208. setAll(v: number): Vector4;
  72209. /**
  72210. * Returns a new Vector4 set from the starting index of the given array.
  72211. * @param array the array to pull values from
  72212. * @param offset the offset into the array to start at
  72213. * @returns the new vector
  72214. */
  72215. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72216. /**
  72217. * Updates the given vector "result" from the starting index of the given array.
  72218. * @param array the array to pull values from
  72219. * @param offset the offset into the array to start at
  72220. * @param result the vector to store the result in
  72221. */
  72222. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72223. /**
  72224. * Updates the given vector "result" from the starting index of the given Float32Array.
  72225. * @param array the array to pull values from
  72226. * @param offset the offset into the array to start at
  72227. * @param result the vector to store the result in
  72228. */
  72229. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72230. /**
  72231. * Updates the given vector "result" coordinates from the given floats.
  72232. * @param x float to set from
  72233. * @param y float to set from
  72234. * @param z float to set from
  72235. * @param w float to set from
  72236. * @param result the vector to the floats in
  72237. */
  72238. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72239. /**
  72240. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72241. * @returns the new vector
  72242. */
  72243. static Zero(): Vector4;
  72244. /**
  72245. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72246. * @returns the new vector
  72247. */
  72248. static One(): Vector4;
  72249. /**
  72250. * Returns a new normalized Vector4 from the given one.
  72251. * @param vector the vector to normalize
  72252. * @returns the vector
  72253. */
  72254. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72255. /**
  72256. * Updates the given vector "result" from the normalization of the given one.
  72257. * @param vector the vector to normalize
  72258. * @param result the vector to store the result in
  72259. */
  72260. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72261. /**
  72262. * Returns a vector with the minimum values from the left and right vectors
  72263. * @param left left vector to minimize
  72264. * @param right right vector to minimize
  72265. * @returns a new vector with the minimum of the left and right vector values
  72266. */
  72267. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72268. /**
  72269. * Returns a vector with the maximum values from the left and right vectors
  72270. * @param left left vector to maximize
  72271. * @param right right vector to maximize
  72272. * @returns a new vector with the maximum of the left and right vector values
  72273. */
  72274. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72275. /**
  72276. * Returns the distance (float) between the vectors "value1" and "value2".
  72277. * @param value1 value to calulate the distance between
  72278. * @param value2 value to calulate the distance between
  72279. * @return the distance between the two vectors
  72280. */
  72281. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72282. /**
  72283. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72284. * @param value1 value to calulate the distance between
  72285. * @param value2 value to calulate the distance between
  72286. * @return the distance between the two vectors squared
  72287. */
  72288. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72289. /**
  72290. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72291. * @param value1 value to calulate the center between
  72292. * @param value2 value to calulate the center between
  72293. * @return the center between the two vectors
  72294. */
  72295. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72296. /**
  72297. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72298. * This methods computes transformed normalized direction vectors only.
  72299. * @param vector the vector to transform
  72300. * @param transformation the transformation matrix to apply
  72301. * @returns the new vector
  72302. */
  72303. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72304. /**
  72305. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72306. * This methods computes transformed normalized direction vectors only.
  72307. * @param vector the vector to transform
  72308. * @param transformation the transformation matrix to apply
  72309. * @param result the vector to store the result in
  72310. */
  72311. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72312. /**
  72313. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72314. * This methods computes transformed normalized direction vectors only.
  72315. * @param x value to transform
  72316. * @param y value to transform
  72317. * @param z value to transform
  72318. * @param w value to transform
  72319. * @param transformation the transformation matrix to apply
  72320. * @param result the vector to store the results in
  72321. */
  72322. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72323. /**
  72324. * Creates a new Vector4 from a Vector3
  72325. * @param source defines the source data
  72326. * @param w defines the 4th component (default is 0)
  72327. * @returns a new Vector4
  72328. */
  72329. static FromVector3(source: Vector3, w?: number): Vector4;
  72330. }
  72331. /**
  72332. * Class used to store quaternion data
  72333. * @see https://en.wikipedia.org/wiki/Quaternion
  72334. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72335. */
  72336. export class Quaternion {
  72337. /** defines the first component (0 by default) */
  72338. x: number;
  72339. /** defines the second component (0 by default) */
  72340. y: number;
  72341. /** defines the third component (0 by default) */
  72342. z: number;
  72343. /** defines the fourth component (1.0 by default) */
  72344. w: number;
  72345. /**
  72346. * Creates a new Quaternion from the given floats
  72347. * @param x defines the first component (0 by default)
  72348. * @param y defines the second component (0 by default)
  72349. * @param z defines the third component (0 by default)
  72350. * @param w defines the fourth component (1.0 by default)
  72351. */
  72352. constructor(
  72353. /** defines the first component (0 by default) */
  72354. x?: number,
  72355. /** defines the second component (0 by default) */
  72356. y?: number,
  72357. /** defines the third component (0 by default) */
  72358. z?: number,
  72359. /** defines the fourth component (1.0 by default) */
  72360. w?: number);
  72361. /**
  72362. * Gets a string representation for the current quaternion
  72363. * @returns a string with the Quaternion coordinates
  72364. */
  72365. toString(): string;
  72366. /**
  72367. * Gets the class name of the quaternion
  72368. * @returns the string "Quaternion"
  72369. */
  72370. getClassName(): string;
  72371. /**
  72372. * Gets a hash code for this quaternion
  72373. * @returns the quaternion hash code
  72374. */
  72375. getHashCode(): number;
  72376. /**
  72377. * Copy the quaternion to an array
  72378. * @returns a new array populated with 4 elements from the quaternion coordinates
  72379. */
  72380. asArray(): number[];
  72381. /**
  72382. * Check if two quaternions are equals
  72383. * @param otherQuaternion defines the second operand
  72384. * @return true if the current quaternion and the given one coordinates are strictly equals
  72385. */
  72386. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72387. /**
  72388. * Clone the current quaternion
  72389. * @returns a new quaternion copied from the current one
  72390. */
  72391. clone(): Quaternion;
  72392. /**
  72393. * Copy a quaternion to the current one
  72394. * @param other defines the other quaternion
  72395. * @returns the updated current quaternion
  72396. */
  72397. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72398. /**
  72399. * Updates the current quaternion with the given float coordinates
  72400. * @param x defines the x coordinate
  72401. * @param y defines the y coordinate
  72402. * @param z defines the z coordinate
  72403. * @param w defines the w coordinate
  72404. * @returns the updated current quaternion
  72405. */
  72406. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72407. /**
  72408. * Updates the current quaternion from the given float coordinates
  72409. * @param x defines the x coordinate
  72410. * @param y defines the y coordinate
  72411. * @param z defines the z coordinate
  72412. * @param w defines the w coordinate
  72413. * @returns the updated current quaternion
  72414. */
  72415. set(x: number, y: number, z: number, w: number): Quaternion;
  72416. /**
  72417. * Adds two quaternions
  72418. * @param other defines the second operand
  72419. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72420. */
  72421. add(other: DeepImmutable<Quaternion>): Quaternion;
  72422. /**
  72423. * Add a quaternion to the current one
  72424. * @param other defines the quaternion to add
  72425. * @returns the current quaternion
  72426. */
  72427. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72428. /**
  72429. * Subtract two quaternions
  72430. * @param other defines the second operand
  72431. * @returns a new quaternion as the subtraction result of the given one from the current one
  72432. */
  72433. subtract(other: Quaternion): Quaternion;
  72434. /**
  72435. * Multiplies the current quaternion by a scale factor
  72436. * @param value defines the scale factor
  72437. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72438. */
  72439. scale(value: number): Quaternion;
  72440. /**
  72441. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72442. * @param scale defines the scale factor
  72443. * @param result defines the Quaternion object where to store the result
  72444. * @returns the unmodified current quaternion
  72445. */
  72446. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72447. /**
  72448. * Multiplies in place the current quaternion by a scale factor
  72449. * @param value defines the scale factor
  72450. * @returns the current modified quaternion
  72451. */
  72452. scaleInPlace(value: number): Quaternion;
  72453. /**
  72454. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72455. * @param scale defines the scale factor
  72456. * @param result defines the Quaternion object where to store the result
  72457. * @returns the unmodified current quaternion
  72458. */
  72459. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72460. /**
  72461. * Multiplies two quaternions
  72462. * @param q1 defines the second operand
  72463. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72464. */
  72465. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72466. /**
  72467. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72468. * @param q1 defines the second operand
  72469. * @param result defines the target quaternion
  72470. * @returns the current quaternion
  72471. */
  72472. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72473. /**
  72474. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72475. * @param q1 defines the second operand
  72476. * @returns the currentupdated quaternion
  72477. */
  72478. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72479. /**
  72480. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72481. * @param ref defines the target quaternion
  72482. * @returns the current quaternion
  72483. */
  72484. conjugateToRef(ref: Quaternion): Quaternion;
  72485. /**
  72486. * Conjugates in place (1-q) the current quaternion
  72487. * @returns the current updated quaternion
  72488. */
  72489. conjugateInPlace(): Quaternion;
  72490. /**
  72491. * Conjugates in place (1-q) the current quaternion
  72492. * @returns a new quaternion
  72493. */
  72494. conjugate(): Quaternion;
  72495. /**
  72496. * Gets length of current quaternion
  72497. * @returns the quaternion length (float)
  72498. */
  72499. length(): number;
  72500. /**
  72501. * Normalize in place the current quaternion
  72502. * @returns the current updated quaternion
  72503. */
  72504. normalize(): Quaternion;
  72505. /**
  72506. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72507. * @param order is a reserved parameter and is ignore for now
  72508. * @returns a new Vector3 containing the Euler angles
  72509. */
  72510. toEulerAngles(order?: string): Vector3;
  72511. /**
  72512. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72513. * @param result defines the vector which will be filled with the Euler angles
  72514. * @param order is a reserved parameter and is ignore for now
  72515. * @returns the current unchanged quaternion
  72516. */
  72517. toEulerAnglesToRef(result: Vector3): Quaternion;
  72518. /**
  72519. * Updates the given rotation matrix with the current quaternion values
  72520. * @param result defines the target matrix
  72521. * @returns the current unchanged quaternion
  72522. */
  72523. toRotationMatrix(result: Matrix): Quaternion;
  72524. /**
  72525. * Updates the current quaternion from the given rotation matrix values
  72526. * @param matrix defines the source matrix
  72527. * @returns the current updated quaternion
  72528. */
  72529. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72530. /**
  72531. * Creates a new quaternion from a rotation matrix
  72532. * @param matrix defines the source matrix
  72533. * @returns a new quaternion created from the given rotation matrix values
  72534. */
  72535. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72536. /**
  72537. * Updates the given quaternion with the given rotation matrix values
  72538. * @param matrix defines the source matrix
  72539. * @param result defines the target quaternion
  72540. */
  72541. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72542. /**
  72543. * Returns the dot product (float) between the quaternions "left" and "right"
  72544. * @param left defines the left operand
  72545. * @param right defines the right operand
  72546. * @returns the dot product
  72547. */
  72548. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72549. /**
  72550. * Checks if the two quaternions are close to each other
  72551. * @param quat0 defines the first quaternion to check
  72552. * @param quat1 defines the second quaternion to check
  72553. * @returns true if the two quaternions are close to each other
  72554. */
  72555. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72556. /**
  72557. * Creates an empty quaternion
  72558. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72559. */
  72560. static Zero(): Quaternion;
  72561. /**
  72562. * Inverse a given quaternion
  72563. * @param q defines the source quaternion
  72564. * @returns a new quaternion as the inverted current quaternion
  72565. */
  72566. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72567. /**
  72568. * Inverse a given quaternion
  72569. * @param q defines the source quaternion
  72570. * @param result the quaternion the result will be stored in
  72571. * @returns the result quaternion
  72572. */
  72573. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72574. /**
  72575. * Creates an identity quaternion
  72576. * @returns the identity quaternion
  72577. */
  72578. static Identity(): Quaternion;
  72579. /**
  72580. * Gets a boolean indicating if the given quaternion is identity
  72581. * @param quaternion defines the quaternion to check
  72582. * @returns true if the quaternion is identity
  72583. */
  72584. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72585. /**
  72586. * Creates a quaternion from a rotation around an axis
  72587. * @param axis defines the axis to use
  72588. * @param angle defines the angle to use
  72589. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72590. */
  72591. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72592. /**
  72593. * Creates a rotation around an axis and stores it into the given quaternion
  72594. * @param axis defines the axis to use
  72595. * @param angle defines the angle to use
  72596. * @param result defines the target quaternion
  72597. * @returns the target quaternion
  72598. */
  72599. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72600. /**
  72601. * Creates a new quaternion from data stored into an array
  72602. * @param array defines the data source
  72603. * @param offset defines the offset in the source array where the data starts
  72604. * @returns a new quaternion
  72605. */
  72606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72607. /**
  72608. * Create a quaternion from Euler rotation angles
  72609. * @param x Pitch
  72610. * @param y Yaw
  72611. * @param z Roll
  72612. * @returns the new Quaternion
  72613. */
  72614. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72615. /**
  72616. * Updates a quaternion from Euler rotation angles
  72617. * @param x Pitch
  72618. * @param y Yaw
  72619. * @param z Roll
  72620. * @param result the quaternion to store the result
  72621. * @returns the updated quaternion
  72622. */
  72623. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72624. /**
  72625. * Create a quaternion from Euler rotation vector
  72626. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72627. * @returns the new Quaternion
  72628. */
  72629. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72630. /**
  72631. * Updates a quaternion from Euler rotation vector
  72632. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72633. * @param result the quaternion to store the result
  72634. * @returns the updated quaternion
  72635. */
  72636. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72637. /**
  72638. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72639. * @param yaw defines the rotation around Y axis
  72640. * @param pitch defines the rotation around X axis
  72641. * @param roll defines the rotation around Z axis
  72642. * @returns the new quaternion
  72643. */
  72644. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72645. /**
  72646. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72647. * @param yaw defines the rotation around Y axis
  72648. * @param pitch defines the rotation around X axis
  72649. * @param roll defines the rotation around Z axis
  72650. * @param result defines the target quaternion
  72651. */
  72652. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72653. /**
  72654. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72655. * @param alpha defines the rotation around first axis
  72656. * @param beta defines the rotation around second axis
  72657. * @param gamma defines the rotation around third axis
  72658. * @returns the new quaternion
  72659. */
  72660. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72661. /**
  72662. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72663. * @param alpha defines the rotation around first axis
  72664. * @param beta defines the rotation around second axis
  72665. * @param gamma defines the rotation around third axis
  72666. * @param result defines the target quaternion
  72667. */
  72668. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72669. /**
  72670. * 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)
  72671. * @param axis1 defines the first axis
  72672. * @param axis2 defines the second axis
  72673. * @param axis3 defines the third axis
  72674. * @returns the new quaternion
  72675. */
  72676. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72677. /**
  72678. * 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
  72679. * @param axis1 defines the first axis
  72680. * @param axis2 defines the second axis
  72681. * @param axis3 defines the third axis
  72682. * @param ref defines the target quaternion
  72683. */
  72684. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72685. /**
  72686. * Interpolates between two quaternions
  72687. * @param left defines first quaternion
  72688. * @param right defines second quaternion
  72689. * @param amount defines the gradient to use
  72690. * @returns the new interpolated quaternion
  72691. */
  72692. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72693. /**
  72694. * Interpolates between two quaternions and stores it into a target quaternion
  72695. * @param left defines first quaternion
  72696. * @param right defines second quaternion
  72697. * @param amount defines the gradient to use
  72698. * @param result defines the target quaternion
  72699. */
  72700. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72701. /**
  72702. * Interpolate between two quaternions using Hermite interpolation
  72703. * @param value1 defines first quaternion
  72704. * @param tangent1 defines the incoming tangent
  72705. * @param value2 defines second quaternion
  72706. * @param tangent2 defines the outgoing tangent
  72707. * @param amount defines the target quaternion
  72708. * @returns the new interpolated quaternion
  72709. */
  72710. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72711. }
  72712. /**
  72713. * Class used to store matrix data (4x4)
  72714. */
  72715. export class Matrix {
  72716. private static _updateFlagSeed;
  72717. private static _identityReadOnly;
  72718. private _isIdentity;
  72719. private _isIdentityDirty;
  72720. private _isIdentity3x2;
  72721. private _isIdentity3x2Dirty;
  72722. /**
  72723. * Gets the update flag of the matrix which is an unique number for the matrix.
  72724. * It will be incremented every time the matrix data change.
  72725. * You can use it to speed the comparison between two versions of the same matrix.
  72726. */
  72727. updateFlag: number;
  72728. private readonly _m;
  72729. /**
  72730. * Gets the internal data of the matrix
  72731. */
  72732. readonly m: DeepImmutable<Float32Array>;
  72733. /** @hidden */
  72734. _markAsUpdated(): void;
  72735. /** @hidden */
  72736. private _updateIdentityStatus;
  72737. /**
  72738. * Creates an empty matrix (filled with zeros)
  72739. */
  72740. constructor();
  72741. /**
  72742. * Check if the current matrix is identity
  72743. * @returns true is the matrix is the identity matrix
  72744. */
  72745. isIdentity(): boolean;
  72746. /**
  72747. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72748. * @returns true is the matrix is the identity matrix
  72749. */
  72750. isIdentityAs3x2(): boolean;
  72751. /**
  72752. * Gets the determinant of the matrix
  72753. * @returns the matrix determinant
  72754. */
  72755. determinant(): number;
  72756. /**
  72757. * Returns the matrix as a Float32Array
  72758. * @returns the matrix underlying array
  72759. */
  72760. toArray(): DeepImmutable<Float32Array>;
  72761. /**
  72762. * Returns the matrix as a Float32Array
  72763. * @returns the matrix underlying array.
  72764. */
  72765. asArray(): DeepImmutable<Float32Array>;
  72766. /**
  72767. * Inverts the current matrix in place
  72768. * @returns the current inverted matrix
  72769. */
  72770. invert(): Matrix;
  72771. /**
  72772. * Sets all the matrix elements to zero
  72773. * @returns the current matrix
  72774. */
  72775. reset(): Matrix;
  72776. /**
  72777. * Adds the current matrix with a second one
  72778. * @param other defines the matrix to add
  72779. * @returns a new matrix as the addition of the current matrix and the given one
  72780. */
  72781. add(other: DeepImmutable<Matrix>): Matrix;
  72782. /**
  72783. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72784. * @param other defines the matrix to add
  72785. * @param result defines the target matrix
  72786. * @returns the current matrix
  72787. */
  72788. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72789. /**
  72790. * Adds in place the given matrix to the current matrix
  72791. * @param other defines the second operand
  72792. * @returns the current updated matrix
  72793. */
  72794. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72795. /**
  72796. * Sets the given matrix to the current inverted Matrix
  72797. * @param other defines the target matrix
  72798. * @returns the unmodified current matrix
  72799. */
  72800. invertToRef(other: Matrix): Matrix;
  72801. /**
  72802. * add a value at the specified position in the current Matrix
  72803. * @param index the index of the value within the matrix. between 0 and 15.
  72804. * @param value the value to be added
  72805. * @returns the current updated matrix
  72806. */
  72807. addAtIndex(index: number, value: number): Matrix;
  72808. /**
  72809. * mutiply the specified position in the current Matrix by a value
  72810. * @param index the index of the value within the matrix. between 0 and 15.
  72811. * @param value the value to be added
  72812. * @returns the current updated matrix
  72813. */
  72814. multiplyAtIndex(index: number, value: number): Matrix;
  72815. /**
  72816. * Inserts the translation vector (using 3 floats) in the current matrix
  72817. * @param x defines the 1st component of the translation
  72818. * @param y defines the 2nd component of the translation
  72819. * @param z defines the 3rd component of the translation
  72820. * @returns the current updated matrix
  72821. */
  72822. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72823. /**
  72824. * Adds the translation vector (using 3 floats) in the current matrix
  72825. * @param x defines the 1st component of the translation
  72826. * @param y defines the 2nd component of the translation
  72827. * @param z defines the 3rd component of the translation
  72828. * @returns the current updated matrix
  72829. */
  72830. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72831. /**
  72832. * Inserts the translation vector in the current matrix
  72833. * @param vector3 defines the translation to insert
  72834. * @returns the current updated matrix
  72835. */
  72836. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72837. /**
  72838. * Gets the translation value of the current matrix
  72839. * @returns a new Vector3 as the extracted translation from the matrix
  72840. */
  72841. getTranslation(): Vector3;
  72842. /**
  72843. * Fill a Vector3 with the extracted translation from the matrix
  72844. * @param result defines the Vector3 where to store the translation
  72845. * @returns the current matrix
  72846. */
  72847. getTranslationToRef(result: Vector3): Matrix;
  72848. /**
  72849. * Remove rotation and scaling part from the matrix
  72850. * @returns the updated matrix
  72851. */
  72852. removeRotationAndScaling(): Matrix;
  72853. /**
  72854. * Multiply two matrices
  72855. * @param other defines the second operand
  72856. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72857. */
  72858. multiply(other: DeepImmutable<Matrix>): Matrix;
  72859. /**
  72860. * Copy the current matrix from the given one
  72861. * @param other defines the source matrix
  72862. * @returns the current updated matrix
  72863. */
  72864. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72865. /**
  72866. * Populates the given array from the starting index with the current matrix values
  72867. * @param array defines the target array
  72868. * @param offset defines the offset in the target array where to start storing values
  72869. * @returns the current matrix
  72870. */
  72871. copyToArray(array: Float32Array, offset?: number): Matrix;
  72872. /**
  72873. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72874. * @param other defines the second operand
  72875. * @param result defines the matrix where to store the multiplication
  72876. * @returns the current matrix
  72877. */
  72878. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72879. /**
  72880. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72881. * @param other defines the second operand
  72882. * @param result defines the array where to store the multiplication
  72883. * @param offset defines the offset in the target array where to start storing values
  72884. * @returns the current matrix
  72885. */
  72886. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72887. /**
  72888. * Check equality between this matrix and a second one
  72889. * @param value defines the second matrix to compare
  72890. * @returns true is the current matrix and the given one values are strictly equal
  72891. */
  72892. equals(value: DeepImmutable<Matrix>): boolean;
  72893. /**
  72894. * Clone the current matrix
  72895. * @returns a new matrix from the current matrix
  72896. */
  72897. clone(): Matrix;
  72898. /**
  72899. * Returns the name of the current matrix class
  72900. * @returns the string "Matrix"
  72901. */
  72902. getClassName(): string;
  72903. /**
  72904. * Gets the hash code of the current matrix
  72905. * @returns the hash code
  72906. */
  72907. getHashCode(): number;
  72908. /**
  72909. * Decomposes the current Matrix into a translation, rotation and scaling components
  72910. * @param scale defines the scale vector3 given as a reference to update
  72911. * @param rotation defines the rotation quaternion given as a reference to update
  72912. * @param translation defines the translation vector3 given as a reference to update
  72913. * @returns true if operation was successful
  72914. */
  72915. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72916. /**
  72917. * Gets specific row of the matrix
  72918. * @param index defines the number of the row to get
  72919. * @returns the index-th row of the current matrix as a new Vector4
  72920. */
  72921. getRow(index: number): Nullable<Vector4>;
  72922. /**
  72923. * Sets the index-th row of the current matrix to the vector4 values
  72924. * @param index defines the number of the row to set
  72925. * @param row defines the target vector4
  72926. * @returns the updated current matrix
  72927. */
  72928. setRow(index: number, row: Vector4): Matrix;
  72929. /**
  72930. * Compute the transpose of the matrix
  72931. * @returns the new transposed matrix
  72932. */
  72933. transpose(): Matrix;
  72934. /**
  72935. * Compute the transpose of the matrix and store it in a given matrix
  72936. * @param result defines the target matrix
  72937. * @returns the current matrix
  72938. */
  72939. transposeToRef(result: Matrix): Matrix;
  72940. /**
  72941. * Sets the index-th row of the current matrix with the given 4 x float values
  72942. * @param index defines the row index
  72943. * @param x defines the x component to set
  72944. * @param y defines the y component to set
  72945. * @param z defines the z component to set
  72946. * @param w defines the w component to set
  72947. * @returns the updated current matrix
  72948. */
  72949. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72950. /**
  72951. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72952. * @param scale defines the scale factor
  72953. * @returns a new matrix
  72954. */
  72955. scale(scale: number): Matrix;
  72956. /**
  72957. * Scale the current matrix values by a factor to a given result matrix
  72958. * @param scale defines the scale factor
  72959. * @param result defines the matrix to store the result
  72960. * @returns the current matrix
  72961. */
  72962. scaleToRef(scale: number, result: Matrix): Matrix;
  72963. /**
  72964. * Scale the current matrix values by a factor and add the result to a given matrix
  72965. * @param scale defines the scale factor
  72966. * @param result defines the Matrix to store the result
  72967. * @returns the current matrix
  72968. */
  72969. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72970. /**
  72971. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72972. * @param ref matrix to store the result
  72973. */
  72974. toNormalMatrix(ref: Matrix): void;
  72975. /**
  72976. * Gets only rotation part of the current matrix
  72977. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72978. */
  72979. getRotationMatrix(): Matrix;
  72980. /**
  72981. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72982. * @param result defines the target matrix to store data to
  72983. * @returns the current matrix
  72984. */
  72985. getRotationMatrixToRef(result: Matrix): Matrix;
  72986. /**
  72987. * Toggles model matrix from being right handed to left handed in place and vice versa
  72988. */
  72989. toggleModelMatrixHandInPlace(): void;
  72990. /**
  72991. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72992. */
  72993. toggleProjectionMatrixHandInPlace(): void;
  72994. /**
  72995. * Creates a matrix from an array
  72996. * @param array defines the source array
  72997. * @param offset defines an offset in the source array
  72998. * @returns a new Matrix set from the starting index of the given array
  72999. */
  73000. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73001. /**
  73002. * Copy the content of an array into a given matrix
  73003. * @param array defines the source array
  73004. * @param offset defines an offset in the source array
  73005. * @param result defines the target matrix
  73006. */
  73007. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73008. /**
  73009. * Stores an array into a matrix after having multiplied each component by a given factor
  73010. * @param array defines the source array
  73011. * @param offset defines the offset in the source array
  73012. * @param scale defines the scaling factor
  73013. * @param result defines the target matrix
  73014. */
  73015. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73016. /**
  73017. * Gets an identity matrix that must not be updated
  73018. */
  73019. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73020. /**
  73021. * Stores a list of values (16) inside a given matrix
  73022. * @param initialM11 defines 1st value of 1st row
  73023. * @param initialM12 defines 2nd value of 1st row
  73024. * @param initialM13 defines 3rd value of 1st row
  73025. * @param initialM14 defines 4th value of 1st row
  73026. * @param initialM21 defines 1st value of 2nd row
  73027. * @param initialM22 defines 2nd value of 2nd row
  73028. * @param initialM23 defines 3rd value of 2nd row
  73029. * @param initialM24 defines 4th value of 2nd row
  73030. * @param initialM31 defines 1st value of 3rd row
  73031. * @param initialM32 defines 2nd value of 3rd row
  73032. * @param initialM33 defines 3rd value of 3rd row
  73033. * @param initialM34 defines 4th value of 3rd row
  73034. * @param initialM41 defines 1st value of 4th row
  73035. * @param initialM42 defines 2nd value of 4th row
  73036. * @param initialM43 defines 3rd value of 4th row
  73037. * @param initialM44 defines 4th value of 4th row
  73038. * @param result defines the target matrix
  73039. */
  73040. 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;
  73041. /**
  73042. * Creates new matrix from a list of values (16)
  73043. * @param initialM11 defines 1st value of 1st row
  73044. * @param initialM12 defines 2nd value of 1st row
  73045. * @param initialM13 defines 3rd value of 1st row
  73046. * @param initialM14 defines 4th value of 1st row
  73047. * @param initialM21 defines 1st value of 2nd row
  73048. * @param initialM22 defines 2nd value of 2nd row
  73049. * @param initialM23 defines 3rd value of 2nd row
  73050. * @param initialM24 defines 4th value of 2nd row
  73051. * @param initialM31 defines 1st value of 3rd row
  73052. * @param initialM32 defines 2nd value of 3rd row
  73053. * @param initialM33 defines 3rd value of 3rd row
  73054. * @param initialM34 defines 4th value of 3rd row
  73055. * @param initialM41 defines 1st value of 4th row
  73056. * @param initialM42 defines 2nd value of 4th row
  73057. * @param initialM43 defines 3rd value of 4th row
  73058. * @param initialM44 defines 4th value of 4th row
  73059. * @returns the new matrix
  73060. */
  73061. 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;
  73062. /**
  73063. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73064. * @param scale defines the scale vector3
  73065. * @param rotation defines the rotation quaternion
  73066. * @param translation defines the translation vector3
  73067. * @returns a new matrix
  73068. */
  73069. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73070. /**
  73071. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73072. * @param scale defines the scale vector3
  73073. * @param rotation defines the rotation quaternion
  73074. * @param translation defines the translation vector3
  73075. * @param result defines the target matrix
  73076. */
  73077. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73078. /**
  73079. * Creates a new identity matrix
  73080. * @returns a new identity matrix
  73081. */
  73082. static Identity(): Matrix;
  73083. /**
  73084. * Creates a new identity matrix and stores the result in a given matrix
  73085. * @param result defines the target matrix
  73086. */
  73087. static IdentityToRef(result: Matrix): void;
  73088. /**
  73089. * Creates a new zero matrix
  73090. * @returns a new zero matrix
  73091. */
  73092. static Zero(): Matrix;
  73093. /**
  73094. * Creates a new rotation matrix for "angle" radians around the X axis
  73095. * @param angle defines the angle (in radians) to use
  73096. * @return the new matrix
  73097. */
  73098. static RotationX(angle: number): Matrix;
  73099. /**
  73100. * Creates a new matrix as the invert of a given matrix
  73101. * @param source defines the source matrix
  73102. * @returns the new matrix
  73103. */
  73104. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73105. /**
  73106. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73107. * @param angle defines the angle (in radians) to use
  73108. * @param result defines the target matrix
  73109. */
  73110. static RotationXToRef(angle: number, result: Matrix): void;
  73111. /**
  73112. * Creates a new rotation matrix for "angle" radians around the Y axis
  73113. * @param angle defines the angle (in radians) to use
  73114. * @return the new matrix
  73115. */
  73116. static RotationY(angle: number): Matrix;
  73117. /**
  73118. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73119. * @param angle defines the angle (in radians) to use
  73120. * @param result defines the target matrix
  73121. */
  73122. static RotationYToRef(angle: number, result: Matrix): void;
  73123. /**
  73124. * Creates a new rotation matrix for "angle" radians around the Z axis
  73125. * @param angle defines the angle (in radians) to use
  73126. * @return the new matrix
  73127. */
  73128. static RotationZ(angle: number): Matrix;
  73129. /**
  73130. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73131. * @param angle defines the angle (in radians) to use
  73132. * @param result defines the target matrix
  73133. */
  73134. static RotationZToRef(angle: number, result: Matrix): void;
  73135. /**
  73136. * Creates a new rotation matrix for "angle" radians around the given axis
  73137. * @param axis defines the axis to use
  73138. * @param angle defines the angle (in radians) to use
  73139. * @return the new matrix
  73140. */
  73141. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73142. /**
  73143. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73144. * @param axis defines the axis to use
  73145. * @param angle defines the angle (in radians) to use
  73146. * @param result defines the target matrix
  73147. */
  73148. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73149. /**
  73150. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73151. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73152. * @param from defines the vector to align
  73153. * @param to defines the vector to align to
  73154. * @param result defines the target matrix
  73155. */
  73156. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73157. /**
  73158. * Creates a rotation matrix
  73159. * @param yaw defines the yaw angle in radians (Y axis)
  73160. * @param pitch defines the pitch angle in radians (X axis)
  73161. * @param roll defines the roll angle in radians (X axis)
  73162. * @returns the new rotation matrix
  73163. */
  73164. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73165. /**
  73166. * Creates a rotation matrix and stores it in a given matrix
  73167. * @param yaw defines the yaw angle in radians (Y axis)
  73168. * @param pitch defines the pitch angle in radians (X axis)
  73169. * @param roll defines the roll angle in radians (X axis)
  73170. * @param result defines the target matrix
  73171. */
  73172. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73173. /**
  73174. * Creates a scaling matrix
  73175. * @param x defines the scale factor on X axis
  73176. * @param y defines the scale factor on Y axis
  73177. * @param z defines the scale factor on Z axis
  73178. * @returns the new matrix
  73179. */
  73180. static Scaling(x: number, y: number, z: number): Matrix;
  73181. /**
  73182. * Creates a scaling matrix and stores it in a given matrix
  73183. * @param x defines the scale factor on X axis
  73184. * @param y defines the scale factor on Y axis
  73185. * @param z defines the scale factor on Z axis
  73186. * @param result defines the target matrix
  73187. */
  73188. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73189. /**
  73190. * Creates a translation matrix
  73191. * @param x defines the translation on X axis
  73192. * @param y defines the translation on Y axis
  73193. * @param z defines the translationon Z axis
  73194. * @returns the new matrix
  73195. */
  73196. static Translation(x: number, y: number, z: number): Matrix;
  73197. /**
  73198. * Creates a translation matrix and stores it in a given matrix
  73199. * @param x defines the translation on X axis
  73200. * @param y defines the translation on Y axis
  73201. * @param z defines the translationon Z axis
  73202. * @param result defines the target matrix
  73203. */
  73204. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73205. /**
  73206. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73207. * @param startValue defines the start value
  73208. * @param endValue defines the end value
  73209. * @param gradient defines the gradient factor
  73210. * @returns the new matrix
  73211. */
  73212. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73213. /**
  73214. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73215. * @param startValue defines the start value
  73216. * @param endValue defines the end value
  73217. * @param gradient defines the gradient factor
  73218. * @param result defines the Matrix object where to store data
  73219. */
  73220. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73221. /**
  73222. * Builds a new matrix whose values are computed by:
  73223. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73224. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73225. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73226. * @param startValue defines the first matrix
  73227. * @param endValue defines the second matrix
  73228. * @param gradient defines the gradient between the two matrices
  73229. * @returns the new matrix
  73230. */
  73231. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73232. /**
  73233. * Update a matrix to values which are computed by:
  73234. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73235. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73236. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73237. * @param startValue defines the first matrix
  73238. * @param endValue defines the second matrix
  73239. * @param gradient defines the gradient between the two matrices
  73240. * @param result defines the target matrix
  73241. */
  73242. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73243. /**
  73244. * 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"
  73245. * This function works in left handed mode
  73246. * @param eye defines the final position of the entity
  73247. * @param target defines where the entity should look at
  73248. * @param up defines the up vector for the entity
  73249. * @returns the new matrix
  73250. */
  73251. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73252. /**
  73253. * 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".
  73254. * This function works in left handed mode
  73255. * @param eye defines the final position of the entity
  73256. * @param target defines where the entity should look at
  73257. * @param up defines the up vector for the entity
  73258. * @param result defines the target matrix
  73259. */
  73260. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73261. /**
  73262. * 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"
  73263. * This function works in right handed mode
  73264. * @param eye defines the final position of the entity
  73265. * @param target defines where the entity should look at
  73266. * @param up defines the up vector for the entity
  73267. * @returns the new matrix
  73268. */
  73269. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73270. /**
  73271. * 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".
  73272. * This function works in right handed mode
  73273. * @param eye defines the final position of the entity
  73274. * @param target defines where the entity should look at
  73275. * @param up defines the up vector for the entity
  73276. * @param result defines the target matrix
  73277. */
  73278. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73279. /**
  73280. * Create a left-handed orthographic projection matrix
  73281. * @param width defines the viewport width
  73282. * @param height defines the viewport height
  73283. * @param znear defines the near clip plane
  73284. * @param zfar defines the far clip plane
  73285. * @returns a new matrix as a left-handed orthographic projection matrix
  73286. */
  73287. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73288. /**
  73289. * Store a left-handed orthographic projection to a given matrix
  73290. * @param width defines the viewport width
  73291. * @param height defines the viewport height
  73292. * @param znear defines the near clip plane
  73293. * @param zfar defines the far clip plane
  73294. * @param result defines the target matrix
  73295. */
  73296. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73297. /**
  73298. * Create a left-handed orthographic projection matrix
  73299. * @param left defines the viewport left coordinate
  73300. * @param right defines the viewport right coordinate
  73301. * @param bottom defines the viewport bottom coordinate
  73302. * @param top defines the viewport top coordinate
  73303. * @param znear defines the near clip plane
  73304. * @param zfar defines the far clip plane
  73305. * @returns a new matrix as a left-handed orthographic projection matrix
  73306. */
  73307. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73308. /**
  73309. * Stores a left-handed orthographic projection into a given matrix
  73310. * @param left defines the viewport left coordinate
  73311. * @param right defines the viewport right coordinate
  73312. * @param bottom defines the viewport bottom coordinate
  73313. * @param top defines the viewport top coordinate
  73314. * @param znear defines the near clip plane
  73315. * @param zfar defines the far clip plane
  73316. * @param result defines the target matrix
  73317. */
  73318. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73319. /**
  73320. * Creates a right-handed orthographic projection matrix
  73321. * @param left defines the viewport left coordinate
  73322. * @param right defines the viewport right coordinate
  73323. * @param bottom defines the viewport bottom coordinate
  73324. * @param top defines the viewport top coordinate
  73325. * @param znear defines the near clip plane
  73326. * @param zfar defines the far clip plane
  73327. * @returns a new matrix as a right-handed orthographic projection matrix
  73328. */
  73329. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73330. /**
  73331. * Stores a right-handed orthographic projection into a given matrix
  73332. * @param left defines the viewport left coordinate
  73333. * @param right defines the viewport right coordinate
  73334. * @param bottom defines the viewport bottom coordinate
  73335. * @param top defines the viewport top coordinate
  73336. * @param znear defines the near clip plane
  73337. * @param zfar defines the far clip plane
  73338. * @param result defines the target matrix
  73339. */
  73340. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73341. /**
  73342. * Creates a left-handed perspective projection 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. * @returns a new matrix as a left-handed perspective projection matrix
  73348. */
  73349. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73350. /**
  73351. * Creates a left-handed perspective projection matrix
  73352. * @param fov defines the horizontal field of view
  73353. * @param aspect defines the aspect ratio
  73354. * @param znear defines the near clip plane
  73355. * @param zfar defines the far clip plane
  73356. * @returns a new matrix as a left-handed perspective projection matrix
  73357. */
  73358. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73359. /**
  73360. * Stores a left-handed perspective projection into a given matrix
  73361. * @param fov defines the horizontal field of view
  73362. * @param aspect defines the aspect ratio
  73363. * @param znear defines the near clip plane
  73364. * @param zfar defines the far clip plane
  73365. * @param result defines the target matrix
  73366. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73367. */
  73368. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73369. /**
  73370. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73371. * @param fov defines the horizontal field of view
  73372. * @param aspect defines the aspect ratio
  73373. * @param znear defines the near clip plane
  73374. * @param zfar not used as infinity is used as far clip
  73375. * @param result defines the target matrix
  73376. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73377. */
  73378. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73379. /**
  73380. * Creates a right-handed perspective projection matrix
  73381. * @param fov defines the horizontal field of view
  73382. * @param aspect defines the aspect ratio
  73383. * @param znear defines the near clip plane
  73384. * @param zfar defines the far clip plane
  73385. * @returns a new matrix as a right-handed perspective projection matrix
  73386. */
  73387. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73388. /**
  73389. * Stores a right-handed perspective projection into a given matrix
  73390. * @param fov defines the horizontal field of view
  73391. * @param aspect defines the aspect ratio
  73392. * @param znear defines the near clip plane
  73393. * @param zfar defines the far clip plane
  73394. * @param result defines the target matrix
  73395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73396. */
  73397. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73398. /**
  73399. * Stores a right-handed perspective projection into a given matrix
  73400. * @param fov defines the horizontal field of view
  73401. * @param aspect defines the aspect ratio
  73402. * @param znear defines the near clip plane
  73403. * @param zfar not used as infinity is used as far clip
  73404. * @param result defines the target matrix
  73405. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73406. */
  73407. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73408. /**
  73409. * Stores a perspective projection for WebVR info a given matrix
  73410. * @param fov defines the field of view
  73411. * @param znear defines the near clip plane
  73412. * @param zfar defines the far clip plane
  73413. * @param result defines the target matrix
  73414. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73415. */
  73416. static PerspectiveFovWebVRToRef(fov: {
  73417. upDegrees: number;
  73418. downDegrees: number;
  73419. leftDegrees: number;
  73420. rightDegrees: number;
  73421. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73422. /**
  73423. * Computes a complete transformation matrix
  73424. * @param viewport defines the viewport to use
  73425. * @param world defines the world matrix
  73426. * @param view defines the view matrix
  73427. * @param projection defines the projection matrix
  73428. * @param zmin defines the near clip plane
  73429. * @param zmax defines the far clip plane
  73430. * @returns the transformation matrix
  73431. */
  73432. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73433. /**
  73434. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73435. * @param matrix defines the matrix to use
  73436. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73437. */
  73438. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73439. /**
  73440. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73441. * @param matrix defines the matrix to use
  73442. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73443. */
  73444. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73445. /**
  73446. * Compute the transpose of a given matrix
  73447. * @param matrix defines the matrix to transpose
  73448. * @returns the new matrix
  73449. */
  73450. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73451. /**
  73452. * Compute the transpose of a matrix and store it in a target matrix
  73453. * @param matrix defines the matrix to transpose
  73454. * @param result defines the target matrix
  73455. */
  73456. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73457. /**
  73458. * Computes a reflection matrix from a plane
  73459. * @param plane defines the reflection plane
  73460. * @returns a new matrix
  73461. */
  73462. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73463. /**
  73464. * Computes a reflection matrix from a plane
  73465. * @param plane defines the reflection plane
  73466. * @param result defines the target matrix
  73467. */
  73468. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73469. /**
  73470. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73471. * @param xaxis defines the value of the 1st axis
  73472. * @param yaxis defines the value of the 2nd axis
  73473. * @param zaxis defines the value of the 3rd axis
  73474. * @param result defines the target matrix
  73475. */
  73476. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73477. /**
  73478. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73479. * @param quat defines the quaternion to use
  73480. * @param result defines the target matrix
  73481. */
  73482. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73483. }
  73484. /**
  73485. * @hidden
  73486. */
  73487. export class TmpVectors {
  73488. static Vector2: Vector2[];
  73489. static Vector3: Vector3[];
  73490. static Vector4: Vector4[];
  73491. static Quaternion: Quaternion[];
  73492. static Matrix: Matrix[];
  73493. }
  73494. }
  73495. declare module BABYLON {
  73496. /**
  73497. * Defines potential orientation for back face culling
  73498. */
  73499. export enum Orientation {
  73500. /**
  73501. * Clockwise
  73502. */
  73503. CW = 0,
  73504. /** Counter clockwise */
  73505. CCW = 1
  73506. }
  73507. /** Class used to represent a Bezier curve */
  73508. export class BezierCurve {
  73509. /**
  73510. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73511. * @param t defines the time
  73512. * @param x1 defines the left coordinate on X axis
  73513. * @param y1 defines the left coordinate on Y axis
  73514. * @param x2 defines the right coordinate on X axis
  73515. * @param y2 defines the right coordinate on Y axis
  73516. * @returns the interpolated value
  73517. */
  73518. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73519. }
  73520. /**
  73521. * Defines angle representation
  73522. */
  73523. export class Angle {
  73524. private _radians;
  73525. /**
  73526. * Creates an Angle object of "radians" radians (float).
  73527. * @param radians the angle in radians
  73528. */
  73529. constructor(radians: number);
  73530. /**
  73531. * Get value in degrees
  73532. * @returns the Angle value in degrees (float)
  73533. */
  73534. degrees(): number;
  73535. /**
  73536. * Get value in radians
  73537. * @returns the Angle value in radians (float)
  73538. */
  73539. radians(): number;
  73540. /**
  73541. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73542. * @param a defines first vector
  73543. * @param b defines second vector
  73544. * @returns a new Angle
  73545. */
  73546. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73547. /**
  73548. * Gets a new Angle object from the given float in radians
  73549. * @param radians defines the angle value in radians
  73550. * @returns a new Angle
  73551. */
  73552. static FromRadians(radians: number): Angle;
  73553. /**
  73554. * Gets a new Angle object from the given float in degrees
  73555. * @param degrees defines the angle value in degrees
  73556. * @returns a new Angle
  73557. */
  73558. static FromDegrees(degrees: number): Angle;
  73559. }
  73560. /**
  73561. * This represents an arc in a 2d space.
  73562. */
  73563. export class Arc2 {
  73564. /** Defines the start point of the arc */
  73565. startPoint: Vector2;
  73566. /** Defines the mid point of the arc */
  73567. midPoint: Vector2;
  73568. /** Defines the end point of the arc */
  73569. endPoint: Vector2;
  73570. /**
  73571. * Defines the center point of the arc.
  73572. */
  73573. centerPoint: Vector2;
  73574. /**
  73575. * Defines the radius of the arc.
  73576. */
  73577. radius: number;
  73578. /**
  73579. * Defines the angle of the arc (from mid point to end point).
  73580. */
  73581. angle: Angle;
  73582. /**
  73583. * Defines the start angle of the arc (from start point to middle point).
  73584. */
  73585. startAngle: Angle;
  73586. /**
  73587. * Defines the orientation of the arc (clock wise/counter clock wise).
  73588. */
  73589. orientation: Orientation;
  73590. /**
  73591. * Creates an Arc object from the three given points : start, middle and end.
  73592. * @param startPoint Defines the start point of the arc
  73593. * @param midPoint Defines the midlle point of the arc
  73594. * @param endPoint Defines the end point of the arc
  73595. */
  73596. constructor(
  73597. /** Defines the start point of the arc */
  73598. startPoint: Vector2,
  73599. /** Defines the mid point of the arc */
  73600. midPoint: Vector2,
  73601. /** Defines the end point of the arc */
  73602. endPoint: Vector2);
  73603. }
  73604. /**
  73605. * Represents a 2D path made up of multiple 2D points
  73606. */
  73607. export class Path2 {
  73608. private _points;
  73609. private _length;
  73610. /**
  73611. * If the path start and end point are the same
  73612. */
  73613. closed: boolean;
  73614. /**
  73615. * Creates a Path2 object from the starting 2D coordinates x and y.
  73616. * @param x the starting points x value
  73617. * @param y the starting points y value
  73618. */
  73619. constructor(x: number, y: number);
  73620. /**
  73621. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73622. * @param x the added points x value
  73623. * @param y the added points y value
  73624. * @returns the updated Path2.
  73625. */
  73626. addLineTo(x: number, y: number): Path2;
  73627. /**
  73628. * 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.
  73629. * @param midX middle point x value
  73630. * @param midY middle point y value
  73631. * @param endX end point x value
  73632. * @param endY end point y value
  73633. * @param numberOfSegments (default: 36)
  73634. * @returns the updated Path2.
  73635. */
  73636. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73637. /**
  73638. * Closes the Path2.
  73639. * @returns the Path2.
  73640. */
  73641. close(): Path2;
  73642. /**
  73643. * Gets the sum of the distance between each sequential point in the path
  73644. * @returns the Path2 total length (float).
  73645. */
  73646. length(): number;
  73647. /**
  73648. * Gets the points which construct the path
  73649. * @returns the Path2 internal array of points.
  73650. */
  73651. getPoints(): Vector2[];
  73652. /**
  73653. * Retreives the point at the distance aways from the starting point
  73654. * @param normalizedLengthPosition the length along the path to retreive the point from
  73655. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73656. */
  73657. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73658. /**
  73659. * Creates a new path starting from an x and y position
  73660. * @param x starting x value
  73661. * @param y starting y value
  73662. * @returns a new Path2 starting at the coordinates (x, y).
  73663. */
  73664. static StartingAt(x: number, y: number): Path2;
  73665. }
  73666. /**
  73667. * Represents a 3D path made up of multiple 3D points
  73668. */
  73669. export class Path3D {
  73670. /**
  73671. * an array of Vector3, the curve axis of the Path3D
  73672. */
  73673. path: Vector3[];
  73674. private _curve;
  73675. private _distances;
  73676. private _tangents;
  73677. private _normals;
  73678. private _binormals;
  73679. private _raw;
  73680. private _alignTangentsWithPath;
  73681. private readonly _pointAtData;
  73682. /**
  73683. * new Path3D(path, normal, raw)
  73684. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73685. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73686. * @param path an array of Vector3, the curve axis of the Path3D
  73687. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73688. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73689. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73690. */
  73691. constructor(
  73692. /**
  73693. * an array of Vector3, the curve axis of the Path3D
  73694. */
  73695. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73696. /**
  73697. * Returns the Path3D array of successive Vector3 designing its curve.
  73698. * @returns the Path3D array of successive Vector3 designing its curve.
  73699. */
  73700. getCurve(): Vector3[];
  73701. /**
  73702. * Returns the Path3D array of successive Vector3 designing its curve.
  73703. * @returns the Path3D array of successive Vector3 designing its curve.
  73704. */
  73705. getPoints(): Vector3[];
  73706. /**
  73707. * @returns the computed length (float) of the path.
  73708. */
  73709. length(): number;
  73710. /**
  73711. * Returns an array populated with tangent vectors on each Path3D curve point.
  73712. * @returns an array populated with tangent vectors on each Path3D curve point.
  73713. */
  73714. getTangents(): Vector3[];
  73715. /**
  73716. * Returns an array populated with normal vectors on each Path3D curve point.
  73717. * @returns an array populated with normal vectors on each Path3D curve point.
  73718. */
  73719. getNormals(): Vector3[];
  73720. /**
  73721. * Returns an array populated with binormal vectors on each Path3D curve point.
  73722. * @returns an array populated with binormal vectors on each Path3D curve point.
  73723. */
  73724. getBinormals(): Vector3[];
  73725. /**
  73726. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73727. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73728. */
  73729. getDistances(): number[];
  73730. /**
  73731. * Returns an interpolated point along this path
  73732. * @param position the position of the point along this path, from 0.0 to 1.0
  73733. * @returns a new Vector3 as the point
  73734. */
  73735. getPointAt(position: number): Vector3;
  73736. /**
  73737. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73738. * @param position the position of the point along this path, from 0.0 to 1.0
  73739. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73740. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73741. */
  73742. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73743. /**
  73744. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73745. * @param position the position of the point along this path, from 0.0 to 1.0
  73746. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73747. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73748. */
  73749. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73750. /**
  73751. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73752. * @param position the position of the point along this path, from 0.0 to 1.0
  73753. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73754. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73755. */
  73756. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73757. /**
  73758. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73759. * @param position the position of the point along this path, from 0.0 to 1.0
  73760. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73761. */
  73762. getDistanceAt(position: number): number;
  73763. /**
  73764. * Returns the array index of the previous point of an interpolated point along this path
  73765. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73766. * @returns the array index
  73767. */
  73768. getPreviousPointIndexAt(position: number): number;
  73769. /**
  73770. * 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)
  73771. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73772. * @returns the sub position
  73773. */
  73774. getSubPositionAt(position: number): number;
  73775. /**
  73776. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73777. * @param target the vector of which to get the closest position to
  73778. * @returns the position of the closest virtual point on this path to the target vector
  73779. */
  73780. getClosestPositionTo(target: Vector3): number;
  73781. /**
  73782. * Returns a sub path (slice) of this path
  73783. * @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
  73784. * @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
  73785. * @returns a sub path (slice) of this path
  73786. */
  73787. slice(start?: number, end?: number): Path3D;
  73788. /**
  73789. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73790. * @param path path which all values are copied into the curves points
  73791. * @param firstNormal which should be projected onto the curve
  73792. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73793. * @returns the same object updated.
  73794. */
  73795. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73796. private _compute;
  73797. private _getFirstNonNullVector;
  73798. private _getLastNonNullVector;
  73799. private _normalVector;
  73800. /**
  73801. * Updates the point at data for an interpolated point along this curve
  73802. * @param position the position of the point along this curve, from 0.0 to 1.0
  73803. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73804. * @returns the (updated) point at data
  73805. */
  73806. private _updatePointAtData;
  73807. /**
  73808. * Updates the point at data from the specified parameters
  73809. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73810. * @param point the interpolated point
  73811. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73812. */
  73813. private _setPointAtData;
  73814. /**
  73815. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73816. */
  73817. private _updateInterpolationMatrix;
  73818. }
  73819. /**
  73820. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73821. * A Curve3 is designed from a series of successive Vector3.
  73822. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73823. */
  73824. export class Curve3 {
  73825. private _points;
  73826. private _length;
  73827. /**
  73828. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73829. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73830. * @param v1 (Vector3) the control point
  73831. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73832. * @param nbPoints (integer) the wanted number of points in the curve
  73833. * @returns the created Curve3
  73834. */
  73835. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73836. /**
  73837. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73838. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73839. * @param v1 (Vector3) the first control point
  73840. * @param v2 (Vector3) the second control point
  73841. * @param v3 (Vector3) the end point of the Cubic Bezier
  73842. * @param nbPoints (integer) the wanted number of points in the curve
  73843. * @returns the created Curve3
  73844. */
  73845. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73846. /**
  73847. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73848. * @param p1 (Vector3) the origin point of the Hermite Spline
  73849. * @param t1 (Vector3) the tangent vector at the origin point
  73850. * @param p2 (Vector3) the end point of the Hermite Spline
  73851. * @param t2 (Vector3) the tangent vector at the end point
  73852. * @param nbPoints (integer) the wanted number of points in the curve
  73853. * @returns the created Curve3
  73854. */
  73855. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73856. /**
  73857. * Returns a Curve3 object along a CatmullRom Spline curve :
  73858. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73859. * @param nbPoints (integer) the wanted number of points between each curve control points
  73860. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73861. * @returns the created Curve3
  73862. */
  73863. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73864. /**
  73865. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73866. * A Curve3 is designed from a series of successive Vector3.
  73867. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73868. * @param points points which make up the curve
  73869. */
  73870. constructor(points: Vector3[]);
  73871. /**
  73872. * @returns the Curve3 stored array of successive Vector3
  73873. */
  73874. getPoints(): Vector3[];
  73875. /**
  73876. * @returns the computed length (float) of the curve.
  73877. */
  73878. length(): number;
  73879. /**
  73880. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73881. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73882. * curveA and curveB keep unchanged.
  73883. * @param curve the curve to continue from this curve
  73884. * @returns the newly constructed curve
  73885. */
  73886. continue(curve: DeepImmutable<Curve3>): Curve3;
  73887. private _computeLength;
  73888. }
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * This represents the main contract an easing function should follow.
  73893. * Easing functions are used throughout the animation system.
  73894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73895. */
  73896. export interface IEasingFunction {
  73897. /**
  73898. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73899. * of the easing function.
  73900. * The link below provides some of the most common examples of easing functions.
  73901. * @see https://easings.net/
  73902. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73903. * @returns the corresponding value on the curve defined by the easing function
  73904. */
  73905. ease(gradient: number): number;
  73906. }
  73907. /**
  73908. * Base class used for every default easing function.
  73909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73910. */
  73911. export class EasingFunction implements IEasingFunction {
  73912. /**
  73913. * Interpolation follows the mathematical formula associated with the easing function.
  73914. */
  73915. static readonly EASINGMODE_EASEIN: number;
  73916. /**
  73917. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73918. */
  73919. static readonly EASINGMODE_EASEOUT: number;
  73920. /**
  73921. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73922. */
  73923. static readonly EASINGMODE_EASEINOUT: number;
  73924. private _easingMode;
  73925. /**
  73926. * Sets the easing mode of the current function.
  73927. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73928. */
  73929. setEasingMode(easingMode: number): void;
  73930. /**
  73931. * Gets the current easing mode.
  73932. * @returns the easing mode
  73933. */
  73934. getEasingMode(): number;
  73935. /**
  73936. * @hidden
  73937. */
  73938. easeInCore(gradient: number): number;
  73939. /**
  73940. * Given an input gradient between 0 and 1, this returns the corresponding value
  73941. * of the easing function.
  73942. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73943. * @returns the corresponding value on the curve defined by the easing function
  73944. */
  73945. ease(gradient: number): number;
  73946. }
  73947. /**
  73948. * Easing function with a circle shape (see link below).
  73949. * @see https://easings.net/#easeInCirc
  73950. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73951. */
  73952. export class CircleEase extends EasingFunction implements IEasingFunction {
  73953. /** @hidden */
  73954. easeInCore(gradient: number): number;
  73955. }
  73956. /**
  73957. * Easing function with a ease back shape (see link below).
  73958. * @see https://easings.net/#easeInBack
  73959. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73960. */
  73961. export class BackEase extends EasingFunction implements IEasingFunction {
  73962. /** Defines the amplitude of the function */
  73963. amplitude: number;
  73964. /**
  73965. * Instantiates a back ease easing
  73966. * @see https://easings.net/#easeInBack
  73967. * @param amplitude Defines the amplitude of the function
  73968. */
  73969. constructor(
  73970. /** Defines the amplitude of the function */
  73971. amplitude?: number);
  73972. /** @hidden */
  73973. easeInCore(gradient: number): number;
  73974. }
  73975. /**
  73976. * Easing function with a bouncing shape (see link below).
  73977. * @see https://easings.net/#easeInBounce
  73978. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73979. */
  73980. export class BounceEase extends EasingFunction implements IEasingFunction {
  73981. /** Defines the number of bounces */
  73982. bounces: number;
  73983. /** Defines the amplitude of the bounce */
  73984. bounciness: number;
  73985. /**
  73986. * Instantiates a bounce easing
  73987. * @see https://easings.net/#easeInBounce
  73988. * @param bounces Defines the number of bounces
  73989. * @param bounciness Defines the amplitude of the bounce
  73990. */
  73991. constructor(
  73992. /** Defines the number of bounces */
  73993. bounces?: number,
  73994. /** Defines the amplitude of the bounce */
  73995. bounciness?: number);
  73996. /** @hidden */
  73997. easeInCore(gradient: number): number;
  73998. }
  73999. /**
  74000. * Easing function with a power of 3 shape (see link below).
  74001. * @see https://easings.net/#easeInCubic
  74002. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74003. */
  74004. export class CubicEase extends EasingFunction implements IEasingFunction {
  74005. /** @hidden */
  74006. easeInCore(gradient: number): number;
  74007. }
  74008. /**
  74009. * Easing function with an elastic shape (see link below).
  74010. * @see https://easings.net/#easeInElastic
  74011. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74012. */
  74013. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74014. /** Defines the number of oscillations*/
  74015. oscillations: number;
  74016. /** Defines the amplitude of the oscillations*/
  74017. springiness: number;
  74018. /**
  74019. * Instantiates an elastic easing function
  74020. * @see https://easings.net/#easeInElastic
  74021. * @param oscillations Defines the number of oscillations
  74022. * @param springiness Defines the amplitude of the oscillations
  74023. */
  74024. constructor(
  74025. /** Defines the number of oscillations*/
  74026. oscillations?: number,
  74027. /** Defines the amplitude of the oscillations*/
  74028. springiness?: number);
  74029. /** @hidden */
  74030. easeInCore(gradient: number): number;
  74031. }
  74032. /**
  74033. * Easing function with an exponential shape (see link below).
  74034. * @see https://easings.net/#easeInExpo
  74035. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74036. */
  74037. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74038. /** Defines the exponent of the function */
  74039. exponent: number;
  74040. /**
  74041. * Instantiates an exponential easing function
  74042. * @see https://easings.net/#easeInExpo
  74043. * @param exponent Defines the exponent of the function
  74044. */
  74045. constructor(
  74046. /** Defines the exponent of the function */
  74047. exponent?: number);
  74048. /** @hidden */
  74049. easeInCore(gradient: number): number;
  74050. }
  74051. /**
  74052. * Easing function with a power shape (see link below).
  74053. * @see https://easings.net/#easeInQuad
  74054. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74055. */
  74056. export class PowerEase extends EasingFunction implements IEasingFunction {
  74057. /** Defines the power of the function */
  74058. power: number;
  74059. /**
  74060. * Instantiates an power base easing function
  74061. * @see https://easings.net/#easeInQuad
  74062. * @param power Defines the power of the function
  74063. */
  74064. constructor(
  74065. /** Defines the power of the function */
  74066. power?: number);
  74067. /** @hidden */
  74068. easeInCore(gradient: number): number;
  74069. }
  74070. /**
  74071. * Easing function with a power of 2 shape (see link below).
  74072. * @see https://easings.net/#easeInQuad
  74073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74074. */
  74075. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74076. /** @hidden */
  74077. easeInCore(gradient: number): number;
  74078. }
  74079. /**
  74080. * Easing function with a power of 4 shape (see link below).
  74081. * @see https://easings.net/#easeInQuart
  74082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74083. */
  74084. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74085. /** @hidden */
  74086. easeInCore(gradient: number): number;
  74087. }
  74088. /**
  74089. * Easing function with a power of 5 shape (see link below).
  74090. * @see https://easings.net/#easeInQuint
  74091. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74092. */
  74093. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74094. /** @hidden */
  74095. easeInCore(gradient: number): number;
  74096. }
  74097. /**
  74098. * Easing function with a sin shape (see link below).
  74099. * @see https://easings.net/#easeInSine
  74100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74101. */
  74102. export class SineEase extends EasingFunction implements IEasingFunction {
  74103. /** @hidden */
  74104. easeInCore(gradient: number): number;
  74105. }
  74106. /**
  74107. * Easing function with a bezier shape (see link below).
  74108. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74110. */
  74111. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74112. /** Defines the x component of the start tangent in the bezier curve */
  74113. x1: number;
  74114. /** Defines the y component of the start tangent in the bezier curve */
  74115. y1: number;
  74116. /** Defines the x component of the end tangent in the bezier curve */
  74117. x2: number;
  74118. /** Defines the y component of the end tangent in the bezier curve */
  74119. y2: number;
  74120. /**
  74121. * Instantiates a bezier function
  74122. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74123. * @param x1 Defines the x component of the start tangent in the bezier curve
  74124. * @param y1 Defines the y component of the start tangent in the bezier curve
  74125. * @param x2 Defines the x component of the end tangent in the bezier curve
  74126. * @param y2 Defines the y component of the end tangent in the bezier curve
  74127. */
  74128. constructor(
  74129. /** Defines the x component of the start tangent in the bezier curve */
  74130. x1?: number,
  74131. /** Defines the y component of the start tangent in the bezier curve */
  74132. y1?: number,
  74133. /** Defines the x component of the end tangent in the bezier curve */
  74134. x2?: number,
  74135. /** Defines the y component of the end tangent in the bezier curve */
  74136. y2?: number);
  74137. /** @hidden */
  74138. easeInCore(gradient: number): number;
  74139. }
  74140. }
  74141. declare module BABYLON {
  74142. /**
  74143. * Class used to hold a RBG color
  74144. */
  74145. export class Color3 {
  74146. /**
  74147. * Defines the red component (between 0 and 1, default is 0)
  74148. */
  74149. r: number;
  74150. /**
  74151. * Defines the green component (between 0 and 1, default is 0)
  74152. */
  74153. g: number;
  74154. /**
  74155. * Defines the blue component (between 0 and 1, default is 0)
  74156. */
  74157. b: number;
  74158. /**
  74159. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74160. * @param r defines the red component (between 0 and 1, default is 0)
  74161. * @param g defines the green component (between 0 and 1, default is 0)
  74162. * @param b defines the blue component (between 0 and 1, default is 0)
  74163. */
  74164. constructor(
  74165. /**
  74166. * Defines the red component (between 0 and 1, default is 0)
  74167. */
  74168. r?: number,
  74169. /**
  74170. * Defines the green component (between 0 and 1, default is 0)
  74171. */
  74172. g?: number,
  74173. /**
  74174. * Defines the blue component (between 0 and 1, default is 0)
  74175. */
  74176. b?: number);
  74177. /**
  74178. * Creates a string with the Color3 current values
  74179. * @returns the string representation of the Color3 object
  74180. */
  74181. toString(): string;
  74182. /**
  74183. * Returns the string "Color3"
  74184. * @returns "Color3"
  74185. */
  74186. getClassName(): string;
  74187. /**
  74188. * Compute the Color3 hash code
  74189. * @returns an unique number that can be used to hash Color3 objects
  74190. */
  74191. getHashCode(): number;
  74192. /**
  74193. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74194. * @param array defines the array where to store the r,g,b components
  74195. * @param index defines an optional index in the target array to define where to start storing values
  74196. * @returns the current Color3 object
  74197. */
  74198. toArray(array: FloatArray, index?: number): Color3;
  74199. /**
  74200. * Returns a new Color4 object from the current Color3 and the given alpha
  74201. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74202. * @returns a new Color4 object
  74203. */
  74204. toColor4(alpha?: number): Color4;
  74205. /**
  74206. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74207. * @returns the new array
  74208. */
  74209. asArray(): number[];
  74210. /**
  74211. * Returns the luminance value
  74212. * @returns a float value
  74213. */
  74214. toLuminance(): number;
  74215. /**
  74216. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74217. * @param otherColor defines the second operand
  74218. * @returns the new Color3 object
  74219. */
  74220. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74221. /**
  74222. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74223. * @param otherColor defines the second operand
  74224. * @param result defines the Color3 object where to store the result
  74225. * @returns the current Color3
  74226. */
  74227. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74228. /**
  74229. * Determines equality between Color3 objects
  74230. * @param otherColor defines the second operand
  74231. * @returns true if the rgb values are equal to the given ones
  74232. */
  74233. equals(otherColor: DeepImmutable<Color3>): boolean;
  74234. /**
  74235. * Determines equality between the current Color3 object and a set of r,b,g values
  74236. * @param r defines the red component to check
  74237. * @param g defines the green component to check
  74238. * @param b defines the blue component to check
  74239. * @returns true if the rgb values are equal to the given ones
  74240. */
  74241. equalsFloats(r: number, g: number, b: number): boolean;
  74242. /**
  74243. * Multiplies in place each rgb value by scale
  74244. * @param scale defines the scaling factor
  74245. * @returns the updated Color3
  74246. */
  74247. scale(scale: number): Color3;
  74248. /**
  74249. * Multiplies the rgb values by scale and stores the result into "result"
  74250. * @param scale defines the scaling factor
  74251. * @param result defines the Color3 object where to store the result
  74252. * @returns the unmodified current Color3
  74253. */
  74254. scaleToRef(scale: number, result: Color3): Color3;
  74255. /**
  74256. * Scale the current Color3 values by a factor and add the result to a given Color3
  74257. * @param scale defines the scale factor
  74258. * @param result defines color to store the result into
  74259. * @returns the unmodified current Color3
  74260. */
  74261. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74262. /**
  74263. * Clamps the rgb values by the min and max values and stores the result into "result"
  74264. * @param min defines minimum clamping value (default is 0)
  74265. * @param max defines maximum clamping value (default is 1)
  74266. * @param result defines color to store the result into
  74267. * @returns the original Color3
  74268. */
  74269. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74270. /**
  74271. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74272. * @param otherColor defines the second operand
  74273. * @returns the new Color3
  74274. */
  74275. add(otherColor: DeepImmutable<Color3>): Color3;
  74276. /**
  74277. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74278. * @param otherColor defines the second operand
  74279. * @param result defines Color3 object to store the result into
  74280. * @returns the unmodified current Color3
  74281. */
  74282. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74283. /**
  74284. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74285. * @param otherColor defines the second operand
  74286. * @returns the new Color3
  74287. */
  74288. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74289. /**
  74290. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74291. * @param otherColor defines the second operand
  74292. * @param result defines Color3 object to store the result into
  74293. * @returns the unmodified current Color3
  74294. */
  74295. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74296. /**
  74297. * Copy the current object
  74298. * @returns a new Color3 copied the current one
  74299. */
  74300. clone(): Color3;
  74301. /**
  74302. * Copies the rgb values from the source in the current Color3
  74303. * @param source defines the source Color3 object
  74304. * @returns the updated Color3 object
  74305. */
  74306. copyFrom(source: DeepImmutable<Color3>): Color3;
  74307. /**
  74308. * Updates the Color3 rgb values from the given floats
  74309. * @param r defines the red component to read from
  74310. * @param g defines the green component to read from
  74311. * @param b defines the blue component to read from
  74312. * @returns the current Color3 object
  74313. */
  74314. copyFromFloats(r: number, g: number, b: number): Color3;
  74315. /**
  74316. * Updates the Color3 rgb values from the given floats
  74317. * @param r defines the red component to read from
  74318. * @param g defines the green component to read from
  74319. * @param b defines the blue component to read from
  74320. * @returns the current Color3 object
  74321. */
  74322. set(r: number, g: number, b: number): Color3;
  74323. /**
  74324. * Compute the Color3 hexadecimal code as a string
  74325. * @returns a string containing the hexadecimal representation of the Color3 object
  74326. */
  74327. toHexString(): string;
  74328. /**
  74329. * Computes a new Color3 converted from the current one to linear space
  74330. * @returns a new Color3 object
  74331. */
  74332. toLinearSpace(): Color3;
  74333. /**
  74334. * Converts current color in rgb space to HSV values
  74335. * @returns a new color3 representing the HSV values
  74336. */
  74337. toHSV(): Color3;
  74338. /**
  74339. * Converts current color in rgb space to HSV values
  74340. * @param result defines the Color3 where to store the HSV values
  74341. */
  74342. toHSVToRef(result: Color3): void;
  74343. /**
  74344. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74345. * @param convertedColor defines the Color3 object where to store the linear space version
  74346. * @returns the unmodified Color3
  74347. */
  74348. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74349. /**
  74350. * Computes a new Color3 converted from the current one to gamma space
  74351. * @returns a new Color3 object
  74352. */
  74353. toGammaSpace(): Color3;
  74354. /**
  74355. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74356. * @param convertedColor defines the Color3 object where to store the gamma space version
  74357. * @returns the unmodified Color3
  74358. */
  74359. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74360. private static _BlackReadOnly;
  74361. /**
  74362. * Convert Hue, saturation and value to a Color3 (RGB)
  74363. * @param hue defines the hue
  74364. * @param saturation defines the saturation
  74365. * @param value defines the value
  74366. * @param result defines the Color3 where to store the RGB values
  74367. */
  74368. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74369. /**
  74370. * Creates a new Color3 from the string containing valid hexadecimal values
  74371. * @param hex defines a string containing valid hexadecimal values
  74372. * @returns a new Color3 object
  74373. */
  74374. static FromHexString(hex: string): Color3;
  74375. /**
  74376. * Creates a new Color3 from the starting index of the given array
  74377. * @param array defines the source array
  74378. * @param offset defines an offset in the source array
  74379. * @returns a new Color3 object
  74380. */
  74381. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74382. /**
  74383. * Creates a new Color3 from integer values (< 256)
  74384. * @param r defines the red component to read from (value between 0 and 255)
  74385. * @param g defines the green component to read from (value between 0 and 255)
  74386. * @param b defines the blue component to read from (value between 0 and 255)
  74387. * @returns a new Color3 object
  74388. */
  74389. static FromInts(r: number, g: number, b: number): Color3;
  74390. /**
  74391. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74392. * @param start defines the start Color3 value
  74393. * @param end defines the end Color3 value
  74394. * @param amount defines the gradient value between start and end
  74395. * @returns a new Color3 object
  74396. */
  74397. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74398. /**
  74399. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74400. * @param left defines the start value
  74401. * @param right defines the end value
  74402. * @param amount defines the gradient factor
  74403. * @param result defines the Color3 object where to store the result
  74404. */
  74405. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74406. /**
  74407. * Returns a Color3 value containing a red color
  74408. * @returns a new Color3 object
  74409. */
  74410. static Red(): Color3;
  74411. /**
  74412. * Returns a Color3 value containing a green color
  74413. * @returns a new Color3 object
  74414. */
  74415. static Green(): Color3;
  74416. /**
  74417. * Returns a Color3 value containing a blue color
  74418. * @returns a new Color3 object
  74419. */
  74420. static Blue(): Color3;
  74421. /**
  74422. * Returns a Color3 value containing a black color
  74423. * @returns a new Color3 object
  74424. */
  74425. static Black(): Color3;
  74426. /**
  74427. * Gets a Color3 value containing a black color that must not be updated
  74428. */
  74429. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74430. /**
  74431. * Returns a Color3 value containing a white color
  74432. * @returns a new Color3 object
  74433. */
  74434. static White(): Color3;
  74435. /**
  74436. * Returns a Color3 value containing a purple color
  74437. * @returns a new Color3 object
  74438. */
  74439. static Purple(): Color3;
  74440. /**
  74441. * Returns a Color3 value containing a magenta color
  74442. * @returns a new Color3 object
  74443. */
  74444. static Magenta(): Color3;
  74445. /**
  74446. * Returns a Color3 value containing a yellow color
  74447. * @returns a new Color3 object
  74448. */
  74449. static Yellow(): Color3;
  74450. /**
  74451. * Returns a Color3 value containing a gray color
  74452. * @returns a new Color3 object
  74453. */
  74454. static Gray(): Color3;
  74455. /**
  74456. * Returns a Color3 value containing a teal color
  74457. * @returns a new Color3 object
  74458. */
  74459. static Teal(): Color3;
  74460. /**
  74461. * Returns a Color3 value containing a random color
  74462. * @returns a new Color3 object
  74463. */
  74464. static Random(): Color3;
  74465. }
  74466. /**
  74467. * Class used to hold a RBGA color
  74468. */
  74469. export class Color4 {
  74470. /**
  74471. * Defines the red component (between 0 and 1, default is 0)
  74472. */
  74473. r: number;
  74474. /**
  74475. * Defines the green component (between 0 and 1, default is 0)
  74476. */
  74477. g: number;
  74478. /**
  74479. * Defines the blue component (between 0 and 1, default is 0)
  74480. */
  74481. b: number;
  74482. /**
  74483. * Defines the alpha component (between 0 and 1, default is 1)
  74484. */
  74485. a: number;
  74486. /**
  74487. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74488. * @param r defines the red component (between 0 and 1, default is 0)
  74489. * @param g defines the green component (between 0 and 1, default is 0)
  74490. * @param b defines the blue component (between 0 and 1, default is 0)
  74491. * @param a defines the alpha component (between 0 and 1, default is 1)
  74492. */
  74493. constructor(
  74494. /**
  74495. * Defines the red component (between 0 and 1, default is 0)
  74496. */
  74497. r?: number,
  74498. /**
  74499. * Defines the green component (between 0 and 1, default is 0)
  74500. */
  74501. g?: number,
  74502. /**
  74503. * Defines the blue component (between 0 and 1, default is 0)
  74504. */
  74505. b?: number,
  74506. /**
  74507. * Defines the alpha component (between 0 and 1, default is 1)
  74508. */
  74509. a?: number);
  74510. /**
  74511. * Adds in place the given Color4 values to the current Color4 object
  74512. * @param right defines the second operand
  74513. * @returns the current updated Color4 object
  74514. */
  74515. addInPlace(right: DeepImmutable<Color4>): Color4;
  74516. /**
  74517. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74518. * @returns the new array
  74519. */
  74520. asArray(): number[];
  74521. /**
  74522. * Stores from the starting index in the given array the Color4 successive values
  74523. * @param array defines the array where to store the r,g,b components
  74524. * @param index defines an optional index in the target array to define where to start storing values
  74525. * @returns the current Color4 object
  74526. */
  74527. toArray(array: number[], index?: number): Color4;
  74528. /**
  74529. * Determines equality between Color4 objects
  74530. * @param otherColor defines the second operand
  74531. * @returns true if the rgba values are equal to the given ones
  74532. */
  74533. equals(otherColor: DeepImmutable<Color4>): boolean;
  74534. /**
  74535. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74536. * @param right defines the second operand
  74537. * @returns a new Color4 object
  74538. */
  74539. add(right: DeepImmutable<Color4>): Color4;
  74540. /**
  74541. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74542. * @param right defines the second operand
  74543. * @returns a new Color4 object
  74544. */
  74545. subtract(right: DeepImmutable<Color4>): Color4;
  74546. /**
  74547. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74548. * @param right defines the second operand
  74549. * @param result defines the Color4 object where to store the result
  74550. * @returns the current Color4 object
  74551. */
  74552. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74553. /**
  74554. * Creates a new Color4 with the current Color4 values multiplied by scale
  74555. * @param scale defines the scaling factor to apply
  74556. * @returns a new Color4 object
  74557. */
  74558. scale(scale: number): Color4;
  74559. /**
  74560. * Multiplies the current Color4 values by scale and stores the result in "result"
  74561. * @param scale defines the scaling factor to apply
  74562. * @param result defines the Color4 object where to store the result
  74563. * @returns the current unmodified Color4
  74564. */
  74565. scaleToRef(scale: number, result: Color4): Color4;
  74566. /**
  74567. * Scale the current Color4 values by a factor and add the result to a given Color4
  74568. * @param scale defines the scale factor
  74569. * @param result defines the Color4 object where to store the result
  74570. * @returns the unmodified current Color4
  74571. */
  74572. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74573. /**
  74574. * Clamps the rgb values by the min and max values and stores the result into "result"
  74575. * @param min defines minimum clamping value (default is 0)
  74576. * @param max defines maximum clamping value (default is 1)
  74577. * @param result defines color to store the result into.
  74578. * @returns the cuurent Color4
  74579. */
  74580. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74581. /**
  74582. * Multipy an Color4 value by another and return a new Color4 object
  74583. * @param color defines the Color4 value to multiply by
  74584. * @returns a new Color4 object
  74585. */
  74586. multiply(color: Color4): Color4;
  74587. /**
  74588. * Multipy a Color4 value by another and push the result in a reference value
  74589. * @param color defines the Color4 value to multiply by
  74590. * @param result defines the Color4 to fill the result in
  74591. * @returns the result Color4
  74592. */
  74593. multiplyToRef(color: Color4, result: Color4): Color4;
  74594. /**
  74595. * Creates a string with the Color4 current values
  74596. * @returns the string representation of the Color4 object
  74597. */
  74598. toString(): string;
  74599. /**
  74600. * Returns the string "Color4"
  74601. * @returns "Color4"
  74602. */
  74603. getClassName(): string;
  74604. /**
  74605. * Compute the Color4 hash code
  74606. * @returns an unique number that can be used to hash Color4 objects
  74607. */
  74608. getHashCode(): number;
  74609. /**
  74610. * Creates a new Color4 copied from the current one
  74611. * @returns a new Color4 object
  74612. */
  74613. clone(): Color4;
  74614. /**
  74615. * Copies the given Color4 values into the current one
  74616. * @param source defines the source Color4 object
  74617. * @returns the current updated Color4 object
  74618. */
  74619. copyFrom(source: Color4): Color4;
  74620. /**
  74621. * Copies the given float values into the current one
  74622. * @param r defines the red component to read from
  74623. * @param g defines the green component to read from
  74624. * @param b defines the blue component to read from
  74625. * @param a defines the alpha component to read from
  74626. * @returns the current updated Color4 object
  74627. */
  74628. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74629. /**
  74630. * Copies the given float values into the current one
  74631. * @param r defines the red component to read from
  74632. * @param g defines the green component to read from
  74633. * @param b defines the blue component to read from
  74634. * @param a defines the alpha component to read from
  74635. * @returns the current updated Color4 object
  74636. */
  74637. set(r: number, g: number, b: number, a: number): Color4;
  74638. /**
  74639. * Compute the Color4 hexadecimal code as a string
  74640. * @returns a string containing the hexadecimal representation of the Color4 object
  74641. */
  74642. toHexString(): string;
  74643. /**
  74644. * Computes a new Color4 converted from the current one to linear space
  74645. * @returns a new Color4 object
  74646. */
  74647. toLinearSpace(): Color4;
  74648. /**
  74649. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74650. * @param convertedColor defines the Color4 object where to store the linear space version
  74651. * @returns the unmodified Color4
  74652. */
  74653. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74654. /**
  74655. * Computes a new Color4 converted from the current one to gamma space
  74656. * @returns a new Color4 object
  74657. */
  74658. toGammaSpace(): Color4;
  74659. /**
  74660. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74661. * @param convertedColor defines the Color4 object where to store the gamma space version
  74662. * @returns the unmodified Color4
  74663. */
  74664. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74665. /**
  74666. * Creates a new Color4 from the string containing valid hexadecimal values
  74667. * @param hex defines a string containing valid hexadecimal values
  74668. * @returns a new Color4 object
  74669. */
  74670. static FromHexString(hex: string): Color4;
  74671. /**
  74672. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74673. * @param left defines the start value
  74674. * @param right defines the end value
  74675. * @param amount defines the gradient factor
  74676. * @returns a new Color4 object
  74677. */
  74678. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74679. /**
  74680. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74681. * @param left defines the start value
  74682. * @param right defines the end value
  74683. * @param amount defines the gradient factor
  74684. * @param result defines the Color4 object where to store data
  74685. */
  74686. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74687. /**
  74688. * Creates a new Color4 from a Color3 and an alpha value
  74689. * @param color3 defines the source Color3 to read from
  74690. * @param alpha defines the alpha component (1.0 by default)
  74691. * @returns a new Color4 object
  74692. */
  74693. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74694. /**
  74695. * Creates a new Color4 from the starting index element of the given array
  74696. * @param array defines the source array to read from
  74697. * @param offset defines the offset in the source array
  74698. * @returns a new Color4 object
  74699. */
  74700. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74701. /**
  74702. * Creates a new Color3 from integer values (< 256)
  74703. * @param r defines the red component to read from (value between 0 and 255)
  74704. * @param g defines the green component to read from (value between 0 and 255)
  74705. * @param b defines the blue component to read from (value between 0 and 255)
  74706. * @param a defines the alpha component to read from (value between 0 and 255)
  74707. * @returns a new Color3 object
  74708. */
  74709. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74710. /**
  74711. * Check the content of a given array and convert it to an array containing RGBA data
  74712. * If the original array was already containing count * 4 values then it is returned directly
  74713. * @param colors defines the array to check
  74714. * @param count defines the number of RGBA data to expect
  74715. * @returns an array containing count * 4 values (RGBA)
  74716. */
  74717. static CheckColors4(colors: number[], count: number): number[];
  74718. }
  74719. /**
  74720. * @hidden
  74721. */
  74722. export class TmpColors {
  74723. static Color3: Color3[];
  74724. static Color4: Color4[];
  74725. }
  74726. }
  74727. declare module BABYLON {
  74728. /**
  74729. * Defines an interface which represents an animation key frame
  74730. */
  74731. export interface IAnimationKey {
  74732. /**
  74733. * Frame of the key frame
  74734. */
  74735. frame: number;
  74736. /**
  74737. * Value at the specifies key frame
  74738. */
  74739. value: any;
  74740. /**
  74741. * The input tangent for the cubic hermite spline
  74742. */
  74743. inTangent?: any;
  74744. /**
  74745. * The output tangent for the cubic hermite spline
  74746. */
  74747. outTangent?: any;
  74748. /**
  74749. * The animation interpolation type
  74750. */
  74751. interpolation?: AnimationKeyInterpolation;
  74752. }
  74753. /**
  74754. * Enum for the animation key frame interpolation type
  74755. */
  74756. export enum AnimationKeyInterpolation {
  74757. /**
  74758. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74759. */
  74760. STEP = 1
  74761. }
  74762. }
  74763. declare module BABYLON {
  74764. /**
  74765. * Represents the range of an animation
  74766. */
  74767. export class AnimationRange {
  74768. /**The name of the animation range**/
  74769. name: string;
  74770. /**The starting frame of the animation */
  74771. from: number;
  74772. /**The ending frame of the animation*/
  74773. to: number;
  74774. /**
  74775. * Initializes the range of an animation
  74776. * @param name The name of the animation range
  74777. * @param from The starting frame of the animation
  74778. * @param to The ending frame of the animation
  74779. */
  74780. constructor(
  74781. /**The name of the animation range**/
  74782. name: string,
  74783. /**The starting frame of the animation */
  74784. from: number,
  74785. /**The ending frame of the animation*/
  74786. to: number);
  74787. /**
  74788. * Makes a copy of the animation range
  74789. * @returns A copy of the animation range
  74790. */
  74791. clone(): AnimationRange;
  74792. }
  74793. }
  74794. declare module BABYLON {
  74795. /**
  74796. * Composed of a frame, and an action function
  74797. */
  74798. export class AnimationEvent {
  74799. /** The frame for which the event is triggered **/
  74800. frame: number;
  74801. /** The event to perform when triggered **/
  74802. action: (currentFrame: number) => void;
  74803. /** Specifies if the event should be triggered only once**/
  74804. onlyOnce?: boolean | undefined;
  74805. /**
  74806. * Specifies if the animation event is done
  74807. */
  74808. isDone: boolean;
  74809. /**
  74810. * Initializes the animation event
  74811. * @param frame The frame for which the event is triggered
  74812. * @param action The event to perform when triggered
  74813. * @param onlyOnce Specifies if the event should be triggered only once
  74814. */
  74815. constructor(
  74816. /** The frame for which the event is triggered **/
  74817. frame: number,
  74818. /** The event to perform when triggered **/
  74819. action: (currentFrame: number) => void,
  74820. /** Specifies if the event should be triggered only once**/
  74821. onlyOnce?: boolean | undefined);
  74822. /** @hidden */
  74823. _clone(): AnimationEvent;
  74824. }
  74825. }
  74826. declare module BABYLON {
  74827. /**
  74828. * Interface used to define a behavior
  74829. */
  74830. export interface Behavior<T> {
  74831. /** gets or sets behavior's name */
  74832. name: string;
  74833. /**
  74834. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74835. */
  74836. init(): void;
  74837. /**
  74838. * Called when the behavior is attached to a target
  74839. * @param target defines the target where the behavior is attached to
  74840. */
  74841. attach(target: T): void;
  74842. /**
  74843. * Called when the behavior is detached from its target
  74844. */
  74845. detach(): void;
  74846. }
  74847. /**
  74848. * Interface implemented by classes supporting behaviors
  74849. */
  74850. export interface IBehaviorAware<T> {
  74851. /**
  74852. * Attach a behavior
  74853. * @param behavior defines the behavior to attach
  74854. * @returns the current host
  74855. */
  74856. addBehavior(behavior: Behavior<T>): T;
  74857. /**
  74858. * Remove a behavior from the current object
  74859. * @param behavior defines the behavior to detach
  74860. * @returns the current host
  74861. */
  74862. removeBehavior(behavior: Behavior<T>): T;
  74863. /**
  74864. * Gets a behavior using its name to search
  74865. * @param name defines the name to search
  74866. * @returns the behavior or null if not found
  74867. */
  74868. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74869. }
  74870. }
  74871. declare module BABYLON {
  74872. /**
  74873. * Defines an array and its length.
  74874. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74875. */
  74876. export interface ISmartArrayLike<T> {
  74877. /**
  74878. * The data of the array.
  74879. */
  74880. data: Array<T>;
  74881. /**
  74882. * The active length of the array.
  74883. */
  74884. length: number;
  74885. }
  74886. /**
  74887. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74888. */
  74889. export class SmartArray<T> implements ISmartArrayLike<T> {
  74890. /**
  74891. * The full set of data from the array.
  74892. */
  74893. data: Array<T>;
  74894. /**
  74895. * The active length of the array.
  74896. */
  74897. length: number;
  74898. protected _id: number;
  74899. /**
  74900. * Instantiates a Smart Array.
  74901. * @param capacity defines the default capacity of the array.
  74902. */
  74903. constructor(capacity: number);
  74904. /**
  74905. * Pushes a value at the end of the active data.
  74906. * @param value defines the object to push in the array.
  74907. */
  74908. push(value: T): void;
  74909. /**
  74910. * Iterates over the active data and apply the lambda to them.
  74911. * @param func defines the action to apply on each value.
  74912. */
  74913. forEach(func: (content: T) => void): void;
  74914. /**
  74915. * Sorts the full sets of data.
  74916. * @param compareFn defines the comparison function to apply.
  74917. */
  74918. sort(compareFn: (a: T, b: T) => number): void;
  74919. /**
  74920. * Resets the active data to an empty array.
  74921. */
  74922. reset(): void;
  74923. /**
  74924. * Releases all the data from the array as well as the array.
  74925. */
  74926. dispose(): void;
  74927. /**
  74928. * Concats the active data with a given array.
  74929. * @param array defines the data to concatenate with.
  74930. */
  74931. concat(array: any): void;
  74932. /**
  74933. * Returns the position of a value in the active data.
  74934. * @param value defines the value to find the index for
  74935. * @returns the index if found in the active data otherwise -1
  74936. */
  74937. indexOf(value: T): number;
  74938. /**
  74939. * Returns whether an element is part of the active data.
  74940. * @param value defines the value to look for
  74941. * @returns true if found in the active data otherwise false
  74942. */
  74943. contains(value: T): boolean;
  74944. private static _GlobalId;
  74945. }
  74946. /**
  74947. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74948. * The data in this array can only be present once
  74949. */
  74950. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74951. private _duplicateId;
  74952. /**
  74953. * Pushes a value at the end of the active data.
  74954. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74955. * @param value defines the object to push in the array.
  74956. */
  74957. push(value: T): void;
  74958. /**
  74959. * Pushes a value at the end of the active data.
  74960. * If the data is already present, it won t be added again
  74961. * @param value defines the object to push in the array.
  74962. * @returns true if added false if it was already present
  74963. */
  74964. pushNoDuplicate(value: T): boolean;
  74965. /**
  74966. * Resets the active data to an empty array.
  74967. */
  74968. reset(): void;
  74969. /**
  74970. * Concats the active data with a given array.
  74971. * This ensures no dupplicate will be present in the result.
  74972. * @param array defines the data to concatenate with.
  74973. */
  74974. concatWithNoDuplicate(array: any): void;
  74975. }
  74976. }
  74977. declare module BABYLON {
  74978. /**
  74979. * @ignore
  74980. * This is a list of all the different input types that are available in the application.
  74981. * Fo instance: ArcRotateCameraGamepadInput...
  74982. */
  74983. export var CameraInputTypes: {};
  74984. /**
  74985. * This is the contract to implement in order to create a new input class.
  74986. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74987. */
  74988. export interface ICameraInput<TCamera extends Camera> {
  74989. /**
  74990. * Defines the camera the input is attached to.
  74991. */
  74992. camera: Nullable<TCamera>;
  74993. /**
  74994. * Gets the class name of the current intput.
  74995. * @returns the class name
  74996. */
  74997. getClassName(): string;
  74998. /**
  74999. * Get the friendly name associated with the input class.
  75000. * @returns the input friendly name
  75001. */
  75002. getSimpleName(): string;
  75003. /**
  75004. * Attach the input controls to a specific dom element to get the input from.
  75005. * @param element Defines the element the controls should be listened from
  75006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75007. */
  75008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75009. /**
  75010. * Detach the current controls from the specified dom element.
  75011. * @param element Defines the element to stop listening the inputs from
  75012. */
  75013. detachControl(element: Nullable<HTMLElement>): void;
  75014. /**
  75015. * Update the current camera state depending on the inputs that have been used this frame.
  75016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75017. */
  75018. checkInputs?: () => void;
  75019. }
  75020. /**
  75021. * Represents a map of input types to input instance or input index to input instance.
  75022. */
  75023. export interface CameraInputsMap<TCamera extends Camera> {
  75024. /**
  75025. * Accessor to the input by input type.
  75026. */
  75027. [name: string]: ICameraInput<TCamera>;
  75028. /**
  75029. * Accessor to the input by input index.
  75030. */
  75031. [idx: number]: ICameraInput<TCamera>;
  75032. }
  75033. /**
  75034. * This represents the input manager used within a camera.
  75035. * It helps dealing with all the different kind of input attached to a camera.
  75036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75037. */
  75038. export class CameraInputsManager<TCamera extends Camera> {
  75039. /**
  75040. * Defines the list of inputs attahed to the camera.
  75041. */
  75042. attached: CameraInputsMap<TCamera>;
  75043. /**
  75044. * Defines the dom element the camera is collecting inputs from.
  75045. * This is null if the controls have not been attached.
  75046. */
  75047. attachedElement: Nullable<HTMLElement>;
  75048. /**
  75049. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75050. */
  75051. noPreventDefault: boolean;
  75052. /**
  75053. * Defined the camera the input manager belongs to.
  75054. */
  75055. camera: TCamera;
  75056. /**
  75057. * Update the current camera state depending on the inputs that have been used this frame.
  75058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75059. */
  75060. checkInputs: () => void;
  75061. /**
  75062. * Instantiate a new Camera Input Manager.
  75063. * @param camera Defines the camera the input manager blongs to
  75064. */
  75065. constructor(camera: TCamera);
  75066. /**
  75067. * Add an input method to a camera
  75068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75069. * @param input camera input method
  75070. */
  75071. add(input: ICameraInput<TCamera>): void;
  75072. /**
  75073. * Remove a specific input method from a camera
  75074. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75075. * @param inputToRemove camera input method
  75076. */
  75077. remove(inputToRemove: ICameraInput<TCamera>): void;
  75078. /**
  75079. * Remove a specific input type from a camera
  75080. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75081. * @param inputType the type of the input to remove
  75082. */
  75083. removeByType(inputType: string): void;
  75084. private _addCheckInputs;
  75085. /**
  75086. * Attach the input controls to the currently attached dom element to listen the events from.
  75087. * @param input Defines the input to attach
  75088. */
  75089. attachInput(input: ICameraInput<TCamera>): void;
  75090. /**
  75091. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75092. * @param element Defines the dom element to collect the events from
  75093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75094. */
  75095. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75096. /**
  75097. * Detach the current manager inputs controls from a specific dom element.
  75098. * @param element Defines the dom element to collect the events from
  75099. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75100. */
  75101. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75102. /**
  75103. * Rebuild the dynamic inputCheck function from the current list of
  75104. * defined inputs in the manager.
  75105. */
  75106. rebuildInputCheck(): void;
  75107. /**
  75108. * Remove all attached input methods from a camera
  75109. */
  75110. clear(): void;
  75111. /**
  75112. * Serialize the current input manager attached to a camera.
  75113. * This ensures than once parsed,
  75114. * the input associated to the camera will be identical to the current ones
  75115. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75116. */
  75117. serialize(serializedCamera: any): void;
  75118. /**
  75119. * Parses an input manager serialized JSON to restore the previous list of inputs
  75120. * and states associated to a camera.
  75121. * @param parsedCamera Defines the JSON to parse
  75122. */
  75123. parse(parsedCamera: any): void;
  75124. }
  75125. }
  75126. declare module BABYLON {
  75127. /**
  75128. * Class used to store data that will be store in GPU memory
  75129. */
  75130. export class Buffer {
  75131. private _engine;
  75132. private _buffer;
  75133. /** @hidden */
  75134. _data: Nullable<DataArray>;
  75135. private _updatable;
  75136. private _instanced;
  75137. private _divisor;
  75138. /**
  75139. * Gets the byte stride.
  75140. */
  75141. readonly byteStride: number;
  75142. /**
  75143. * Constructor
  75144. * @param engine the engine
  75145. * @param data the data to use for this buffer
  75146. * @param updatable whether the data is updatable
  75147. * @param stride the stride (optional)
  75148. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75149. * @param instanced whether the buffer is instanced (optional)
  75150. * @param useBytes set to true if the stride in in bytes (optional)
  75151. * @param divisor sets an optional divisor for instances (1 by default)
  75152. */
  75153. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75154. /**
  75155. * Create a new VertexBuffer based on the current buffer
  75156. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75157. * @param offset defines offset in the buffer (0 by default)
  75158. * @param size defines the size in floats of attributes (position is 3 for instance)
  75159. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75160. * @param instanced defines if the vertex buffer contains indexed data
  75161. * @param useBytes defines if the offset and stride are in bytes *
  75162. * @param divisor sets an optional divisor for instances (1 by default)
  75163. * @returns the new vertex buffer
  75164. */
  75165. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75166. /**
  75167. * Gets a boolean indicating if the Buffer is updatable?
  75168. * @returns true if the buffer is updatable
  75169. */
  75170. isUpdatable(): boolean;
  75171. /**
  75172. * Gets current buffer's data
  75173. * @returns a DataArray or null
  75174. */
  75175. getData(): Nullable<DataArray>;
  75176. /**
  75177. * Gets underlying native buffer
  75178. * @returns underlying native buffer
  75179. */
  75180. getBuffer(): Nullable<DataBuffer>;
  75181. /**
  75182. * Gets the stride in float32 units (i.e. byte stride / 4).
  75183. * May not be an integer if the byte stride is not divisible by 4.
  75184. * @returns the stride in float32 units
  75185. * @deprecated Please use byteStride instead.
  75186. */
  75187. getStrideSize(): number;
  75188. /**
  75189. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75190. * @param data defines the data to store
  75191. */
  75192. create(data?: Nullable<DataArray>): void;
  75193. /** @hidden */
  75194. _rebuild(): void;
  75195. /**
  75196. * Update current buffer data
  75197. * @param data defines the data to store
  75198. */
  75199. update(data: DataArray): void;
  75200. /**
  75201. * Updates the data directly.
  75202. * @param data the new data
  75203. * @param offset the new offset
  75204. * @param vertexCount the vertex count (optional)
  75205. * @param useBytes set to true if the offset is in bytes
  75206. */
  75207. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75208. /**
  75209. * Release all resources
  75210. */
  75211. dispose(): void;
  75212. }
  75213. /**
  75214. * Specialized buffer used to store vertex data
  75215. */
  75216. export class VertexBuffer {
  75217. /** @hidden */
  75218. _buffer: Buffer;
  75219. private _kind;
  75220. private _size;
  75221. private _ownsBuffer;
  75222. private _instanced;
  75223. private _instanceDivisor;
  75224. /**
  75225. * The byte type.
  75226. */
  75227. static readonly BYTE: number;
  75228. /**
  75229. * The unsigned byte type.
  75230. */
  75231. static readonly UNSIGNED_BYTE: number;
  75232. /**
  75233. * The short type.
  75234. */
  75235. static readonly SHORT: number;
  75236. /**
  75237. * The unsigned short type.
  75238. */
  75239. static readonly UNSIGNED_SHORT: number;
  75240. /**
  75241. * The integer type.
  75242. */
  75243. static readonly INT: number;
  75244. /**
  75245. * The unsigned integer type.
  75246. */
  75247. static readonly UNSIGNED_INT: number;
  75248. /**
  75249. * The float type.
  75250. */
  75251. static readonly FLOAT: number;
  75252. /**
  75253. * Gets or sets the instance divisor when in instanced mode
  75254. */
  75255. instanceDivisor: number;
  75256. /**
  75257. * Gets the byte stride.
  75258. */
  75259. readonly byteStride: number;
  75260. /**
  75261. * Gets the byte offset.
  75262. */
  75263. readonly byteOffset: number;
  75264. /**
  75265. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75266. */
  75267. readonly normalized: boolean;
  75268. /**
  75269. * Gets the data type of each component in the array.
  75270. */
  75271. readonly type: number;
  75272. /**
  75273. * Constructor
  75274. * @param engine the engine
  75275. * @param data the data to use for this vertex buffer
  75276. * @param kind the vertex buffer kind
  75277. * @param updatable whether the data is updatable
  75278. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75279. * @param stride the stride (optional)
  75280. * @param instanced whether the buffer is instanced (optional)
  75281. * @param offset the offset of the data (optional)
  75282. * @param size the number of components (optional)
  75283. * @param type the type of the component (optional)
  75284. * @param normalized whether the data contains normalized data (optional)
  75285. * @param useBytes set to true if stride and offset are in bytes (optional)
  75286. * @param divisor defines the instance divisor to use (1 by default)
  75287. */
  75288. 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);
  75289. /** @hidden */
  75290. _rebuild(): void;
  75291. /**
  75292. * Returns the kind of the VertexBuffer (string)
  75293. * @returns a string
  75294. */
  75295. getKind(): string;
  75296. /**
  75297. * Gets a boolean indicating if the VertexBuffer is updatable?
  75298. * @returns true if the buffer is updatable
  75299. */
  75300. isUpdatable(): boolean;
  75301. /**
  75302. * Gets current buffer's data
  75303. * @returns a DataArray or null
  75304. */
  75305. getData(): Nullable<DataArray>;
  75306. /**
  75307. * Gets underlying native buffer
  75308. * @returns underlying native buffer
  75309. */
  75310. getBuffer(): Nullable<DataBuffer>;
  75311. /**
  75312. * Gets the stride in float32 units (i.e. byte stride / 4).
  75313. * May not be an integer if the byte stride is not divisible by 4.
  75314. * @returns the stride in float32 units
  75315. * @deprecated Please use byteStride instead.
  75316. */
  75317. getStrideSize(): number;
  75318. /**
  75319. * Returns the offset as a multiple of the type byte length.
  75320. * @returns the offset in bytes
  75321. * @deprecated Please use byteOffset instead.
  75322. */
  75323. getOffset(): number;
  75324. /**
  75325. * Returns the number of components per vertex attribute (integer)
  75326. * @returns the size in float
  75327. */
  75328. getSize(): number;
  75329. /**
  75330. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75331. * @returns true if this buffer is instanced
  75332. */
  75333. getIsInstanced(): boolean;
  75334. /**
  75335. * Returns the instancing divisor, zero for non-instanced (integer).
  75336. * @returns a number
  75337. */
  75338. getInstanceDivisor(): number;
  75339. /**
  75340. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75341. * @param data defines the data to store
  75342. */
  75343. create(data?: DataArray): void;
  75344. /**
  75345. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75346. * This function will create a new buffer if the current one is not updatable
  75347. * @param data defines the data to store
  75348. */
  75349. update(data: DataArray): void;
  75350. /**
  75351. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75352. * Returns the directly updated WebGLBuffer.
  75353. * @param data the new data
  75354. * @param offset the new offset
  75355. * @param useBytes set to true if the offset is in bytes
  75356. */
  75357. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75358. /**
  75359. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75360. */
  75361. dispose(): void;
  75362. /**
  75363. * Enumerates each value of this vertex buffer as numbers.
  75364. * @param count the number of values to enumerate
  75365. * @param callback the callback function called for each value
  75366. */
  75367. forEach(count: number, callback: (value: number, index: number) => void): void;
  75368. /**
  75369. * Positions
  75370. */
  75371. static readonly PositionKind: string;
  75372. /**
  75373. * Normals
  75374. */
  75375. static readonly NormalKind: string;
  75376. /**
  75377. * Tangents
  75378. */
  75379. static readonly TangentKind: string;
  75380. /**
  75381. * Texture coordinates
  75382. */
  75383. static readonly UVKind: string;
  75384. /**
  75385. * Texture coordinates 2
  75386. */
  75387. static readonly UV2Kind: string;
  75388. /**
  75389. * Texture coordinates 3
  75390. */
  75391. static readonly UV3Kind: string;
  75392. /**
  75393. * Texture coordinates 4
  75394. */
  75395. static readonly UV4Kind: string;
  75396. /**
  75397. * Texture coordinates 5
  75398. */
  75399. static readonly UV5Kind: string;
  75400. /**
  75401. * Texture coordinates 6
  75402. */
  75403. static readonly UV6Kind: string;
  75404. /**
  75405. * Colors
  75406. */
  75407. static readonly ColorKind: string;
  75408. /**
  75409. * Matrix indices (for bones)
  75410. */
  75411. static readonly MatricesIndicesKind: string;
  75412. /**
  75413. * Matrix weights (for bones)
  75414. */
  75415. static readonly MatricesWeightsKind: string;
  75416. /**
  75417. * Additional matrix indices (for bones)
  75418. */
  75419. static readonly MatricesIndicesExtraKind: string;
  75420. /**
  75421. * Additional matrix weights (for bones)
  75422. */
  75423. static readonly MatricesWeightsExtraKind: string;
  75424. /**
  75425. * Deduces the stride given a kind.
  75426. * @param kind The kind string to deduce
  75427. * @returns The deduced stride
  75428. */
  75429. static DeduceStride(kind: string): number;
  75430. /**
  75431. * Gets the byte length of the given type.
  75432. * @param type the type
  75433. * @returns the number of bytes
  75434. */
  75435. static GetTypeByteLength(type: number): number;
  75436. /**
  75437. * Enumerates each value of the given parameters as numbers.
  75438. * @param data the data to enumerate
  75439. * @param byteOffset the byte offset of the data
  75440. * @param byteStride the byte stride of the data
  75441. * @param componentCount the number of components per element
  75442. * @param componentType the type of the component
  75443. * @param count the number of values to enumerate
  75444. * @param normalized whether the data is normalized
  75445. * @param callback the callback function called for each value
  75446. */
  75447. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75448. private static _GetFloatValue;
  75449. }
  75450. }
  75451. declare module BABYLON {
  75452. /**
  75453. * @hidden
  75454. */
  75455. export class IntersectionInfo {
  75456. bu: Nullable<number>;
  75457. bv: Nullable<number>;
  75458. distance: number;
  75459. faceId: number;
  75460. subMeshId: number;
  75461. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75462. }
  75463. }
  75464. declare module BABYLON {
  75465. /**
  75466. * Represens a plane by the equation ax + by + cz + d = 0
  75467. */
  75468. export class Plane {
  75469. private static _TmpMatrix;
  75470. /**
  75471. * Normal of the plane (a,b,c)
  75472. */
  75473. normal: Vector3;
  75474. /**
  75475. * d component of the plane
  75476. */
  75477. d: number;
  75478. /**
  75479. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75480. * @param a a component of the plane
  75481. * @param b b component of the plane
  75482. * @param c c component of the plane
  75483. * @param d d component of the plane
  75484. */
  75485. constructor(a: number, b: number, c: number, d: number);
  75486. /**
  75487. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75488. */
  75489. asArray(): number[];
  75490. /**
  75491. * @returns a new plane copied from the current Plane.
  75492. */
  75493. clone(): Plane;
  75494. /**
  75495. * @returns the string "Plane".
  75496. */
  75497. getClassName(): string;
  75498. /**
  75499. * @returns the Plane hash code.
  75500. */
  75501. getHashCode(): number;
  75502. /**
  75503. * Normalize the current Plane in place.
  75504. * @returns the updated Plane.
  75505. */
  75506. normalize(): Plane;
  75507. /**
  75508. * Applies a transformation the plane and returns the result
  75509. * @param transformation the transformation matrix to be applied to the plane
  75510. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75511. */
  75512. transform(transformation: DeepImmutable<Matrix>): Plane;
  75513. /**
  75514. * Calcualtte the dot product between the point and the plane normal
  75515. * @param point point to calculate the dot product with
  75516. * @returns the dot product (float) of the point coordinates and the plane normal.
  75517. */
  75518. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75519. /**
  75520. * Updates the current Plane from the plane defined by the three given points.
  75521. * @param point1 one of the points used to contruct the plane
  75522. * @param point2 one of the points used to contruct the plane
  75523. * @param point3 one of the points used to contruct the plane
  75524. * @returns the updated Plane.
  75525. */
  75526. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75527. /**
  75528. * Checks if the plane is facing a given direction
  75529. * @param direction the direction to check if the plane is facing
  75530. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75531. * @returns True is the vector "direction" is the same side than the plane normal.
  75532. */
  75533. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75534. /**
  75535. * Calculates the distance to a point
  75536. * @param point point to calculate distance to
  75537. * @returns the signed distance (float) from the given point to the Plane.
  75538. */
  75539. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75540. /**
  75541. * Creates a plane from an array
  75542. * @param array the array to create a plane from
  75543. * @returns a new Plane from the given array.
  75544. */
  75545. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75546. /**
  75547. * Creates a plane from three points
  75548. * @param point1 point used to create the plane
  75549. * @param point2 point used to create the plane
  75550. * @param point3 point used to create the plane
  75551. * @returns a new Plane defined by the three given points.
  75552. */
  75553. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75554. /**
  75555. * Creates a plane from an origin point and a normal
  75556. * @param origin origin of the plane to be constructed
  75557. * @param normal normal of the plane to be constructed
  75558. * @returns a new Plane the normal vector to this plane at the given origin point.
  75559. * Note : the vector "normal" is updated because normalized.
  75560. */
  75561. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75562. /**
  75563. * Calculates the distance from a plane and a point
  75564. * @param origin origin of the plane to be constructed
  75565. * @param normal normal of the plane to be constructed
  75566. * @param point point to calculate distance to
  75567. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75568. */
  75569. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75570. }
  75571. }
  75572. declare module BABYLON {
  75573. /**
  75574. * Class used to store bounding sphere information
  75575. */
  75576. export class BoundingSphere {
  75577. /**
  75578. * Gets the center of the bounding sphere in local space
  75579. */
  75580. readonly center: Vector3;
  75581. /**
  75582. * Radius of the bounding sphere in local space
  75583. */
  75584. radius: number;
  75585. /**
  75586. * Gets the center of the bounding sphere in world space
  75587. */
  75588. readonly centerWorld: Vector3;
  75589. /**
  75590. * Radius of the bounding sphere in world space
  75591. */
  75592. radiusWorld: number;
  75593. /**
  75594. * Gets the minimum vector in local space
  75595. */
  75596. readonly minimum: Vector3;
  75597. /**
  75598. * Gets the maximum vector in local space
  75599. */
  75600. readonly maximum: Vector3;
  75601. private _worldMatrix;
  75602. private static readonly TmpVector3;
  75603. /**
  75604. * Creates a new bounding sphere
  75605. * @param min defines the minimum vector (in local space)
  75606. * @param max defines the maximum vector (in local space)
  75607. * @param worldMatrix defines the new world matrix
  75608. */
  75609. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75610. /**
  75611. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75612. * @param min defines the new minimum vector (in local space)
  75613. * @param max defines the new maximum vector (in local space)
  75614. * @param worldMatrix defines the new world matrix
  75615. */
  75616. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75617. /**
  75618. * Scale the current bounding sphere by applying a scale factor
  75619. * @param factor defines the scale factor to apply
  75620. * @returns the current bounding box
  75621. */
  75622. scale(factor: number): BoundingSphere;
  75623. /**
  75624. * Gets the world matrix of the bounding box
  75625. * @returns a matrix
  75626. */
  75627. getWorldMatrix(): DeepImmutable<Matrix>;
  75628. /** @hidden */
  75629. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75630. /**
  75631. * Tests if the bounding sphere is intersecting the frustum planes
  75632. * @param frustumPlanes defines the frustum planes to test
  75633. * @returns true if there is an intersection
  75634. */
  75635. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75636. /**
  75637. * Tests if the bounding sphere center is in between the frustum planes.
  75638. * Used for optimistic fast inclusion.
  75639. * @param frustumPlanes defines the frustum planes to test
  75640. * @returns true if the sphere center is in between the frustum planes
  75641. */
  75642. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75643. /**
  75644. * Tests if a point is inside the bounding sphere
  75645. * @param point defines the point to test
  75646. * @returns true if the point is inside the bounding sphere
  75647. */
  75648. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75649. /**
  75650. * Checks if two sphere intersct
  75651. * @param sphere0 sphere 0
  75652. * @param sphere1 sphere 1
  75653. * @returns true if the speres intersect
  75654. */
  75655. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75656. }
  75657. }
  75658. declare module BABYLON {
  75659. /**
  75660. * Class used to store bounding box information
  75661. */
  75662. export class BoundingBox implements ICullable {
  75663. /**
  75664. * Gets the 8 vectors representing the bounding box in local space
  75665. */
  75666. readonly vectors: Vector3[];
  75667. /**
  75668. * Gets the center of the bounding box in local space
  75669. */
  75670. readonly center: Vector3;
  75671. /**
  75672. * Gets the center of the bounding box in world space
  75673. */
  75674. readonly centerWorld: Vector3;
  75675. /**
  75676. * Gets the extend size in local space
  75677. */
  75678. readonly extendSize: Vector3;
  75679. /**
  75680. * Gets the extend size in world space
  75681. */
  75682. readonly extendSizeWorld: Vector3;
  75683. /**
  75684. * Gets the OBB (object bounding box) directions
  75685. */
  75686. readonly directions: Vector3[];
  75687. /**
  75688. * Gets the 8 vectors representing the bounding box in world space
  75689. */
  75690. readonly vectorsWorld: Vector3[];
  75691. /**
  75692. * Gets the minimum vector in world space
  75693. */
  75694. readonly minimumWorld: Vector3;
  75695. /**
  75696. * Gets the maximum vector in world space
  75697. */
  75698. readonly maximumWorld: Vector3;
  75699. /**
  75700. * Gets the minimum vector in local space
  75701. */
  75702. readonly minimum: Vector3;
  75703. /**
  75704. * Gets the maximum vector in local space
  75705. */
  75706. readonly maximum: Vector3;
  75707. private _worldMatrix;
  75708. private static readonly TmpVector3;
  75709. /**
  75710. * @hidden
  75711. */
  75712. _tag: number;
  75713. /**
  75714. * Creates a new bounding box
  75715. * @param min defines the minimum vector (in local space)
  75716. * @param max defines the maximum vector (in local space)
  75717. * @param worldMatrix defines the new world matrix
  75718. */
  75719. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75720. /**
  75721. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75722. * @param min defines the new minimum vector (in local space)
  75723. * @param max defines the new maximum vector (in local space)
  75724. * @param worldMatrix defines the new world matrix
  75725. */
  75726. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75727. /**
  75728. * Scale the current bounding box by applying a scale factor
  75729. * @param factor defines the scale factor to apply
  75730. * @returns the current bounding box
  75731. */
  75732. scale(factor: number): BoundingBox;
  75733. /**
  75734. * Gets the world matrix of the bounding box
  75735. * @returns a matrix
  75736. */
  75737. getWorldMatrix(): DeepImmutable<Matrix>;
  75738. /** @hidden */
  75739. _update(world: DeepImmutable<Matrix>): void;
  75740. /**
  75741. * Tests if the bounding box is intersecting the frustum planes
  75742. * @param frustumPlanes defines the frustum planes to test
  75743. * @returns true if there is an intersection
  75744. */
  75745. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75746. /**
  75747. * Tests if the bounding box is entirely inside the frustum planes
  75748. * @param frustumPlanes defines the frustum planes to test
  75749. * @returns true if there is an inclusion
  75750. */
  75751. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75752. /**
  75753. * Tests if a point is inside the bounding box
  75754. * @param point defines the point to test
  75755. * @returns true if the point is inside the bounding box
  75756. */
  75757. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75758. /**
  75759. * Tests if the bounding box intersects with a bounding sphere
  75760. * @param sphere defines the sphere to test
  75761. * @returns true if there is an intersection
  75762. */
  75763. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75764. /**
  75765. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75766. * @param min defines the min vector to use
  75767. * @param max defines the max vector to use
  75768. * @returns true if there is an intersection
  75769. */
  75770. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75771. /**
  75772. * Tests if two bounding boxes are intersections
  75773. * @param box0 defines the first box to test
  75774. * @param box1 defines the second box to test
  75775. * @returns true if there is an intersection
  75776. */
  75777. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75778. /**
  75779. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75780. * @param minPoint defines the minimum vector of the bounding box
  75781. * @param maxPoint defines the maximum vector of the bounding box
  75782. * @param sphereCenter defines the sphere center
  75783. * @param sphereRadius defines the sphere radius
  75784. * @returns true if there is an intersection
  75785. */
  75786. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75787. /**
  75788. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75789. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75790. * @param frustumPlanes defines the frustum planes to test
  75791. * @return true if there is an inclusion
  75792. */
  75793. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75794. /**
  75795. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75796. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75797. * @param frustumPlanes defines the frustum planes to test
  75798. * @return true if there is an intersection
  75799. */
  75800. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75801. }
  75802. }
  75803. declare module BABYLON {
  75804. /** @hidden */
  75805. export class Collider {
  75806. /** Define if a collision was found */
  75807. collisionFound: boolean;
  75808. /**
  75809. * Define last intersection point in local space
  75810. */
  75811. intersectionPoint: Vector3;
  75812. /**
  75813. * Define last collided mesh
  75814. */
  75815. collidedMesh: Nullable<AbstractMesh>;
  75816. private _collisionPoint;
  75817. private _planeIntersectionPoint;
  75818. private _tempVector;
  75819. private _tempVector2;
  75820. private _tempVector3;
  75821. private _tempVector4;
  75822. private _edge;
  75823. private _baseToVertex;
  75824. private _destinationPoint;
  75825. private _slidePlaneNormal;
  75826. private _displacementVector;
  75827. /** @hidden */
  75828. _radius: Vector3;
  75829. /** @hidden */
  75830. _retry: number;
  75831. private _velocity;
  75832. private _basePoint;
  75833. private _epsilon;
  75834. /** @hidden */
  75835. _velocityWorldLength: number;
  75836. /** @hidden */
  75837. _basePointWorld: Vector3;
  75838. private _velocityWorld;
  75839. private _normalizedVelocity;
  75840. /** @hidden */
  75841. _initialVelocity: Vector3;
  75842. /** @hidden */
  75843. _initialPosition: Vector3;
  75844. private _nearestDistance;
  75845. private _collisionMask;
  75846. collisionMask: number;
  75847. /**
  75848. * Gets the plane normal used to compute the sliding response (in local space)
  75849. */
  75850. readonly slidePlaneNormal: Vector3;
  75851. /** @hidden */
  75852. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75853. /** @hidden */
  75854. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75855. /** @hidden */
  75856. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75857. /** @hidden */
  75858. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75859. /** @hidden */
  75860. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75861. /** @hidden */
  75862. _getResponse(pos: Vector3, vel: Vector3): void;
  75863. }
  75864. }
  75865. declare module BABYLON {
  75866. /**
  75867. * Interface for cullable objects
  75868. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75869. */
  75870. export interface ICullable {
  75871. /**
  75872. * Checks if the object or part of the object is in the frustum
  75873. * @param frustumPlanes Camera near/planes
  75874. * @returns true if the object is in frustum otherwise false
  75875. */
  75876. isInFrustum(frustumPlanes: Plane[]): boolean;
  75877. /**
  75878. * Checks if a cullable object (mesh...) is in the camera frustum
  75879. * Unlike isInFrustum this cheks the full bounding box
  75880. * @param frustumPlanes Camera near/planes
  75881. * @returns true if the object is in frustum otherwise false
  75882. */
  75883. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75884. }
  75885. /**
  75886. * Info for a bounding data of a mesh
  75887. */
  75888. export class BoundingInfo implements ICullable {
  75889. /**
  75890. * Bounding box for the mesh
  75891. */
  75892. readonly boundingBox: BoundingBox;
  75893. /**
  75894. * Bounding sphere for the mesh
  75895. */
  75896. readonly boundingSphere: BoundingSphere;
  75897. private _isLocked;
  75898. private static readonly TmpVector3;
  75899. /**
  75900. * Constructs bounding info
  75901. * @param minimum min vector of the bounding box/sphere
  75902. * @param maximum max vector of the bounding box/sphere
  75903. * @param worldMatrix defines the new world matrix
  75904. */
  75905. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75906. /**
  75907. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75908. * @param min defines the new minimum vector (in local space)
  75909. * @param max defines the new maximum vector (in local space)
  75910. * @param worldMatrix defines the new world matrix
  75911. */
  75912. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75913. /**
  75914. * min vector of the bounding box/sphere
  75915. */
  75916. readonly minimum: Vector3;
  75917. /**
  75918. * max vector of the bounding box/sphere
  75919. */
  75920. readonly maximum: Vector3;
  75921. /**
  75922. * If the info is locked and won't be updated to avoid perf overhead
  75923. */
  75924. isLocked: boolean;
  75925. /**
  75926. * Updates the bounding sphere and box
  75927. * @param world world matrix to be used to update
  75928. */
  75929. update(world: DeepImmutable<Matrix>): void;
  75930. /**
  75931. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75932. * @param center New center of the bounding info
  75933. * @param extend New extend of the bounding info
  75934. * @returns the current bounding info
  75935. */
  75936. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75937. /**
  75938. * Scale the current bounding info by applying a scale factor
  75939. * @param factor defines the scale factor to apply
  75940. * @returns the current bounding info
  75941. */
  75942. scale(factor: number): BoundingInfo;
  75943. /**
  75944. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75945. * @param frustumPlanes defines the frustum to test
  75946. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75947. * @returns true if the bounding info is in the frustum planes
  75948. */
  75949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75950. /**
  75951. * Gets the world distance between the min and max points of the bounding box
  75952. */
  75953. readonly diagonalLength: number;
  75954. /**
  75955. * Checks if a cullable object (mesh...) is in the camera frustum
  75956. * Unlike isInFrustum this cheks the full bounding box
  75957. * @param frustumPlanes Camera near/planes
  75958. * @returns true if the object is in frustum otherwise false
  75959. */
  75960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75961. /** @hidden */
  75962. _checkCollision(collider: Collider): boolean;
  75963. /**
  75964. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75965. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75966. * @param point the point to check intersection with
  75967. * @returns if the point intersects
  75968. */
  75969. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75970. /**
  75971. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75972. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75973. * @param boundingInfo the bounding info to check intersection with
  75974. * @param precise if the intersection should be done using OBB
  75975. * @returns if the bounding info intersects
  75976. */
  75977. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75978. }
  75979. }
  75980. declare module BABYLON {
  75981. /**
  75982. * Extracts minimum and maximum values from a list of indexed positions
  75983. * @param positions defines the positions to use
  75984. * @param indices defines the indices to the positions
  75985. * @param indexStart defines the start index
  75986. * @param indexCount defines the end index
  75987. * @param bias defines bias value to add to the result
  75988. * @return minimum and maximum values
  75989. */
  75990. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75991. minimum: Vector3;
  75992. maximum: Vector3;
  75993. };
  75994. /**
  75995. * Extracts minimum and maximum values from a list of positions
  75996. * @param positions defines the positions to use
  75997. * @param start defines the start index in the positions array
  75998. * @param count defines the number of positions to handle
  75999. * @param bias defines bias value to add to the result
  76000. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76001. * @return minimum and maximum values
  76002. */
  76003. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76004. minimum: Vector3;
  76005. maximum: Vector3;
  76006. };
  76007. }
  76008. declare module BABYLON {
  76009. /** @hidden */
  76010. export class WebGLDataBuffer extends DataBuffer {
  76011. private _buffer;
  76012. constructor(resource: WebGLBuffer);
  76013. readonly underlyingResource: any;
  76014. }
  76015. }
  76016. declare module BABYLON {
  76017. /** @hidden */
  76018. export class WebGLPipelineContext implements IPipelineContext {
  76019. engine: ThinEngine;
  76020. program: Nullable<WebGLProgram>;
  76021. context?: WebGLRenderingContext;
  76022. vertexShader?: WebGLShader;
  76023. fragmentShader?: WebGLShader;
  76024. isParallelCompiled: boolean;
  76025. onCompiled?: () => void;
  76026. transformFeedback?: WebGLTransformFeedback | null;
  76027. readonly isAsync: boolean;
  76028. readonly isReady: boolean;
  76029. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76030. }
  76031. }
  76032. declare module BABYLON {
  76033. interface ThinEngine {
  76034. /**
  76035. * Create an uniform buffer
  76036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76037. * @param elements defines the content of the uniform buffer
  76038. * @returns the webGL uniform buffer
  76039. */
  76040. createUniformBuffer(elements: FloatArray): DataBuffer;
  76041. /**
  76042. * Create a dynamic uniform buffer
  76043. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76044. * @param elements defines the content of the uniform buffer
  76045. * @returns the webGL uniform buffer
  76046. */
  76047. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76048. /**
  76049. * Update an existing uniform buffer
  76050. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76051. * @param uniformBuffer defines the target uniform buffer
  76052. * @param elements defines the content to update
  76053. * @param offset defines the offset in the uniform buffer where update should start
  76054. * @param count defines the size of the data to update
  76055. */
  76056. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76057. /**
  76058. * Bind an uniform buffer to the current webGL context
  76059. * @param buffer defines the buffer to bind
  76060. */
  76061. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76062. /**
  76063. * Bind a buffer to the current webGL context at a given location
  76064. * @param buffer defines the buffer to bind
  76065. * @param location defines the index where to bind the buffer
  76066. */
  76067. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76068. /**
  76069. * Bind a specific block at a given index in a specific shader program
  76070. * @param pipelineContext defines the pipeline context to use
  76071. * @param blockName defines the block name
  76072. * @param index defines the index where to bind the block
  76073. */
  76074. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76075. }
  76076. }
  76077. declare module BABYLON {
  76078. /**
  76079. * Uniform buffer objects.
  76080. *
  76081. * Handles blocks of uniform on the GPU.
  76082. *
  76083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76084. *
  76085. * For more information, please refer to :
  76086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76087. */
  76088. export class UniformBuffer {
  76089. private _engine;
  76090. private _buffer;
  76091. private _data;
  76092. private _bufferData;
  76093. private _dynamic?;
  76094. private _uniformLocations;
  76095. private _uniformSizes;
  76096. private _uniformLocationPointer;
  76097. private _needSync;
  76098. private _noUBO;
  76099. private _currentEffect;
  76100. /** @hidden */
  76101. _alreadyBound: boolean;
  76102. private static _MAX_UNIFORM_SIZE;
  76103. private static _tempBuffer;
  76104. /**
  76105. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76106. * This is dynamic to allow compat with webgl 1 and 2.
  76107. * You will need to pass the name of the uniform as well as the value.
  76108. */
  76109. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76110. /**
  76111. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76112. * This is dynamic to allow compat with webgl 1 and 2.
  76113. * You will need to pass the name of the uniform as well as the value.
  76114. */
  76115. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76116. /**
  76117. * Lambda to Update a single float in a uniform buffer.
  76118. * This is dynamic to allow compat with webgl 1 and 2.
  76119. * You will need to pass the name of the uniform as well as the value.
  76120. */
  76121. updateFloat: (name: string, x: number) => void;
  76122. /**
  76123. * Lambda to Update a vec2 of float in a uniform buffer.
  76124. * This is dynamic to allow compat with webgl 1 and 2.
  76125. * You will need to pass the name of the uniform as well as the value.
  76126. */
  76127. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76128. /**
  76129. * Lambda to Update a vec3 of float in a uniform buffer.
  76130. * This is dynamic to allow compat with webgl 1 and 2.
  76131. * You will need to pass the name of the uniform as well as the value.
  76132. */
  76133. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76134. /**
  76135. * Lambda to Update a vec4 of float in a uniform buffer.
  76136. * This is dynamic to allow compat with webgl 1 and 2.
  76137. * You will need to pass the name of the uniform as well as the value.
  76138. */
  76139. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76140. /**
  76141. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76142. * This is dynamic to allow compat with webgl 1 and 2.
  76143. * You will need to pass the name of the uniform as well as the value.
  76144. */
  76145. updateMatrix: (name: string, mat: Matrix) => void;
  76146. /**
  76147. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76148. * This is dynamic to allow compat with webgl 1 and 2.
  76149. * You will need to pass the name of the uniform as well as the value.
  76150. */
  76151. updateVector3: (name: string, vector: Vector3) => void;
  76152. /**
  76153. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76154. * This is dynamic to allow compat with webgl 1 and 2.
  76155. * You will need to pass the name of the uniform as well as the value.
  76156. */
  76157. updateVector4: (name: string, vector: Vector4) => void;
  76158. /**
  76159. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76160. * This is dynamic to allow compat with webgl 1 and 2.
  76161. * You will need to pass the name of the uniform as well as the value.
  76162. */
  76163. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76164. /**
  76165. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76166. * This is dynamic to allow compat with webgl 1 and 2.
  76167. * You will need to pass the name of the uniform as well as the value.
  76168. */
  76169. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76170. /**
  76171. * Instantiates a new Uniform buffer objects.
  76172. *
  76173. * Handles blocks of uniform on the GPU.
  76174. *
  76175. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76176. *
  76177. * For more information, please refer to :
  76178. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76179. * @param engine Define the engine the buffer is associated with
  76180. * @param data Define the data contained in the buffer
  76181. * @param dynamic Define if the buffer is updatable
  76182. */
  76183. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76184. /**
  76185. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76186. * or just falling back on setUniformXXX calls.
  76187. */
  76188. readonly useUbo: boolean;
  76189. /**
  76190. * Indicates if the WebGL underlying uniform buffer is in sync
  76191. * with the javascript cache data.
  76192. */
  76193. readonly isSync: boolean;
  76194. /**
  76195. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76196. * Also, a dynamic UniformBuffer will disable cache verification and always
  76197. * update the underlying WebGL uniform buffer to the GPU.
  76198. * @returns if Dynamic, otherwise false
  76199. */
  76200. isDynamic(): boolean;
  76201. /**
  76202. * The data cache on JS side.
  76203. * @returns the underlying data as a float array
  76204. */
  76205. getData(): Float32Array;
  76206. /**
  76207. * The underlying WebGL Uniform buffer.
  76208. * @returns the webgl buffer
  76209. */
  76210. getBuffer(): Nullable<DataBuffer>;
  76211. /**
  76212. * std140 layout specifies how to align data within an UBO structure.
  76213. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76214. * for specs.
  76215. */
  76216. private _fillAlignment;
  76217. /**
  76218. * Adds an uniform in the buffer.
  76219. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76220. * for the layout to be correct !
  76221. * @param name Name of the uniform, as used in the uniform block in the shader.
  76222. * @param size Data size, or data directly.
  76223. */
  76224. addUniform(name: string, size: number | number[]): void;
  76225. /**
  76226. * Adds a Matrix 4x4 to the uniform buffer.
  76227. * @param name Name of the uniform, as used in the uniform block in the shader.
  76228. * @param mat A 4x4 matrix.
  76229. */
  76230. addMatrix(name: string, mat: Matrix): void;
  76231. /**
  76232. * Adds a vec2 to the uniform buffer.
  76233. * @param name Name of the uniform, as used in the uniform block in the shader.
  76234. * @param x Define the x component value of the vec2
  76235. * @param y Define the y component value of the vec2
  76236. */
  76237. addFloat2(name: string, x: number, y: number): void;
  76238. /**
  76239. * Adds a vec3 to the uniform buffer.
  76240. * @param name Name of the uniform, as used in the uniform block in the shader.
  76241. * @param x Define the x component value of the vec3
  76242. * @param y Define the y component value of the vec3
  76243. * @param z Define the z component value of the vec3
  76244. */
  76245. addFloat3(name: string, x: number, y: number, z: number): void;
  76246. /**
  76247. * Adds a vec3 to the uniform buffer.
  76248. * @param name Name of the uniform, as used in the uniform block in the shader.
  76249. * @param color Define the vec3 from a Color
  76250. */
  76251. addColor3(name: string, color: Color3): void;
  76252. /**
  76253. * Adds a vec4 to the uniform buffer.
  76254. * @param name Name of the uniform, as used in the uniform block in the shader.
  76255. * @param color Define the rgb components from a Color
  76256. * @param alpha Define the a component of the vec4
  76257. */
  76258. addColor4(name: string, color: Color3, alpha: number): void;
  76259. /**
  76260. * Adds a vec3 to the uniform buffer.
  76261. * @param name Name of the uniform, as used in the uniform block in the shader.
  76262. * @param vector Define the vec3 components from a Vector
  76263. */
  76264. addVector3(name: string, vector: Vector3): void;
  76265. /**
  76266. * Adds a Matrix 3x3 to the uniform buffer.
  76267. * @param name Name of the uniform, as used in the uniform block in the shader.
  76268. */
  76269. addMatrix3x3(name: string): void;
  76270. /**
  76271. * Adds a Matrix 2x2 to the uniform buffer.
  76272. * @param name Name of the uniform, as used in the uniform block in the shader.
  76273. */
  76274. addMatrix2x2(name: string): void;
  76275. /**
  76276. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76277. */
  76278. create(): void;
  76279. /** @hidden */
  76280. _rebuild(): void;
  76281. /**
  76282. * Updates the WebGL Uniform Buffer on the GPU.
  76283. * If the `dynamic` flag is set to true, no cache comparison is done.
  76284. * Otherwise, the buffer will be updated only if the cache differs.
  76285. */
  76286. update(): void;
  76287. /**
  76288. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76289. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76290. * @param data Define the flattened data
  76291. * @param size Define the size of the data.
  76292. */
  76293. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76294. private _valueCache;
  76295. private _cacheMatrix;
  76296. private _updateMatrix3x3ForUniform;
  76297. private _updateMatrix3x3ForEffect;
  76298. private _updateMatrix2x2ForEffect;
  76299. private _updateMatrix2x2ForUniform;
  76300. private _updateFloatForEffect;
  76301. private _updateFloatForUniform;
  76302. private _updateFloat2ForEffect;
  76303. private _updateFloat2ForUniform;
  76304. private _updateFloat3ForEffect;
  76305. private _updateFloat3ForUniform;
  76306. private _updateFloat4ForEffect;
  76307. private _updateFloat4ForUniform;
  76308. private _updateMatrixForEffect;
  76309. private _updateMatrixForUniform;
  76310. private _updateVector3ForEffect;
  76311. private _updateVector3ForUniform;
  76312. private _updateVector4ForEffect;
  76313. private _updateVector4ForUniform;
  76314. private _updateColor3ForEffect;
  76315. private _updateColor3ForUniform;
  76316. private _updateColor4ForEffect;
  76317. private _updateColor4ForUniform;
  76318. /**
  76319. * Sets a sampler uniform on the effect.
  76320. * @param name Define the name of the sampler.
  76321. * @param texture Define the texture to set in the sampler
  76322. */
  76323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76324. /**
  76325. * Directly updates the value of the uniform in the cache AND on the GPU.
  76326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76327. * @param data Define the flattened data
  76328. */
  76329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76330. /**
  76331. * Binds this uniform buffer to an effect.
  76332. * @param effect Define the effect to bind the buffer to
  76333. * @param name Name of the uniform block in the shader.
  76334. */
  76335. bindToEffect(effect: Effect, name: string): void;
  76336. /**
  76337. * Disposes the uniform buffer.
  76338. */
  76339. dispose(): void;
  76340. }
  76341. }
  76342. declare module BABYLON {
  76343. /**
  76344. * Enum that determines the text-wrapping mode to use.
  76345. */
  76346. export enum InspectableType {
  76347. /**
  76348. * Checkbox for booleans
  76349. */
  76350. Checkbox = 0,
  76351. /**
  76352. * Sliders for numbers
  76353. */
  76354. Slider = 1,
  76355. /**
  76356. * Vector3
  76357. */
  76358. Vector3 = 2,
  76359. /**
  76360. * Quaternions
  76361. */
  76362. Quaternion = 3,
  76363. /**
  76364. * Color3
  76365. */
  76366. Color3 = 4,
  76367. /**
  76368. * String
  76369. */
  76370. String = 5
  76371. }
  76372. /**
  76373. * Interface used to define custom inspectable properties.
  76374. * This interface is used by the inspector to display custom property grids
  76375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76376. */
  76377. export interface IInspectable {
  76378. /**
  76379. * Gets the label to display
  76380. */
  76381. label: string;
  76382. /**
  76383. * Gets the name of the property to edit
  76384. */
  76385. propertyName: string;
  76386. /**
  76387. * Gets the type of the editor to use
  76388. */
  76389. type: InspectableType;
  76390. /**
  76391. * Gets the minimum value of the property when using in "slider" mode
  76392. */
  76393. min?: number;
  76394. /**
  76395. * Gets the maximum value of the property when using in "slider" mode
  76396. */
  76397. max?: number;
  76398. /**
  76399. * Gets the setp to use when using in "slider" mode
  76400. */
  76401. step?: number;
  76402. }
  76403. }
  76404. declare module BABYLON {
  76405. /**
  76406. * Class used to provide helper for timing
  76407. */
  76408. export class TimingTools {
  76409. /**
  76410. * Polyfill for setImmediate
  76411. * @param action defines the action to execute after the current execution block
  76412. */
  76413. static SetImmediate(action: () => void): void;
  76414. }
  76415. }
  76416. declare module BABYLON {
  76417. /**
  76418. * Class used to enable instatition of objects by class name
  76419. */
  76420. export class InstantiationTools {
  76421. /**
  76422. * Use this object to register external classes like custom textures or material
  76423. * to allow the laoders to instantiate them
  76424. */
  76425. static RegisteredExternalClasses: {
  76426. [key: string]: Object;
  76427. };
  76428. /**
  76429. * Tries to instantiate a new object from a given class name
  76430. * @param className defines the class name to instantiate
  76431. * @returns the new object or null if the system was not able to do the instantiation
  76432. */
  76433. static Instantiate(className: string): any;
  76434. }
  76435. }
  76436. declare module BABYLON {
  76437. /**
  76438. * Define options used to create a depth texture
  76439. */
  76440. export class DepthTextureCreationOptions {
  76441. /** Specifies whether or not a stencil should be allocated in the texture */
  76442. generateStencil?: boolean;
  76443. /** Specifies whether or not bilinear filtering is enable on the texture */
  76444. bilinearFiltering?: boolean;
  76445. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76446. comparisonFunction?: number;
  76447. /** Specifies if the created texture is a cube texture */
  76448. isCube?: boolean;
  76449. }
  76450. }
  76451. declare module BABYLON {
  76452. interface ThinEngine {
  76453. /**
  76454. * Creates a depth stencil cube texture.
  76455. * This is only available in WebGL 2.
  76456. * @param size The size of face edge in the cube texture.
  76457. * @param options The options defining the cube texture.
  76458. * @returns The cube texture
  76459. */
  76460. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76461. /**
  76462. * Creates a cube texture
  76463. * @param rootUrl defines the url where the files to load is located
  76464. * @param scene defines the current scene
  76465. * @param files defines the list of files to load (1 per face)
  76466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76467. * @param onLoad defines an optional callback raised when the texture is loaded
  76468. * @param onError defines an optional callback raised if there is an issue to load the texture
  76469. * @param format defines the format of the data
  76470. * @param forcedExtension defines the extension to use to pick the right loader
  76471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76474. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76475. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76476. * @returns the cube texture as an InternalTexture
  76477. */
  76478. 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;
  76479. /**
  76480. * Creates a cube texture
  76481. * @param rootUrl defines the url where the files to load is located
  76482. * @param scene defines the current scene
  76483. * @param files defines the list of files to load (1 per face)
  76484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76485. * @param onLoad defines an optional callback raised when the texture is loaded
  76486. * @param onError defines an optional callback raised if there is an issue to load the texture
  76487. * @param format defines the format of the data
  76488. * @param forcedExtension defines the extension to use to pick the right loader
  76489. * @returns the cube texture as an InternalTexture
  76490. */
  76491. 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;
  76492. /**
  76493. * Creates a cube texture
  76494. * @param rootUrl defines the url where the files to load is located
  76495. * @param scene defines the current scene
  76496. * @param files defines the list of files to load (1 per face)
  76497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76498. * @param onLoad defines an optional callback raised when the texture is loaded
  76499. * @param onError defines an optional callback raised if there is an issue to load the texture
  76500. * @param format defines the format of the data
  76501. * @param forcedExtension defines the extension to use to pick the right loader
  76502. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76505. * @returns the cube texture as an InternalTexture
  76506. */
  76507. 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;
  76508. /** @hidden */
  76509. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76510. /** @hidden */
  76511. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76512. /** @hidden */
  76513. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76514. /** @hidden */
  76515. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76516. /**
  76517. * @hidden
  76518. */
  76519. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76520. }
  76521. }
  76522. declare module BABYLON {
  76523. /**
  76524. * Class for creating a cube texture
  76525. */
  76526. export class CubeTexture extends BaseTexture {
  76527. private _delayedOnLoad;
  76528. /**
  76529. * The url of the texture
  76530. */
  76531. url: string;
  76532. /**
  76533. * Gets or sets the center of the bounding box associated with the cube texture.
  76534. * It must define where the camera used to render the texture was set
  76535. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76536. */
  76537. boundingBoxPosition: Vector3;
  76538. private _boundingBoxSize;
  76539. /**
  76540. * Gets or sets the size of the bounding box associated with the cube texture
  76541. * When defined, the cubemap will switch to local mode
  76542. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76543. * @example https://www.babylonjs-playground.com/#RNASML
  76544. */
  76545. /**
  76546. * Returns the bounding box size
  76547. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76548. */
  76549. boundingBoxSize: Vector3;
  76550. protected _rotationY: number;
  76551. /**
  76552. * Sets texture matrix rotation angle around Y axis in radians.
  76553. */
  76554. /**
  76555. * Gets texture matrix rotation angle around Y axis radians.
  76556. */
  76557. rotationY: number;
  76558. /**
  76559. * Are mip maps generated for this texture or not.
  76560. */
  76561. readonly noMipmap: boolean;
  76562. private _noMipmap;
  76563. private _files;
  76564. protected _forcedExtension: Nullable<string>;
  76565. private _extensions;
  76566. private _textureMatrix;
  76567. private _format;
  76568. private _createPolynomials;
  76569. /** @hidden */
  76570. _prefiltered: boolean;
  76571. /**
  76572. * Creates a cube texture from an array of image urls
  76573. * @param files defines an array of image urls
  76574. * @param scene defines the hosting scene
  76575. * @param noMipmap specifies if mip maps are not used
  76576. * @returns a cube texture
  76577. */
  76578. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76579. /**
  76580. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76581. * @param url defines the url of the prefiltered texture
  76582. * @param scene defines the scene the texture is attached to
  76583. * @param forcedExtension defines the extension of the file if different from the url
  76584. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76585. * @return the prefiltered texture
  76586. */
  76587. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76588. /**
  76589. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76590. * as prefiltered data.
  76591. * @param rootUrl defines the url of the texture or the root name of the six images
  76592. * @param scene defines the scene the texture is attached to
  76593. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76594. * @param noMipmap defines if mipmaps should be created or not
  76595. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76596. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76597. * @param onError defines a callback triggered in case of error during load
  76598. * @param format defines the internal format to use for the texture once loaded
  76599. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76600. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76601. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76602. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76603. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76604. * @return the cube texture
  76605. */
  76606. 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);
  76607. /**
  76608. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76609. */
  76610. readonly isPrefiltered: boolean;
  76611. /**
  76612. * Get the current class name of the texture useful for serialization or dynamic coding.
  76613. * @returns "CubeTexture"
  76614. */
  76615. getClassName(): string;
  76616. /**
  76617. * Update the url (and optional buffer) of this texture if url was null during construction.
  76618. * @param url the url of the texture
  76619. * @param forcedExtension defines the extension to use
  76620. * @param onLoad callback called when the texture is loaded (defaults to null)
  76621. */
  76622. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76623. /**
  76624. * Delays loading of the cube texture
  76625. * @param forcedExtension defines the extension to use
  76626. */
  76627. delayLoad(forcedExtension?: string): void;
  76628. /**
  76629. * Returns the reflection texture matrix
  76630. * @returns the reflection texture matrix
  76631. */
  76632. getReflectionTextureMatrix(): Matrix;
  76633. /**
  76634. * Sets the reflection texture matrix
  76635. * @param value Reflection texture matrix
  76636. */
  76637. setReflectionTextureMatrix(value: Matrix): void;
  76638. /**
  76639. * Parses text to create a cube texture
  76640. * @param parsedTexture define the serialized text to read from
  76641. * @param scene defines the hosting scene
  76642. * @param rootUrl defines the root url of the cube texture
  76643. * @returns a cube texture
  76644. */
  76645. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76646. /**
  76647. * Makes a clone, or deep copy, of the cube texture
  76648. * @returns a new cube texture
  76649. */
  76650. clone(): CubeTexture;
  76651. }
  76652. }
  76653. declare module BABYLON {
  76654. /**
  76655. * Manages the defines for the Material
  76656. */
  76657. export class MaterialDefines {
  76658. /** @hidden */
  76659. protected _keys: string[];
  76660. private _isDirty;
  76661. /** @hidden */
  76662. _renderId: number;
  76663. /** @hidden */
  76664. _areLightsDirty: boolean;
  76665. /** @hidden */
  76666. _areLightsDisposed: boolean;
  76667. /** @hidden */
  76668. _areAttributesDirty: boolean;
  76669. /** @hidden */
  76670. _areTexturesDirty: boolean;
  76671. /** @hidden */
  76672. _areFresnelDirty: boolean;
  76673. /** @hidden */
  76674. _areMiscDirty: boolean;
  76675. /** @hidden */
  76676. _areImageProcessingDirty: boolean;
  76677. /** @hidden */
  76678. _normals: boolean;
  76679. /** @hidden */
  76680. _uvs: boolean;
  76681. /** @hidden */
  76682. _needNormals: boolean;
  76683. /** @hidden */
  76684. _needUVs: boolean;
  76685. [id: string]: any;
  76686. /**
  76687. * Specifies if the material needs to be re-calculated
  76688. */
  76689. readonly isDirty: boolean;
  76690. /**
  76691. * Marks the material to indicate that it has been re-calculated
  76692. */
  76693. markAsProcessed(): void;
  76694. /**
  76695. * Marks the material to indicate that it needs to be re-calculated
  76696. */
  76697. markAsUnprocessed(): void;
  76698. /**
  76699. * Marks the material to indicate all of its defines need to be re-calculated
  76700. */
  76701. markAllAsDirty(): void;
  76702. /**
  76703. * Marks the material to indicate that image processing needs to be re-calculated
  76704. */
  76705. markAsImageProcessingDirty(): void;
  76706. /**
  76707. * Marks the material to indicate the lights need to be re-calculated
  76708. * @param disposed Defines whether the light is dirty due to dispose or not
  76709. */
  76710. markAsLightDirty(disposed?: boolean): void;
  76711. /**
  76712. * Marks the attribute state as changed
  76713. */
  76714. markAsAttributesDirty(): void;
  76715. /**
  76716. * Marks the texture state as changed
  76717. */
  76718. markAsTexturesDirty(): void;
  76719. /**
  76720. * Marks the fresnel state as changed
  76721. */
  76722. markAsFresnelDirty(): void;
  76723. /**
  76724. * Marks the misc state as changed
  76725. */
  76726. markAsMiscDirty(): void;
  76727. /**
  76728. * Rebuilds the material defines
  76729. */
  76730. rebuild(): void;
  76731. /**
  76732. * Specifies if two material defines are equal
  76733. * @param other - A material define instance to compare to
  76734. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76735. */
  76736. isEqual(other: MaterialDefines): boolean;
  76737. /**
  76738. * Clones this instance's defines to another instance
  76739. * @param other - material defines to clone values to
  76740. */
  76741. cloneTo(other: MaterialDefines): void;
  76742. /**
  76743. * Resets the material define values
  76744. */
  76745. reset(): void;
  76746. /**
  76747. * Converts the material define values to a string
  76748. * @returns - String of material define information
  76749. */
  76750. toString(): string;
  76751. }
  76752. }
  76753. declare module BABYLON {
  76754. /**
  76755. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76756. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76757. * 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;
  76758. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76759. */
  76760. export class ColorCurves {
  76761. private _dirty;
  76762. private _tempColor;
  76763. private _globalCurve;
  76764. private _highlightsCurve;
  76765. private _midtonesCurve;
  76766. private _shadowsCurve;
  76767. private _positiveCurve;
  76768. private _negativeCurve;
  76769. private _globalHue;
  76770. private _globalDensity;
  76771. private _globalSaturation;
  76772. private _globalExposure;
  76773. /**
  76774. * Gets the global Hue value.
  76775. * 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).
  76776. */
  76777. /**
  76778. * Sets the global Hue value.
  76779. * 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).
  76780. */
  76781. globalHue: number;
  76782. /**
  76783. * Gets the global Density value.
  76784. * 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.
  76785. * Values less than zero provide a filter of opposite hue.
  76786. */
  76787. /**
  76788. * Sets the global Density value.
  76789. * 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.
  76790. * Values less than zero provide a filter of opposite hue.
  76791. */
  76792. globalDensity: number;
  76793. /**
  76794. * Gets the global Saturation value.
  76795. * 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.
  76796. */
  76797. /**
  76798. * Sets the global Saturation value.
  76799. * 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.
  76800. */
  76801. globalSaturation: number;
  76802. /**
  76803. * Gets the global Exposure value.
  76804. * 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.
  76805. */
  76806. /**
  76807. * Sets the global Exposure value.
  76808. * 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.
  76809. */
  76810. globalExposure: number;
  76811. private _highlightsHue;
  76812. private _highlightsDensity;
  76813. private _highlightsSaturation;
  76814. private _highlightsExposure;
  76815. /**
  76816. * Gets the highlights Hue value.
  76817. * 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).
  76818. */
  76819. /**
  76820. * Sets the highlights Hue value.
  76821. * 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).
  76822. */
  76823. highlightsHue: number;
  76824. /**
  76825. * Gets the highlights Density value.
  76826. * 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.
  76827. * Values less than zero provide a filter of opposite hue.
  76828. */
  76829. /**
  76830. * Sets the highlights Density value.
  76831. * 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.
  76832. * Values less than zero provide a filter of opposite hue.
  76833. */
  76834. highlightsDensity: number;
  76835. /**
  76836. * Gets the highlights Saturation value.
  76837. * 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.
  76838. */
  76839. /**
  76840. * Sets the highlights Saturation value.
  76841. * 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.
  76842. */
  76843. highlightsSaturation: number;
  76844. /**
  76845. * Gets the highlights Exposure value.
  76846. * 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.
  76847. */
  76848. /**
  76849. * Sets the highlights Exposure value.
  76850. * 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.
  76851. */
  76852. highlightsExposure: number;
  76853. private _midtonesHue;
  76854. private _midtonesDensity;
  76855. private _midtonesSaturation;
  76856. private _midtonesExposure;
  76857. /**
  76858. * Gets the midtones Hue value.
  76859. * 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).
  76860. */
  76861. /**
  76862. * Sets the midtones Hue value.
  76863. * 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).
  76864. */
  76865. midtonesHue: number;
  76866. /**
  76867. * Gets the midtones Density value.
  76868. * 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.
  76869. * Values less than zero provide a filter of opposite hue.
  76870. */
  76871. /**
  76872. * Sets the midtones Density value.
  76873. * 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.
  76874. * Values less than zero provide a filter of opposite hue.
  76875. */
  76876. midtonesDensity: number;
  76877. /**
  76878. * Gets the midtones Saturation value.
  76879. * 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.
  76880. */
  76881. /**
  76882. * Sets the midtones Saturation value.
  76883. * 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.
  76884. */
  76885. midtonesSaturation: number;
  76886. /**
  76887. * Gets the midtones Exposure value.
  76888. * 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.
  76889. */
  76890. /**
  76891. * Sets the midtones Exposure value.
  76892. * 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.
  76893. */
  76894. midtonesExposure: number;
  76895. private _shadowsHue;
  76896. private _shadowsDensity;
  76897. private _shadowsSaturation;
  76898. private _shadowsExposure;
  76899. /**
  76900. * Gets the shadows Hue value.
  76901. * 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).
  76902. */
  76903. /**
  76904. * Sets the shadows Hue value.
  76905. * 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).
  76906. */
  76907. shadowsHue: number;
  76908. /**
  76909. * Gets the shadows Density value.
  76910. * 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.
  76911. * Values less than zero provide a filter of opposite hue.
  76912. */
  76913. /**
  76914. * Sets the shadows Density value.
  76915. * 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.
  76916. * Values less than zero provide a filter of opposite hue.
  76917. */
  76918. shadowsDensity: number;
  76919. /**
  76920. * Gets the shadows Saturation value.
  76921. * 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.
  76922. */
  76923. /**
  76924. * Sets the shadows Saturation value.
  76925. * 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.
  76926. */
  76927. shadowsSaturation: number;
  76928. /**
  76929. * Gets the shadows Exposure value.
  76930. * 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.
  76931. */
  76932. /**
  76933. * Sets the shadows Exposure value.
  76934. * 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.
  76935. */
  76936. shadowsExposure: number;
  76937. /**
  76938. * Returns the class name
  76939. * @returns The class name
  76940. */
  76941. getClassName(): string;
  76942. /**
  76943. * Binds the color curves to the shader.
  76944. * @param colorCurves The color curve to bind
  76945. * @param effect The effect to bind to
  76946. * @param positiveUniform The positive uniform shader parameter
  76947. * @param neutralUniform The neutral uniform shader parameter
  76948. * @param negativeUniform The negative uniform shader parameter
  76949. */
  76950. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76951. /**
  76952. * Prepare the list of uniforms associated with the ColorCurves effects.
  76953. * @param uniformsList The list of uniforms used in the effect
  76954. */
  76955. static PrepareUniforms(uniformsList: string[]): void;
  76956. /**
  76957. * Returns color grading data based on a hue, density, saturation and exposure value.
  76958. * @param filterHue The hue of the color filter.
  76959. * @param filterDensity The density of the color filter.
  76960. * @param saturation The saturation.
  76961. * @param exposure The exposure.
  76962. * @param result The result data container.
  76963. */
  76964. private getColorGradingDataToRef;
  76965. /**
  76966. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76967. * @param value The input slider value in range [-100,100].
  76968. * @returns Adjusted value.
  76969. */
  76970. private static applyColorGradingSliderNonlinear;
  76971. /**
  76972. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76973. * @param hue The hue (H) input.
  76974. * @param saturation The saturation (S) input.
  76975. * @param brightness The brightness (B) input.
  76976. * @result An RGBA color represented as Vector4.
  76977. */
  76978. private static fromHSBToRef;
  76979. /**
  76980. * Returns a value clamped between min and max
  76981. * @param value The value to clamp
  76982. * @param min The minimum of value
  76983. * @param max The maximum of value
  76984. * @returns The clamped value.
  76985. */
  76986. private static clamp;
  76987. /**
  76988. * Clones the current color curve instance.
  76989. * @return The cloned curves
  76990. */
  76991. clone(): ColorCurves;
  76992. /**
  76993. * Serializes the current color curve instance to a json representation.
  76994. * @return a JSON representation
  76995. */
  76996. serialize(): any;
  76997. /**
  76998. * Parses the color curve from a json representation.
  76999. * @param source the JSON source to parse
  77000. * @return The parsed curves
  77001. */
  77002. static Parse(source: any): ColorCurves;
  77003. }
  77004. }
  77005. declare module BABYLON {
  77006. /**
  77007. * Interface to follow in your material defines to integrate easily the
  77008. * Image proccessing functions.
  77009. * @hidden
  77010. */
  77011. export interface IImageProcessingConfigurationDefines {
  77012. IMAGEPROCESSING: boolean;
  77013. VIGNETTE: boolean;
  77014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77015. VIGNETTEBLENDMODEOPAQUE: boolean;
  77016. TONEMAPPING: boolean;
  77017. TONEMAPPING_ACES: boolean;
  77018. CONTRAST: boolean;
  77019. EXPOSURE: boolean;
  77020. COLORCURVES: boolean;
  77021. COLORGRADING: boolean;
  77022. COLORGRADING3D: boolean;
  77023. SAMPLER3DGREENDEPTH: boolean;
  77024. SAMPLER3DBGRMAP: boolean;
  77025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77026. }
  77027. /**
  77028. * @hidden
  77029. */
  77030. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77031. IMAGEPROCESSING: boolean;
  77032. VIGNETTE: boolean;
  77033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77034. VIGNETTEBLENDMODEOPAQUE: boolean;
  77035. TONEMAPPING: boolean;
  77036. TONEMAPPING_ACES: boolean;
  77037. CONTRAST: boolean;
  77038. COLORCURVES: boolean;
  77039. COLORGRADING: boolean;
  77040. COLORGRADING3D: boolean;
  77041. SAMPLER3DGREENDEPTH: boolean;
  77042. SAMPLER3DBGRMAP: boolean;
  77043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77044. EXPOSURE: boolean;
  77045. constructor();
  77046. }
  77047. /**
  77048. * This groups together the common properties used for image processing either in direct forward pass
  77049. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77050. * or not.
  77051. */
  77052. export class ImageProcessingConfiguration {
  77053. /**
  77054. * Default tone mapping applied in BabylonJS.
  77055. */
  77056. static readonly TONEMAPPING_STANDARD: number;
  77057. /**
  77058. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77059. * to other engines rendering to increase portability.
  77060. */
  77061. static readonly TONEMAPPING_ACES: number;
  77062. /**
  77063. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77064. */
  77065. colorCurves: Nullable<ColorCurves>;
  77066. private _colorCurvesEnabled;
  77067. /**
  77068. * Gets wether the color curves effect is enabled.
  77069. */
  77070. /**
  77071. * Sets wether the color curves effect is enabled.
  77072. */
  77073. colorCurvesEnabled: boolean;
  77074. private _colorGradingTexture;
  77075. /**
  77076. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77077. */
  77078. /**
  77079. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77080. */
  77081. colorGradingTexture: Nullable<BaseTexture>;
  77082. private _colorGradingEnabled;
  77083. /**
  77084. * Gets wether the color grading effect is enabled.
  77085. */
  77086. /**
  77087. * Sets wether the color grading effect is enabled.
  77088. */
  77089. colorGradingEnabled: boolean;
  77090. private _colorGradingWithGreenDepth;
  77091. /**
  77092. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77093. */
  77094. /**
  77095. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77096. */
  77097. colorGradingWithGreenDepth: boolean;
  77098. private _colorGradingBGR;
  77099. /**
  77100. * Gets wether the color grading texture contains BGR values.
  77101. */
  77102. /**
  77103. * Sets wether the color grading texture contains BGR values.
  77104. */
  77105. colorGradingBGR: boolean;
  77106. /** @hidden */
  77107. _exposure: number;
  77108. /**
  77109. * Gets the Exposure used in the effect.
  77110. */
  77111. /**
  77112. * Sets the Exposure used in the effect.
  77113. */
  77114. exposure: number;
  77115. private _toneMappingEnabled;
  77116. /**
  77117. * Gets wether the tone mapping effect is enabled.
  77118. */
  77119. /**
  77120. * Sets wether the tone mapping effect is enabled.
  77121. */
  77122. toneMappingEnabled: boolean;
  77123. private _toneMappingType;
  77124. /**
  77125. * Gets the type of tone mapping effect.
  77126. */
  77127. /**
  77128. * Sets the type of tone mapping effect used in BabylonJS.
  77129. */
  77130. toneMappingType: number;
  77131. protected _contrast: number;
  77132. /**
  77133. * Gets the contrast used in the effect.
  77134. */
  77135. /**
  77136. * Sets the contrast used in the effect.
  77137. */
  77138. contrast: number;
  77139. /**
  77140. * Vignette stretch size.
  77141. */
  77142. vignetteStretch: number;
  77143. /**
  77144. * Vignette centre X Offset.
  77145. */
  77146. vignetteCentreX: number;
  77147. /**
  77148. * Vignette centre Y Offset.
  77149. */
  77150. vignetteCentreY: number;
  77151. /**
  77152. * Vignette weight or intensity of the vignette effect.
  77153. */
  77154. vignetteWeight: number;
  77155. /**
  77156. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77157. * if vignetteEnabled is set to true.
  77158. */
  77159. vignetteColor: Color4;
  77160. /**
  77161. * Camera field of view used by the Vignette effect.
  77162. */
  77163. vignetteCameraFov: number;
  77164. private _vignetteBlendMode;
  77165. /**
  77166. * Gets the vignette blend mode allowing different kind of effect.
  77167. */
  77168. /**
  77169. * Sets the vignette blend mode allowing different kind of effect.
  77170. */
  77171. vignetteBlendMode: number;
  77172. private _vignetteEnabled;
  77173. /**
  77174. * Gets wether the vignette effect is enabled.
  77175. */
  77176. /**
  77177. * Sets wether the vignette effect is enabled.
  77178. */
  77179. vignetteEnabled: boolean;
  77180. private _applyByPostProcess;
  77181. /**
  77182. * Gets wether the image processing is applied through a post process or not.
  77183. */
  77184. /**
  77185. * Sets wether the image processing is applied through a post process or not.
  77186. */
  77187. applyByPostProcess: boolean;
  77188. private _isEnabled;
  77189. /**
  77190. * Gets wether the image processing is enabled or not.
  77191. */
  77192. /**
  77193. * Sets wether the image processing is enabled or not.
  77194. */
  77195. isEnabled: boolean;
  77196. /**
  77197. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77198. */
  77199. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77200. /**
  77201. * Method called each time the image processing information changes requires to recompile the effect.
  77202. */
  77203. protected _updateParameters(): void;
  77204. /**
  77205. * Gets the current class name.
  77206. * @return "ImageProcessingConfiguration"
  77207. */
  77208. getClassName(): string;
  77209. /**
  77210. * Prepare the list of uniforms associated with the Image Processing effects.
  77211. * @param uniforms The list of uniforms used in the effect
  77212. * @param defines the list of defines currently in use
  77213. */
  77214. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77215. /**
  77216. * Prepare the list of samplers associated with the Image Processing effects.
  77217. * @param samplersList The list of uniforms used in the effect
  77218. * @param defines the list of defines currently in use
  77219. */
  77220. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77221. /**
  77222. * Prepare the list of defines associated to the shader.
  77223. * @param defines the list of defines to complete
  77224. * @param forPostProcess Define if we are currently in post process mode or not
  77225. */
  77226. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77227. /**
  77228. * Returns true if all the image processing information are ready.
  77229. * @returns True if ready, otherwise, false
  77230. */
  77231. isReady(): boolean;
  77232. /**
  77233. * Binds the image processing to the shader.
  77234. * @param effect The effect to bind to
  77235. * @param overrideAspectRatio Override the aspect ratio of the effect
  77236. */
  77237. bind(effect: Effect, overrideAspectRatio?: number): void;
  77238. /**
  77239. * Clones the current image processing instance.
  77240. * @return The cloned image processing
  77241. */
  77242. clone(): ImageProcessingConfiguration;
  77243. /**
  77244. * Serializes the current image processing instance to a json representation.
  77245. * @return a JSON representation
  77246. */
  77247. serialize(): any;
  77248. /**
  77249. * Parses the image processing from a json representation.
  77250. * @param source the JSON source to parse
  77251. * @return The parsed image processing
  77252. */
  77253. static Parse(source: any): ImageProcessingConfiguration;
  77254. private static _VIGNETTEMODE_MULTIPLY;
  77255. private static _VIGNETTEMODE_OPAQUE;
  77256. /**
  77257. * Used to apply the vignette as a mix with the pixel color.
  77258. */
  77259. static readonly VIGNETTEMODE_MULTIPLY: number;
  77260. /**
  77261. * Used to apply the vignette as a replacement of the pixel color.
  77262. */
  77263. static readonly VIGNETTEMODE_OPAQUE: number;
  77264. }
  77265. }
  77266. declare module BABYLON {
  77267. /** @hidden */
  77268. export var postprocessVertexShader: {
  77269. name: string;
  77270. shader: string;
  77271. };
  77272. }
  77273. declare module BABYLON {
  77274. interface ThinEngine {
  77275. /**
  77276. * Creates a new render target texture
  77277. * @param size defines the size of the texture
  77278. * @param options defines the options used to create the texture
  77279. * @returns a new render target texture stored in an InternalTexture
  77280. */
  77281. createRenderTargetTexture(size: number | {
  77282. width: number;
  77283. height: number;
  77284. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77285. /**
  77286. * Creates a depth stencil texture.
  77287. * This is only available in WebGL 2 or with the depth texture extension available.
  77288. * @param size The size of face edge in the texture.
  77289. * @param options The options defining the texture.
  77290. * @returns The texture
  77291. */
  77292. createDepthStencilTexture(size: number | {
  77293. width: number;
  77294. height: number;
  77295. }, options: DepthTextureCreationOptions): InternalTexture;
  77296. /** @hidden */
  77297. _createDepthStencilTexture(size: number | {
  77298. width: number;
  77299. height: number;
  77300. }, options: DepthTextureCreationOptions): InternalTexture;
  77301. }
  77302. }
  77303. declare module BABYLON {
  77304. /** Defines supported spaces */
  77305. export enum Space {
  77306. /** Local (object) space */
  77307. LOCAL = 0,
  77308. /** World space */
  77309. WORLD = 1,
  77310. /** Bone space */
  77311. BONE = 2
  77312. }
  77313. /** Defines the 3 main axes */
  77314. export class Axis {
  77315. /** X axis */
  77316. static X: Vector3;
  77317. /** Y axis */
  77318. static Y: Vector3;
  77319. /** Z axis */
  77320. static Z: Vector3;
  77321. }
  77322. }
  77323. declare module BABYLON {
  77324. /**
  77325. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77326. * This is the base of the follow, arc rotate cameras and Free camera
  77327. * @see http://doc.babylonjs.com/features/cameras
  77328. */
  77329. export class TargetCamera extends Camera {
  77330. private static _RigCamTransformMatrix;
  77331. private static _TargetTransformMatrix;
  77332. private static _TargetFocalPoint;
  77333. /**
  77334. * Define the current direction the camera is moving to
  77335. */
  77336. cameraDirection: Vector3;
  77337. /**
  77338. * Define the current rotation the camera is rotating to
  77339. */
  77340. cameraRotation: Vector2;
  77341. /**
  77342. * When set, the up vector of the camera will be updated by the rotation of the camera
  77343. */
  77344. updateUpVectorFromRotation: boolean;
  77345. private _tmpQuaternion;
  77346. /**
  77347. * Define the current rotation of the camera
  77348. */
  77349. rotation: Vector3;
  77350. /**
  77351. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77352. */
  77353. rotationQuaternion: Quaternion;
  77354. /**
  77355. * Define the current speed of the camera
  77356. */
  77357. speed: number;
  77358. /**
  77359. * Add constraint to the camera to prevent it to move freely in all directions and
  77360. * around all axis.
  77361. */
  77362. noRotationConstraint: boolean;
  77363. /**
  77364. * Define the current target of the camera as an object or a position.
  77365. */
  77366. lockedTarget: any;
  77367. /** @hidden */
  77368. _currentTarget: Vector3;
  77369. /** @hidden */
  77370. _initialFocalDistance: number;
  77371. /** @hidden */
  77372. _viewMatrix: Matrix;
  77373. /** @hidden */
  77374. _camMatrix: Matrix;
  77375. /** @hidden */
  77376. _cameraTransformMatrix: Matrix;
  77377. /** @hidden */
  77378. _cameraRotationMatrix: Matrix;
  77379. /** @hidden */
  77380. _referencePoint: Vector3;
  77381. /** @hidden */
  77382. _transformedReferencePoint: Vector3;
  77383. protected _globalCurrentTarget: Vector3;
  77384. protected _globalCurrentUpVector: Vector3;
  77385. /** @hidden */
  77386. _reset: () => void;
  77387. private _defaultUp;
  77388. /**
  77389. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77390. * This is the base of the follow, arc rotate cameras and Free camera
  77391. * @see http://doc.babylonjs.com/features/cameras
  77392. * @param name Defines the name of the camera in the scene
  77393. * @param position Defines the start position of the camera in the scene
  77394. * @param scene Defines the scene the camera belongs to
  77395. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77396. */
  77397. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77398. /**
  77399. * Gets the position in front of the camera at a given distance.
  77400. * @param distance The distance from the camera we want the position to be
  77401. * @returns the position
  77402. */
  77403. getFrontPosition(distance: number): Vector3;
  77404. /** @hidden */
  77405. _getLockedTargetPosition(): Nullable<Vector3>;
  77406. private _storedPosition;
  77407. private _storedRotation;
  77408. private _storedRotationQuaternion;
  77409. /**
  77410. * Store current camera state of the camera (fov, position, rotation, etc..)
  77411. * @returns the camera
  77412. */
  77413. storeState(): Camera;
  77414. /**
  77415. * Restored camera state. You must call storeState() first
  77416. * @returns whether it was successful or not
  77417. * @hidden
  77418. */
  77419. _restoreStateValues(): boolean;
  77420. /** @hidden */
  77421. _initCache(): void;
  77422. /** @hidden */
  77423. _updateCache(ignoreParentClass?: boolean): void;
  77424. /** @hidden */
  77425. _isSynchronizedViewMatrix(): boolean;
  77426. /** @hidden */
  77427. _computeLocalCameraSpeed(): number;
  77428. /**
  77429. * Defines the target the camera should look at.
  77430. * @param target Defines the new target as a Vector or a mesh
  77431. */
  77432. setTarget(target: Vector3): void;
  77433. /**
  77434. * Return the current target position of the camera. This value is expressed in local space.
  77435. * @returns the target position
  77436. */
  77437. getTarget(): Vector3;
  77438. /** @hidden */
  77439. _decideIfNeedsToMove(): boolean;
  77440. /** @hidden */
  77441. _updatePosition(): void;
  77442. /** @hidden */
  77443. _checkInputs(): void;
  77444. protected _updateCameraRotationMatrix(): void;
  77445. /**
  77446. * 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)
  77447. * @returns the current camera
  77448. */
  77449. private _rotateUpVectorWithCameraRotationMatrix;
  77450. private _cachedRotationZ;
  77451. private _cachedQuaternionRotationZ;
  77452. /** @hidden */
  77453. _getViewMatrix(): Matrix;
  77454. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77455. /**
  77456. * @hidden
  77457. */
  77458. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77459. /**
  77460. * @hidden
  77461. */
  77462. _updateRigCameras(): void;
  77463. private _getRigCamPositionAndTarget;
  77464. /**
  77465. * Gets the current object class name.
  77466. * @return the class name
  77467. */
  77468. getClassName(): string;
  77469. }
  77470. }
  77471. declare module BABYLON {
  77472. /**
  77473. * Gather the list of keyboard event types as constants.
  77474. */
  77475. export class KeyboardEventTypes {
  77476. /**
  77477. * The keydown event is fired when a key becomes active (pressed).
  77478. */
  77479. static readonly KEYDOWN: number;
  77480. /**
  77481. * The keyup event is fired when a key has been released.
  77482. */
  77483. static readonly KEYUP: number;
  77484. }
  77485. /**
  77486. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77487. */
  77488. export class KeyboardInfo {
  77489. /**
  77490. * Defines the type of event (KeyboardEventTypes)
  77491. */
  77492. type: number;
  77493. /**
  77494. * Defines the related dom event
  77495. */
  77496. event: KeyboardEvent;
  77497. /**
  77498. * Instantiates a new keyboard info.
  77499. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77500. * @param type Defines the type of event (KeyboardEventTypes)
  77501. * @param event Defines the related dom event
  77502. */
  77503. constructor(
  77504. /**
  77505. * Defines the type of event (KeyboardEventTypes)
  77506. */
  77507. type: number,
  77508. /**
  77509. * Defines the related dom event
  77510. */
  77511. event: KeyboardEvent);
  77512. }
  77513. /**
  77514. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77515. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77516. */
  77517. export class KeyboardInfoPre extends KeyboardInfo {
  77518. /**
  77519. * Defines the type of event (KeyboardEventTypes)
  77520. */
  77521. type: number;
  77522. /**
  77523. * Defines the related dom event
  77524. */
  77525. event: KeyboardEvent;
  77526. /**
  77527. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77528. */
  77529. skipOnPointerObservable: boolean;
  77530. /**
  77531. * Instantiates a new keyboard pre info.
  77532. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77533. * @param type Defines the type of event (KeyboardEventTypes)
  77534. * @param event Defines the related dom event
  77535. */
  77536. constructor(
  77537. /**
  77538. * Defines the type of event (KeyboardEventTypes)
  77539. */
  77540. type: number,
  77541. /**
  77542. * Defines the related dom event
  77543. */
  77544. event: KeyboardEvent);
  77545. }
  77546. }
  77547. declare module BABYLON {
  77548. /**
  77549. * Manage the keyboard inputs to control the movement of a free camera.
  77550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77551. */
  77552. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77553. /**
  77554. * Defines the camera the input is attached to.
  77555. */
  77556. camera: FreeCamera;
  77557. /**
  77558. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77559. */
  77560. keysUp: number[];
  77561. /**
  77562. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77563. */
  77564. keysDown: number[];
  77565. /**
  77566. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77567. */
  77568. keysLeft: number[];
  77569. /**
  77570. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77571. */
  77572. keysRight: number[];
  77573. private _keys;
  77574. private _onCanvasBlurObserver;
  77575. private _onKeyboardObserver;
  77576. private _engine;
  77577. private _scene;
  77578. /**
  77579. * Attach the input controls to a specific dom element to get the input from.
  77580. * @param element Defines the element the controls should be listened from
  77581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77582. */
  77583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77584. /**
  77585. * Detach the current controls from the specified dom element.
  77586. * @param element Defines the element to stop listening the inputs from
  77587. */
  77588. detachControl(element: Nullable<HTMLElement>): void;
  77589. /**
  77590. * Update the current camera state depending on the inputs that have been used this frame.
  77591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77592. */
  77593. checkInputs(): void;
  77594. /**
  77595. * Gets the class name of the current intput.
  77596. * @returns the class name
  77597. */
  77598. getClassName(): string;
  77599. /** @hidden */
  77600. _onLostFocus(): void;
  77601. /**
  77602. * Get the friendly name associated with the input class.
  77603. * @returns the input friendly name
  77604. */
  77605. getSimpleName(): string;
  77606. }
  77607. }
  77608. declare module BABYLON {
  77609. /**
  77610. * Interface describing all the common properties and methods a shadow light needs to implement.
  77611. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77612. * as well as binding the different shadow properties to the effects.
  77613. */
  77614. export interface IShadowLight extends Light {
  77615. /**
  77616. * The light id in the scene (used in scene.findLighById for instance)
  77617. */
  77618. id: string;
  77619. /**
  77620. * The position the shdow will be casted from.
  77621. */
  77622. position: Vector3;
  77623. /**
  77624. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77625. */
  77626. direction: Vector3;
  77627. /**
  77628. * The transformed position. Position of the light in world space taking parenting in account.
  77629. */
  77630. transformedPosition: Vector3;
  77631. /**
  77632. * The transformed direction. Direction of the light in world space taking parenting in account.
  77633. */
  77634. transformedDirection: Vector3;
  77635. /**
  77636. * The friendly name of the light in the scene.
  77637. */
  77638. name: string;
  77639. /**
  77640. * Defines the shadow projection clipping minimum z value.
  77641. */
  77642. shadowMinZ: number;
  77643. /**
  77644. * Defines the shadow projection clipping maximum z value.
  77645. */
  77646. shadowMaxZ: number;
  77647. /**
  77648. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77649. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77650. */
  77651. computeTransformedInformation(): boolean;
  77652. /**
  77653. * Gets the scene the light belongs to.
  77654. * @returns The scene
  77655. */
  77656. getScene(): Scene;
  77657. /**
  77658. * Callback defining a custom Projection Matrix Builder.
  77659. * This can be used to override the default projection matrix computation.
  77660. */
  77661. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77662. /**
  77663. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77664. * @param matrix The materix to updated with the projection information
  77665. * @param viewMatrix The transform matrix of the light
  77666. * @param renderList The list of mesh to render in the map
  77667. * @returns The current light
  77668. */
  77669. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77670. /**
  77671. * Gets the current depth scale used in ESM.
  77672. * @returns The scale
  77673. */
  77674. getDepthScale(): number;
  77675. /**
  77676. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77677. * @returns true if a cube texture needs to be use
  77678. */
  77679. needCube(): boolean;
  77680. /**
  77681. * Detects if the projection matrix requires to be recomputed this frame.
  77682. * @returns true if it requires to be recomputed otherwise, false.
  77683. */
  77684. needProjectionMatrixCompute(): boolean;
  77685. /**
  77686. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77687. */
  77688. forceProjectionMatrixCompute(): void;
  77689. /**
  77690. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77691. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77692. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77693. */
  77694. getShadowDirection(faceIndex?: number): Vector3;
  77695. /**
  77696. * Gets the minZ used for shadow according to both the scene and the light.
  77697. * @param activeCamera The camera we are returning the min for
  77698. * @returns the depth min z
  77699. */
  77700. getDepthMinZ(activeCamera: Camera): number;
  77701. /**
  77702. * Gets the maxZ used for shadow according to both the scene and the light.
  77703. * @param activeCamera The camera we are returning the max for
  77704. * @returns the depth max z
  77705. */
  77706. getDepthMaxZ(activeCamera: Camera): number;
  77707. }
  77708. /**
  77709. * Base implementation IShadowLight
  77710. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77711. */
  77712. export abstract class ShadowLight extends Light implements IShadowLight {
  77713. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77714. protected _position: Vector3;
  77715. protected _setPosition(value: Vector3): void;
  77716. /**
  77717. * Sets the position the shadow will be casted from. Also use as the light position for both
  77718. * point and spot lights.
  77719. */
  77720. /**
  77721. * Sets the position the shadow will be casted from. Also use as the light position for both
  77722. * point and spot lights.
  77723. */
  77724. position: Vector3;
  77725. protected _direction: Vector3;
  77726. protected _setDirection(value: Vector3): void;
  77727. /**
  77728. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77729. * Also use as the light direction on spot and directional lights.
  77730. */
  77731. /**
  77732. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77733. * Also use as the light direction on spot and directional lights.
  77734. */
  77735. direction: Vector3;
  77736. private _shadowMinZ;
  77737. /**
  77738. * Gets the shadow projection clipping minimum z value.
  77739. */
  77740. /**
  77741. * Sets the shadow projection clipping minimum z value.
  77742. */
  77743. shadowMinZ: number;
  77744. private _shadowMaxZ;
  77745. /**
  77746. * Sets the shadow projection clipping maximum z value.
  77747. */
  77748. /**
  77749. * Gets the shadow projection clipping maximum z value.
  77750. */
  77751. shadowMaxZ: number;
  77752. /**
  77753. * Callback defining a custom Projection Matrix Builder.
  77754. * This can be used to override the default projection matrix computation.
  77755. */
  77756. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77757. /**
  77758. * The transformed position. Position of the light in world space taking parenting in account.
  77759. */
  77760. transformedPosition: Vector3;
  77761. /**
  77762. * The transformed direction. Direction of the light in world space taking parenting in account.
  77763. */
  77764. transformedDirection: Vector3;
  77765. private _needProjectionMatrixCompute;
  77766. /**
  77767. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77768. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77769. */
  77770. computeTransformedInformation(): boolean;
  77771. /**
  77772. * Return the depth scale used for the shadow map.
  77773. * @returns the depth scale.
  77774. */
  77775. getDepthScale(): number;
  77776. /**
  77777. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77778. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77779. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77780. */
  77781. getShadowDirection(faceIndex?: number): Vector3;
  77782. /**
  77783. * Returns the ShadowLight absolute position in the World.
  77784. * @returns the position vector in world space
  77785. */
  77786. getAbsolutePosition(): Vector3;
  77787. /**
  77788. * Sets the ShadowLight direction toward the passed target.
  77789. * @param target The point to target in local space
  77790. * @returns the updated ShadowLight direction
  77791. */
  77792. setDirectionToTarget(target: Vector3): Vector3;
  77793. /**
  77794. * Returns the light rotation in euler definition.
  77795. * @returns the x y z rotation in local space.
  77796. */
  77797. getRotation(): Vector3;
  77798. /**
  77799. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77800. * @returns true if a cube texture needs to be use
  77801. */
  77802. needCube(): boolean;
  77803. /**
  77804. * Detects if the projection matrix requires to be recomputed this frame.
  77805. * @returns true if it requires to be recomputed otherwise, false.
  77806. */
  77807. needProjectionMatrixCompute(): boolean;
  77808. /**
  77809. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77810. */
  77811. forceProjectionMatrixCompute(): void;
  77812. /** @hidden */
  77813. _initCache(): void;
  77814. /** @hidden */
  77815. _isSynchronized(): boolean;
  77816. /**
  77817. * Computes the world matrix of the node
  77818. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77819. * @returns the world matrix
  77820. */
  77821. computeWorldMatrix(force?: boolean): Matrix;
  77822. /**
  77823. * Gets the minZ used for shadow according to both the scene and the light.
  77824. * @param activeCamera The camera we are returning the min for
  77825. * @returns the depth min z
  77826. */
  77827. getDepthMinZ(activeCamera: Camera): number;
  77828. /**
  77829. * Gets the maxZ used for shadow according to both the scene and the light.
  77830. * @param activeCamera The camera we are returning the max for
  77831. * @returns the depth max z
  77832. */
  77833. getDepthMaxZ(activeCamera: Camera): number;
  77834. /**
  77835. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77836. * @param matrix The materix to updated with the projection information
  77837. * @param viewMatrix The transform matrix of the light
  77838. * @param renderList The list of mesh to render in the map
  77839. * @returns The current light
  77840. */
  77841. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77842. }
  77843. }
  77844. declare module BABYLON {
  77845. /**
  77846. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77847. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77848. */
  77849. export class EffectFallbacks implements IEffectFallbacks {
  77850. private _defines;
  77851. private _currentRank;
  77852. private _maxRank;
  77853. private _mesh;
  77854. /**
  77855. * Removes the fallback from the bound mesh.
  77856. */
  77857. unBindMesh(): void;
  77858. /**
  77859. * Adds a fallback on the specified property.
  77860. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77861. * @param define The name of the define in the shader
  77862. */
  77863. addFallback(rank: number, define: string): void;
  77864. /**
  77865. * Sets the mesh to use CPU skinning when needing to fallback.
  77866. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77867. * @param mesh The mesh to use the fallbacks.
  77868. */
  77869. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77870. /**
  77871. * Checks to see if more fallbacks are still availible.
  77872. */
  77873. readonly hasMoreFallbacks: boolean;
  77874. /**
  77875. * Removes the defines that should be removed when falling back.
  77876. * @param currentDefines defines the current define statements for the shader.
  77877. * @param effect defines the current effect we try to compile
  77878. * @returns The resulting defines with defines of the current rank removed.
  77879. */
  77880. reduce(currentDefines: string, effect: Effect): string;
  77881. }
  77882. }
  77883. declare module BABYLON {
  77884. /**
  77885. * "Static Class" containing the most commonly used helper while dealing with material for
  77886. * rendering purpose.
  77887. *
  77888. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77889. *
  77890. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77891. */
  77892. export class MaterialHelper {
  77893. /**
  77894. * Bind the current view position to an effect.
  77895. * @param effect The effect to be bound
  77896. * @param scene The scene the eyes position is used from
  77897. */
  77898. static BindEyePosition(effect: Effect, scene: Scene): void;
  77899. /**
  77900. * Helps preparing the defines values about the UVs in used in the effect.
  77901. * UVs are shared as much as we can accross channels in the shaders.
  77902. * @param texture The texture we are preparing the UVs for
  77903. * @param defines The defines to update
  77904. * @param key The channel key "diffuse", "specular"... used in the shader
  77905. */
  77906. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77907. /**
  77908. * Binds a texture matrix value to its corrsponding uniform
  77909. * @param texture The texture to bind the matrix for
  77910. * @param uniformBuffer The uniform buffer receivin the data
  77911. * @param key The channel key "diffuse", "specular"... used in the shader
  77912. */
  77913. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77914. /**
  77915. * Gets the current status of the fog (should it be enabled?)
  77916. * @param mesh defines the mesh to evaluate for fog support
  77917. * @param scene defines the hosting scene
  77918. * @returns true if fog must be enabled
  77919. */
  77920. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77921. /**
  77922. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77923. * @param mesh defines the current mesh
  77924. * @param scene defines the current scene
  77925. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77926. * @param pointsCloud defines if point cloud rendering has to be turned on
  77927. * @param fogEnabled defines if fog has to be turned on
  77928. * @param alphaTest defines if alpha testing has to be turned on
  77929. * @param defines defines the current list of defines
  77930. */
  77931. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77932. /**
  77933. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77934. * @param scene defines the current scene
  77935. * @param engine defines the current engine
  77936. * @param defines specifies the list of active defines
  77937. * @param useInstances defines if instances have to be turned on
  77938. * @param useClipPlane defines if clip plane have to be turned on
  77939. */
  77940. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77941. /**
  77942. * Prepares the defines for bones
  77943. * @param mesh The mesh containing the geometry data we will draw
  77944. * @param defines The defines to update
  77945. */
  77946. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77947. /**
  77948. * Prepares the defines for morph targets
  77949. * @param mesh The mesh containing the geometry data we will draw
  77950. * @param defines The defines to update
  77951. */
  77952. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77953. /**
  77954. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77955. * @param mesh The mesh containing the geometry data we will draw
  77956. * @param defines The defines to update
  77957. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77958. * @param useBones Precise whether bones should be used or not (override mesh info)
  77959. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77960. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77961. * @returns false if defines are considered not dirty and have not been checked
  77962. */
  77963. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77964. /**
  77965. * Prepares the defines related to multiview
  77966. * @param scene The scene we are intending to draw
  77967. * @param defines The defines to update
  77968. */
  77969. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77970. /**
  77971. * Prepares the defines related to the light information passed in parameter
  77972. * @param scene The scene we are intending to draw
  77973. * @param mesh The mesh the effect is compiling for
  77974. * @param light The light the effect is compiling for
  77975. * @param lightIndex The index of the light
  77976. * @param defines The defines to update
  77977. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77978. * @param state Defines the current state regarding what is needed (normals, etc...)
  77979. */
  77980. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77981. needNormals: boolean;
  77982. needRebuild: boolean;
  77983. shadowEnabled: boolean;
  77984. specularEnabled: boolean;
  77985. lightmapMode: boolean;
  77986. }): void;
  77987. /**
  77988. * Prepares the defines related to the light information passed in parameter
  77989. * @param scene The scene we are intending to draw
  77990. * @param mesh The mesh the effect is compiling for
  77991. * @param defines The defines to update
  77992. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77993. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77994. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77995. * @returns true if normals will be required for the rest of the effect
  77996. */
  77997. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77998. /**
  77999. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78000. * @param lightIndex defines the light index
  78001. * @param uniformsList The uniform list
  78002. * @param samplersList The sampler list
  78003. * @param projectedLightTexture defines if projected texture must be used
  78004. * @param uniformBuffersList defines an optional list of uniform buffers
  78005. */
  78006. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78007. /**
  78008. * Prepares the uniforms and samplers list to be used in the effect
  78009. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78010. * @param samplersList The sampler list
  78011. * @param defines The defines helping in the list generation
  78012. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78013. */
  78014. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78015. /**
  78016. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78017. * @param defines The defines to update while falling back
  78018. * @param fallbacks The authorized effect fallbacks
  78019. * @param maxSimultaneousLights The maximum number of lights allowed
  78020. * @param rank the current rank of the Effect
  78021. * @returns The newly affected rank
  78022. */
  78023. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78024. private static _TmpMorphInfluencers;
  78025. /**
  78026. * Prepares the list of attributes required for morph targets according to the effect defines.
  78027. * @param attribs The current list of supported attribs
  78028. * @param mesh The mesh to prepare the morph targets attributes for
  78029. * @param influencers The number of influencers
  78030. */
  78031. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78032. /**
  78033. * Prepares the list of attributes required for morph targets according to the effect defines.
  78034. * @param attribs The current list of supported attribs
  78035. * @param mesh The mesh to prepare the morph targets attributes for
  78036. * @param defines The current Defines of the effect
  78037. */
  78038. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78039. /**
  78040. * Prepares the list of attributes required for bones according to the effect defines.
  78041. * @param attribs The current list of supported attribs
  78042. * @param mesh The mesh to prepare the bones attributes for
  78043. * @param defines The current Defines of the effect
  78044. * @param fallbacks The current efffect fallback strategy
  78045. */
  78046. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78047. /**
  78048. * Check and prepare the list of attributes required for instances according to the effect defines.
  78049. * @param attribs The current list of supported attribs
  78050. * @param defines The current MaterialDefines of the effect
  78051. */
  78052. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78053. /**
  78054. * Add the list of attributes required for instances to the attribs array.
  78055. * @param attribs The current list of supported attribs
  78056. */
  78057. static PushAttributesForInstances(attribs: string[]): void;
  78058. /**
  78059. * Binds the light information to the effect.
  78060. * @param light The light containing the generator
  78061. * @param effect The effect we are binding the data to
  78062. * @param lightIndex The light index in the effect used to render
  78063. */
  78064. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78065. /**
  78066. * Binds the lights information from the scene to the effect for the given mesh.
  78067. * @param light Light to bind
  78068. * @param lightIndex Light index
  78069. * @param scene The scene where the light belongs to
  78070. * @param effect The effect we are binding the data to
  78071. * @param useSpecular Defines if specular is supported
  78072. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78073. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78074. */
  78075. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78076. /**
  78077. * Binds the lights information from the scene to the effect for the given mesh.
  78078. * @param scene The scene the lights belongs to
  78079. * @param mesh The mesh we are binding the information to render
  78080. * @param effect The effect we are binding the data to
  78081. * @param defines The generated defines for the effect
  78082. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78083. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78084. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78085. */
  78086. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78087. private static _tempFogColor;
  78088. /**
  78089. * Binds the fog information from the scene to the effect for the given mesh.
  78090. * @param scene The scene the lights belongs to
  78091. * @param mesh The mesh we are binding the information to render
  78092. * @param effect The effect we are binding the data to
  78093. * @param linearSpace Defines if the fog effect is applied in linear space
  78094. */
  78095. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78096. /**
  78097. * Binds the bones information from the mesh to the effect.
  78098. * @param mesh The mesh we are binding the information to render
  78099. * @param effect The effect we are binding the data to
  78100. */
  78101. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78102. /**
  78103. * Binds the morph targets information from the mesh to the effect.
  78104. * @param abstractMesh The mesh we are binding the information to render
  78105. * @param effect The effect we are binding the data to
  78106. */
  78107. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78108. /**
  78109. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78110. * @param defines The generated defines used in the effect
  78111. * @param effect The effect we are binding the data to
  78112. * @param scene The scene we are willing to render with logarithmic scale for
  78113. */
  78114. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78115. /**
  78116. * Binds the clip plane information from the scene to the effect.
  78117. * @param scene The scene the clip plane information are extracted from
  78118. * @param effect The effect we are binding the data to
  78119. */
  78120. static BindClipPlane(effect: Effect, scene: Scene): void;
  78121. }
  78122. }
  78123. declare module BABYLON {
  78124. /** @hidden */
  78125. export var packingFunctions: {
  78126. name: string;
  78127. shader: string;
  78128. };
  78129. }
  78130. declare module BABYLON {
  78131. /** @hidden */
  78132. export var shadowMapPixelShader: {
  78133. name: string;
  78134. shader: string;
  78135. };
  78136. }
  78137. declare module BABYLON {
  78138. /** @hidden */
  78139. export var bonesDeclaration: {
  78140. name: string;
  78141. shader: string;
  78142. };
  78143. }
  78144. declare module BABYLON {
  78145. /** @hidden */
  78146. export var morphTargetsVertexGlobalDeclaration: {
  78147. name: string;
  78148. shader: string;
  78149. };
  78150. }
  78151. declare module BABYLON {
  78152. /** @hidden */
  78153. export var morphTargetsVertexDeclaration: {
  78154. name: string;
  78155. shader: string;
  78156. };
  78157. }
  78158. declare module BABYLON {
  78159. /** @hidden */
  78160. export var instancesDeclaration: {
  78161. name: string;
  78162. shader: string;
  78163. };
  78164. }
  78165. declare module BABYLON {
  78166. /** @hidden */
  78167. export var helperFunctions: {
  78168. name: string;
  78169. shader: string;
  78170. };
  78171. }
  78172. declare module BABYLON {
  78173. /** @hidden */
  78174. export var morphTargetsVertex: {
  78175. name: string;
  78176. shader: string;
  78177. };
  78178. }
  78179. declare module BABYLON {
  78180. /** @hidden */
  78181. export var instancesVertex: {
  78182. name: string;
  78183. shader: string;
  78184. };
  78185. }
  78186. declare module BABYLON {
  78187. /** @hidden */
  78188. export var bonesVertex: {
  78189. name: string;
  78190. shader: string;
  78191. };
  78192. }
  78193. declare module BABYLON {
  78194. /** @hidden */
  78195. export var shadowMapVertexShader: {
  78196. name: string;
  78197. shader: string;
  78198. };
  78199. }
  78200. declare module BABYLON {
  78201. /** @hidden */
  78202. export var depthBoxBlurPixelShader: {
  78203. name: string;
  78204. shader: string;
  78205. };
  78206. }
  78207. declare module BABYLON {
  78208. /**
  78209. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78210. */
  78211. export interface ICustomShaderOptions {
  78212. /**
  78213. * Gets or sets the custom shader name to use
  78214. */
  78215. shaderName: string;
  78216. /**
  78217. * The list of attribute names used in the shader
  78218. */
  78219. attributes?: string[];
  78220. /**
  78221. * The list of unifrom names used in the shader
  78222. */
  78223. uniforms?: string[];
  78224. /**
  78225. * The list of sampler names used in the shader
  78226. */
  78227. samplers?: string[];
  78228. /**
  78229. * The list of defines used in the shader
  78230. */
  78231. defines?: string[];
  78232. }
  78233. /**
  78234. * Interface to implement to create a shadow generator compatible with BJS.
  78235. */
  78236. export interface IShadowGenerator {
  78237. /**
  78238. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78239. * @returns The render target texture if present otherwise, null
  78240. */
  78241. getShadowMap(): Nullable<RenderTargetTexture>;
  78242. /**
  78243. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78244. * @returns The render target texture if the shadow map is present otherwise, null
  78245. */
  78246. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78247. /**
  78248. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78249. * @param subMesh The submesh we want to render in the shadow map
  78250. * @param useInstances Defines wether will draw in the map using instances
  78251. * @returns true if ready otherwise, false
  78252. */
  78253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78254. /**
  78255. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78256. * @param defines Defines of the material we want to update
  78257. * @param lightIndex Index of the light in the enabled light list of the material
  78258. */
  78259. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78260. /**
  78261. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78262. * defined in the generator but impacting the effect).
  78263. * It implies the unifroms available on the materials are the standard BJS ones.
  78264. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78265. * @param effect The effect we are binfing the information for
  78266. */
  78267. bindShadowLight(lightIndex: string, effect: Effect): void;
  78268. /**
  78269. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78270. * (eq to shadow prjection matrix * light transform matrix)
  78271. * @returns The transform matrix used to create the shadow map
  78272. */
  78273. getTransformMatrix(): Matrix;
  78274. /**
  78275. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78276. * Cube and 2D textures for instance.
  78277. */
  78278. recreateShadowMap(): void;
  78279. /**
  78280. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78281. * @param onCompiled Callback triggered at the and of the effects compilation
  78282. * @param options Sets of optional options forcing the compilation with different modes
  78283. */
  78284. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78285. useInstances: boolean;
  78286. }>): void;
  78287. /**
  78288. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78289. * @param options Sets of optional options forcing the compilation with different modes
  78290. * @returns A promise that resolves when the compilation completes
  78291. */
  78292. forceCompilationAsync(options?: Partial<{
  78293. useInstances: boolean;
  78294. }>): Promise<void>;
  78295. /**
  78296. * Serializes the shadow generator setup to a json object.
  78297. * @returns The serialized JSON object
  78298. */
  78299. serialize(): any;
  78300. /**
  78301. * Disposes the Shadow map and related Textures and effects.
  78302. */
  78303. dispose(): void;
  78304. }
  78305. /**
  78306. * Default implementation IShadowGenerator.
  78307. * This is the main object responsible of generating shadows in the framework.
  78308. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78309. */
  78310. export class ShadowGenerator implements IShadowGenerator {
  78311. /**
  78312. * Shadow generator mode None: no filtering applied.
  78313. */
  78314. static readonly FILTER_NONE: number;
  78315. /**
  78316. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78317. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78318. */
  78319. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78320. /**
  78321. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78322. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78323. */
  78324. static readonly FILTER_POISSONSAMPLING: number;
  78325. /**
  78326. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78328. */
  78329. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78330. /**
  78331. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78332. * edge artifacts on steep falloff.
  78333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78334. */
  78335. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78336. /**
  78337. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78338. * edge artifacts on steep falloff.
  78339. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78340. */
  78341. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78342. /**
  78343. * Shadow generator mode PCF: Percentage Closer Filtering
  78344. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78345. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78346. */
  78347. static readonly FILTER_PCF: number;
  78348. /**
  78349. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78350. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78351. * Contact Hardening
  78352. */
  78353. static readonly FILTER_PCSS: number;
  78354. /**
  78355. * Reserved for PCF and PCSS
  78356. * Highest Quality.
  78357. *
  78358. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78359. *
  78360. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78361. */
  78362. static readonly QUALITY_HIGH: number;
  78363. /**
  78364. * Reserved for PCF and PCSS
  78365. * Good tradeoff for quality/perf cross devices
  78366. *
  78367. * Execute PCF on a 3*3 kernel.
  78368. *
  78369. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78370. */
  78371. static readonly QUALITY_MEDIUM: number;
  78372. /**
  78373. * Reserved for PCF and PCSS
  78374. * The lowest quality but the fastest.
  78375. *
  78376. * Execute PCF on a 1*1 kernel.
  78377. *
  78378. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78379. */
  78380. static readonly QUALITY_LOW: number;
  78381. /** Gets or sets the custom shader name to use */
  78382. customShaderOptions: ICustomShaderOptions;
  78383. /**
  78384. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78385. */
  78386. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78387. /**
  78388. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78389. */
  78390. onAfterShadowMapRenderObservable: Observable<Effect>;
  78391. /**
  78392. * Observable triggered before a mesh is rendered in the shadow map.
  78393. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78394. */
  78395. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78396. /**
  78397. * Observable triggered after a mesh is rendered in the shadow map.
  78398. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78399. */
  78400. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78401. private _bias;
  78402. /**
  78403. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78404. */
  78405. /**
  78406. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78407. */
  78408. bias: number;
  78409. private _normalBias;
  78410. /**
  78411. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78412. */
  78413. /**
  78414. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78415. */
  78416. normalBias: number;
  78417. private _blurBoxOffset;
  78418. /**
  78419. * Gets the blur box offset: offset applied during the blur pass.
  78420. * Only useful if useKernelBlur = false
  78421. */
  78422. /**
  78423. * Sets the blur box offset: offset applied during the blur pass.
  78424. * Only useful if useKernelBlur = false
  78425. */
  78426. blurBoxOffset: number;
  78427. private _blurScale;
  78428. /**
  78429. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78430. * 2 means half of the size.
  78431. */
  78432. /**
  78433. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78434. * 2 means half of the size.
  78435. */
  78436. blurScale: number;
  78437. private _blurKernel;
  78438. /**
  78439. * Gets the blur kernel: kernel size of the blur pass.
  78440. * Only useful if useKernelBlur = true
  78441. */
  78442. /**
  78443. * Sets the blur kernel: kernel size of the blur pass.
  78444. * Only useful if useKernelBlur = true
  78445. */
  78446. blurKernel: number;
  78447. private _useKernelBlur;
  78448. /**
  78449. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78450. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78451. */
  78452. /**
  78453. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78454. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78455. */
  78456. useKernelBlur: boolean;
  78457. private _depthScale;
  78458. /**
  78459. * Gets the depth scale used in ESM mode.
  78460. */
  78461. /**
  78462. * Sets the depth scale used in ESM mode.
  78463. * This can override the scale stored on the light.
  78464. */
  78465. depthScale: number;
  78466. private _filter;
  78467. /**
  78468. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78469. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78470. */
  78471. /**
  78472. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78473. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78474. */
  78475. filter: number;
  78476. /**
  78477. * Gets if the current filter is set to Poisson Sampling.
  78478. */
  78479. /**
  78480. * Sets the current filter to Poisson Sampling.
  78481. */
  78482. usePoissonSampling: boolean;
  78483. /**
  78484. * Gets if the current filter is set to ESM.
  78485. */
  78486. /**
  78487. * Sets the current filter is to ESM.
  78488. */
  78489. useExponentialShadowMap: boolean;
  78490. /**
  78491. * Gets if the current filter is set to filtered ESM.
  78492. */
  78493. /**
  78494. * Gets if the current filter is set to filtered ESM.
  78495. */
  78496. useBlurExponentialShadowMap: boolean;
  78497. /**
  78498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78499. * exponential to prevent steep falloff artifacts).
  78500. */
  78501. /**
  78502. * Sets the current filter to "close ESM" (using the inverse of the
  78503. * exponential to prevent steep falloff artifacts).
  78504. */
  78505. useCloseExponentialShadowMap: boolean;
  78506. /**
  78507. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78508. * exponential to prevent steep falloff artifacts).
  78509. */
  78510. /**
  78511. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78512. * exponential to prevent steep falloff artifacts).
  78513. */
  78514. useBlurCloseExponentialShadowMap: boolean;
  78515. /**
  78516. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78517. */
  78518. /**
  78519. * Sets the current filter to "PCF" (percentage closer filtering).
  78520. */
  78521. usePercentageCloserFiltering: boolean;
  78522. private _filteringQuality;
  78523. /**
  78524. * Gets the PCF or PCSS Quality.
  78525. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78526. */
  78527. /**
  78528. * Sets the PCF or PCSS Quality.
  78529. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78530. */
  78531. filteringQuality: number;
  78532. /**
  78533. * Gets if the current filter is set to "PCSS" (contact hardening).
  78534. */
  78535. /**
  78536. * Sets the current filter to "PCSS" (contact hardening).
  78537. */
  78538. useContactHardeningShadow: boolean;
  78539. private _contactHardeningLightSizeUVRatio;
  78540. /**
  78541. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78542. * Using a ratio helps keeping shape stability independently of the map size.
  78543. *
  78544. * It does not account for the light projection as it was having too much
  78545. * instability during the light setup or during light position changes.
  78546. *
  78547. * Only valid if useContactHardeningShadow is true.
  78548. */
  78549. /**
  78550. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78551. * Using a ratio helps keeping shape stability independently of the map size.
  78552. *
  78553. * It does not account for the light projection as it was having too much
  78554. * instability during the light setup or during light position changes.
  78555. *
  78556. * Only valid if useContactHardeningShadow is true.
  78557. */
  78558. contactHardeningLightSizeUVRatio: number;
  78559. private _darkness;
  78560. /** Gets or sets the actual darkness of a shadow */
  78561. darkness: number;
  78562. /**
  78563. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78564. * 0 means strongest and 1 would means no shadow.
  78565. * @returns the darkness.
  78566. */
  78567. getDarkness(): number;
  78568. /**
  78569. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78570. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78571. * @returns the shadow generator allowing fluent coding.
  78572. */
  78573. setDarkness(darkness: number): ShadowGenerator;
  78574. private _transparencyShadow;
  78575. /** Gets or sets the ability to have transparent shadow */
  78576. transparencyShadow: boolean;
  78577. /**
  78578. * Sets the ability to have transparent shadow (boolean).
  78579. * @param transparent True if transparent else False
  78580. * @returns the shadow generator allowing fluent coding
  78581. */
  78582. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78583. private _shadowMap;
  78584. private _shadowMap2;
  78585. /**
  78586. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78587. * @returns The render target texture if present otherwise, null
  78588. */
  78589. getShadowMap(): Nullable<RenderTargetTexture>;
  78590. /**
  78591. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78592. * @returns The render target texture if the shadow map is present otherwise, null
  78593. */
  78594. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78595. /**
  78596. * Gets the class name of that object
  78597. * @returns "ShadowGenerator"
  78598. */
  78599. getClassName(): string;
  78600. /**
  78601. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78602. * @param mesh Mesh to add
  78603. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78604. * @returns the Shadow Generator itself
  78605. */
  78606. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78607. /**
  78608. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78609. * @param mesh Mesh to remove
  78610. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78611. * @returns the Shadow Generator itself
  78612. */
  78613. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78614. /**
  78615. * Controls the extent to which the shadows fade out at the edge of the frustum
  78616. * Used only by directionals and spots
  78617. */
  78618. frustumEdgeFalloff: number;
  78619. private _light;
  78620. /**
  78621. * Returns the associated light object.
  78622. * @returns the light generating the shadow
  78623. */
  78624. getLight(): IShadowLight;
  78625. /**
  78626. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78627. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78628. * It might on the other hand introduce peter panning.
  78629. */
  78630. forceBackFacesOnly: boolean;
  78631. private _scene;
  78632. private _lightDirection;
  78633. private _effect;
  78634. private _viewMatrix;
  78635. private _projectionMatrix;
  78636. private _transformMatrix;
  78637. private _cachedPosition;
  78638. private _cachedDirection;
  78639. private _cachedDefines;
  78640. private _currentRenderID;
  78641. private _boxBlurPostprocess;
  78642. private _kernelBlurXPostprocess;
  78643. private _kernelBlurYPostprocess;
  78644. private _blurPostProcesses;
  78645. private _mapSize;
  78646. private _currentFaceIndex;
  78647. private _currentFaceIndexCache;
  78648. private _textureType;
  78649. private _defaultTextureMatrix;
  78650. private _storedUniqueId;
  78651. /** @hidden */
  78652. static _SceneComponentInitialization: (scene: Scene) => void;
  78653. /**
  78654. * Creates a ShadowGenerator object.
  78655. * A ShadowGenerator is the required tool to use the shadows.
  78656. * Each light casting shadows needs to use its own ShadowGenerator.
  78657. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78658. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78659. * @param light The light object generating the shadows.
  78660. * @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.
  78661. */
  78662. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78663. private _initializeGenerator;
  78664. private _initializeShadowMap;
  78665. private _initializeBlurRTTAndPostProcesses;
  78666. private _renderForShadowMap;
  78667. private _renderSubMeshForShadowMap;
  78668. private _applyFilterValues;
  78669. /**
  78670. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78671. * @param onCompiled Callback triggered at the and of the effects compilation
  78672. * @param options Sets of optional options forcing the compilation with different modes
  78673. */
  78674. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78675. useInstances: boolean;
  78676. }>): void;
  78677. /**
  78678. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78679. * @param options Sets of optional options forcing the compilation with different modes
  78680. * @returns A promise that resolves when the compilation completes
  78681. */
  78682. forceCompilationAsync(options?: Partial<{
  78683. useInstances: boolean;
  78684. }>): Promise<void>;
  78685. /**
  78686. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78687. * @param subMesh The submesh we want to render in the shadow map
  78688. * @param useInstances Defines wether will draw in the map using instances
  78689. * @returns true if ready otherwise, false
  78690. */
  78691. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78692. /**
  78693. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78694. * @param defines Defines of the material we want to update
  78695. * @param lightIndex Index of the light in the enabled light list of the material
  78696. */
  78697. prepareDefines(defines: any, lightIndex: number): void;
  78698. /**
  78699. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78700. * defined in the generator but impacting the effect).
  78701. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78702. * @param effect The effect we are binfing the information for
  78703. */
  78704. bindShadowLight(lightIndex: string, effect: Effect): void;
  78705. /**
  78706. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78707. * (eq to shadow prjection matrix * light transform matrix)
  78708. * @returns The transform matrix used to create the shadow map
  78709. */
  78710. getTransformMatrix(): Matrix;
  78711. /**
  78712. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78713. * Cube and 2D textures for instance.
  78714. */
  78715. recreateShadowMap(): void;
  78716. private _disposeBlurPostProcesses;
  78717. private _disposeRTTandPostProcesses;
  78718. /**
  78719. * Disposes the ShadowGenerator.
  78720. * Returns nothing.
  78721. */
  78722. dispose(): void;
  78723. /**
  78724. * Serializes the shadow generator setup to a json object.
  78725. * @returns The serialized JSON object
  78726. */
  78727. serialize(): any;
  78728. /**
  78729. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78730. * @param parsedShadowGenerator The JSON object to parse
  78731. * @param scene The scene to create the shadow map for
  78732. * @returns The parsed shadow generator
  78733. */
  78734. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78735. }
  78736. }
  78737. declare module BABYLON {
  78738. /**
  78739. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78740. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78741. * 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.
  78742. */
  78743. export abstract class Light extends Node {
  78744. /**
  78745. * Falloff Default: light is falling off following the material specification:
  78746. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78747. */
  78748. static readonly FALLOFF_DEFAULT: number;
  78749. /**
  78750. * Falloff Physical: light is falling off following the inverse squared distance law.
  78751. */
  78752. static readonly FALLOFF_PHYSICAL: number;
  78753. /**
  78754. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78755. * to enhance interoperability with other engines.
  78756. */
  78757. static readonly FALLOFF_GLTF: number;
  78758. /**
  78759. * Falloff Standard: light is falling off like in the standard material
  78760. * to enhance interoperability with other materials.
  78761. */
  78762. static readonly FALLOFF_STANDARD: number;
  78763. /**
  78764. * If every light affecting the material is in this lightmapMode,
  78765. * material.lightmapTexture adds or multiplies
  78766. * (depends on material.useLightmapAsShadowmap)
  78767. * after every other light calculations.
  78768. */
  78769. static readonly LIGHTMAP_DEFAULT: number;
  78770. /**
  78771. * material.lightmapTexture as only diffuse lighting from this light
  78772. * adds only specular lighting from this light
  78773. * adds dynamic shadows
  78774. */
  78775. static readonly LIGHTMAP_SPECULAR: number;
  78776. /**
  78777. * material.lightmapTexture as only lighting
  78778. * no light calculation from this light
  78779. * only adds dynamic shadows from this light
  78780. */
  78781. static readonly LIGHTMAP_SHADOWSONLY: number;
  78782. /**
  78783. * Each light type uses the default quantity according to its type:
  78784. * point/spot lights use luminous intensity
  78785. * directional lights use illuminance
  78786. */
  78787. static readonly INTENSITYMODE_AUTOMATIC: number;
  78788. /**
  78789. * lumen (lm)
  78790. */
  78791. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78792. /**
  78793. * candela (lm/sr)
  78794. */
  78795. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78796. /**
  78797. * lux (lm/m^2)
  78798. */
  78799. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78800. /**
  78801. * nit (cd/m^2)
  78802. */
  78803. static readonly INTENSITYMODE_LUMINANCE: number;
  78804. /**
  78805. * Light type const id of the point light.
  78806. */
  78807. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78808. /**
  78809. * Light type const id of the directional light.
  78810. */
  78811. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78812. /**
  78813. * Light type const id of the spot light.
  78814. */
  78815. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78816. /**
  78817. * Light type const id of the hemispheric light.
  78818. */
  78819. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78820. /**
  78821. * Diffuse gives the basic color to an object.
  78822. */
  78823. diffuse: Color3;
  78824. /**
  78825. * Specular produces a highlight color on an object.
  78826. * Note: This is note affecting PBR materials.
  78827. */
  78828. specular: Color3;
  78829. /**
  78830. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78831. * falling off base on range or angle.
  78832. * This can be set to any values in Light.FALLOFF_x.
  78833. *
  78834. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78835. * other types of materials.
  78836. */
  78837. falloffType: number;
  78838. /**
  78839. * Strength of the light.
  78840. * Note: By default it is define in the framework own unit.
  78841. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78842. */
  78843. intensity: number;
  78844. private _range;
  78845. protected _inverseSquaredRange: number;
  78846. /**
  78847. * Defines how far from the source the light is impacting in scene units.
  78848. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78849. */
  78850. /**
  78851. * Defines how far from the source the light is impacting in scene units.
  78852. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78853. */
  78854. range: number;
  78855. /**
  78856. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78857. * of light.
  78858. */
  78859. private _photometricScale;
  78860. private _intensityMode;
  78861. /**
  78862. * Gets the photometric scale used to interpret the intensity.
  78863. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78864. */
  78865. /**
  78866. * Sets the photometric scale used to interpret the intensity.
  78867. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78868. */
  78869. intensityMode: number;
  78870. private _radius;
  78871. /**
  78872. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78873. */
  78874. /**
  78875. * sets the light radius used by PBR Materials to simulate soft area lights.
  78876. */
  78877. radius: number;
  78878. private _renderPriority;
  78879. /**
  78880. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78881. * exceeding the number allowed of the materials.
  78882. */
  78883. renderPriority: number;
  78884. private _shadowEnabled;
  78885. /**
  78886. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78887. * the current shadow generator.
  78888. */
  78889. /**
  78890. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78891. * the current shadow generator.
  78892. */
  78893. shadowEnabled: boolean;
  78894. private _includedOnlyMeshes;
  78895. /**
  78896. * Gets the only meshes impacted by this light.
  78897. */
  78898. /**
  78899. * Sets the only meshes impacted by this light.
  78900. */
  78901. includedOnlyMeshes: AbstractMesh[];
  78902. private _excludedMeshes;
  78903. /**
  78904. * Gets the meshes not impacted by this light.
  78905. */
  78906. /**
  78907. * Sets the meshes not impacted by this light.
  78908. */
  78909. excludedMeshes: AbstractMesh[];
  78910. private _excludeWithLayerMask;
  78911. /**
  78912. * Gets the layer id use to find what meshes are not impacted by the light.
  78913. * Inactive if 0
  78914. */
  78915. /**
  78916. * Sets the layer id use to find what meshes are not impacted by the light.
  78917. * Inactive if 0
  78918. */
  78919. excludeWithLayerMask: number;
  78920. private _includeOnlyWithLayerMask;
  78921. /**
  78922. * Gets the layer id use to find what meshes are impacted by the light.
  78923. * Inactive if 0
  78924. */
  78925. /**
  78926. * Sets the layer id use to find what meshes are impacted by the light.
  78927. * Inactive if 0
  78928. */
  78929. includeOnlyWithLayerMask: number;
  78930. private _lightmapMode;
  78931. /**
  78932. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78933. */
  78934. /**
  78935. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78936. */
  78937. lightmapMode: number;
  78938. /**
  78939. * Shadow generator associted to the light.
  78940. * @hidden Internal use only.
  78941. */
  78942. _shadowGenerator: Nullable<IShadowGenerator>;
  78943. /**
  78944. * @hidden Internal use only.
  78945. */
  78946. _excludedMeshesIds: string[];
  78947. /**
  78948. * @hidden Internal use only.
  78949. */
  78950. _includedOnlyMeshesIds: string[];
  78951. /**
  78952. * The current light unifom buffer.
  78953. * @hidden Internal use only.
  78954. */
  78955. _uniformBuffer: UniformBuffer;
  78956. /** @hidden */
  78957. _renderId: number;
  78958. /**
  78959. * Creates a Light object in the scene.
  78960. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78961. * @param name The firendly name of the light
  78962. * @param scene The scene the light belongs too
  78963. */
  78964. constructor(name: string, scene: Scene);
  78965. protected abstract _buildUniformLayout(): void;
  78966. /**
  78967. * Sets the passed Effect "effect" with the Light information.
  78968. * @param effect The effect to update
  78969. * @param lightIndex The index of the light in the effect to update
  78970. * @returns The light
  78971. */
  78972. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78973. /**
  78974. * Sets the passed Effect "effect" with the Light textures.
  78975. * @param effect The effect to update
  78976. * @param lightIndex The index of the light in the effect to update
  78977. * @returns The light
  78978. */
  78979. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  78980. /**
  78981. * Binds the lights information from the scene to the effect for the given mesh.
  78982. * @param lightIndex Light index
  78983. * @param scene The scene where the light belongs to
  78984. * @param effect The effect we are binding the data to
  78985. * @param useSpecular Defines if specular is supported
  78986. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78987. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78988. */
  78989. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78990. /**
  78991. * Sets the passed Effect "effect" with the Light information.
  78992. * @param effect The effect to update
  78993. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78994. * @returns The light
  78995. */
  78996. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78997. /**
  78998. * Returns the string "Light".
  78999. * @returns the class name
  79000. */
  79001. getClassName(): string;
  79002. /** @hidden */
  79003. readonly _isLight: boolean;
  79004. /**
  79005. * Converts the light information to a readable string for debug purpose.
  79006. * @param fullDetails Supports for multiple levels of logging within scene loading
  79007. * @returns the human readable light info
  79008. */
  79009. toString(fullDetails?: boolean): string;
  79010. /** @hidden */
  79011. protected _syncParentEnabledState(): void;
  79012. /**
  79013. * Set the enabled state of this node.
  79014. * @param value - the new enabled state
  79015. */
  79016. setEnabled(value: boolean): void;
  79017. /**
  79018. * Returns the Light associated shadow generator if any.
  79019. * @return the associated shadow generator.
  79020. */
  79021. getShadowGenerator(): Nullable<IShadowGenerator>;
  79022. /**
  79023. * Returns a Vector3, the absolute light position in the World.
  79024. * @returns the world space position of the light
  79025. */
  79026. getAbsolutePosition(): Vector3;
  79027. /**
  79028. * Specifies if the light will affect the passed mesh.
  79029. * @param mesh The mesh to test against the light
  79030. * @return true the mesh is affected otherwise, false.
  79031. */
  79032. canAffectMesh(mesh: AbstractMesh): boolean;
  79033. /**
  79034. * Sort function to order lights for rendering.
  79035. * @param a First Light object to compare to second.
  79036. * @param b Second Light object to compare first.
  79037. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79038. */
  79039. static CompareLightsPriority(a: Light, b: Light): number;
  79040. /**
  79041. * Releases resources associated with this node.
  79042. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79043. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79044. */
  79045. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79046. /**
  79047. * Returns the light type ID (integer).
  79048. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79049. */
  79050. getTypeID(): number;
  79051. /**
  79052. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79053. * @returns the scaled intensity in intensity mode unit
  79054. */
  79055. getScaledIntensity(): number;
  79056. /**
  79057. * Returns a new Light object, named "name", from the current one.
  79058. * @param name The name of the cloned light
  79059. * @returns the new created light
  79060. */
  79061. clone(name: string): Nullable<Light>;
  79062. /**
  79063. * Serializes the current light into a Serialization object.
  79064. * @returns the serialized object.
  79065. */
  79066. serialize(): any;
  79067. /**
  79068. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79069. * This new light is named "name" and added to the passed scene.
  79070. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79071. * @param name The friendly name of the light
  79072. * @param scene The scene the new light will belong to
  79073. * @returns the constructor function
  79074. */
  79075. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79076. /**
  79077. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79078. * @param parsedLight The JSON representation of the light
  79079. * @param scene The scene to create the parsed light in
  79080. * @returns the created light after parsing
  79081. */
  79082. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79083. private _hookArrayForExcluded;
  79084. private _hookArrayForIncludedOnly;
  79085. private _resyncMeshes;
  79086. /**
  79087. * Forces the meshes to update their light related information in their rendering used effects
  79088. * @hidden Internal Use Only
  79089. */
  79090. _markMeshesAsLightDirty(): void;
  79091. /**
  79092. * Recomputes the cached photometric scale if needed.
  79093. */
  79094. private _computePhotometricScale;
  79095. /**
  79096. * Returns the Photometric Scale according to the light type and intensity mode.
  79097. */
  79098. private _getPhotometricScale;
  79099. /**
  79100. * Reorder the light in the scene according to their defined priority.
  79101. * @hidden Internal Use Only
  79102. */
  79103. _reorderLightsInScene(): void;
  79104. /**
  79105. * Prepares the list of defines specific to the light type.
  79106. * @param defines the list of defines
  79107. * @param lightIndex defines the index of the light for the effect
  79108. */
  79109. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79110. }
  79111. }
  79112. declare module BABYLON {
  79113. /**
  79114. * Interface used to define Action
  79115. */
  79116. export interface IAction {
  79117. /**
  79118. * Trigger for the action
  79119. */
  79120. trigger: number;
  79121. /** Options of the trigger */
  79122. triggerOptions: any;
  79123. /**
  79124. * Gets the trigger parameters
  79125. * @returns the trigger parameters
  79126. */
  79127. getTriggerParameter(): any;
  79128. /**
  79129. * Internal only - executes current action event
  79130. * @hidden
  79131. */
  79132. _executeCurrent(evt?: ActionEvent): void;
  79133. /**
  79134. * Serialize placeholder for child classes
  79135. * @param parent of child
  79136. * @returns the serialized object
  79137. */
  79138. serialize(parent: any): any;
  79139. /**
  79140. * Internal only
  79141. * @hidden
  79142. */
  79143. _prepare(): void;
  79144. /**
  79145. * Internal only - manager for action
  79146. * @hidden
  79147. */
  79148. _actionManager: AbstractActionManager;
  79149. /**
  79150. * Adds action to chain of actions, may be a DoNothingAction
  79151. * @param action defines the next action to execute
  79152. * @returns The action passed in
  79153. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79154. */
  79155. then(action: IAction): IAction;
  79156. }
  79157. /**
  79158. * The action to be carried out following a trigger
  79159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79160. */
  79161. export class Action implements IAction {
  79162. /** the trigger, with or without parameters, for the action */
  79163. triggerOptions: any;
  79164. /**
  79165. * Trigger for the action
  79166. */
  79167. trigger: number;
  79168. /**
  79169. * Internal only - manager for action
  79170. * @hidden
  79171. */
  79172. _actionManager: ActionManager;
  79173. private _nextActiveAction;
  79174. private _child;
  79175. private _condition?;
  79176. private _triggerParameter;
  79177. /**
  79178. * An event triggered prior to action being executed.
  79179. */
  79180. onBeforeExecuteObservable: Observable<Action>;
  79181. /**
  79182. * Creates a new Action
  79183. * @param triggerOptions the trigger, with or without parameters, for the action
  79184. * @param condition an optional determinant of action
  79185. */
  79186. constructor(
  79187. /** the trigger, with or without parameters, for the action */
  79188. triggerOptions: any, condition?: Condition);
  79189. /**
  79190. * Internal only
  79191. * @hidden
  79192. */
  79193. _prepare(): void;
  79194. /**
  79195. * Gets the trigger parameters
  79196. * @returns the trigger parameters
  79197. */
  79198. getTriggerParameter(): any;
  79199. /**
  79200. * Internal only - executes current action event
  79201. * @hidden
  79202. */
  79203. _executeCurrent(evt?: ActionEvent): void;
  79204. /**
  79205. * Execute placeholder for child classes
  79206. * @param evt optional action event
  79207. */
  79208. execute(evt?: ActionEvent): void;
  79209. /**
  79210. * Skips to next active action
  79211. */
  79212. skipToNextActiveAction(): void;
  79213. /**
  79214. * Adds action to chain of actions, may be a DoNothingAction
  79215. * @param action defines the next action to execute
  79216. * @returns The action passed in
  79217. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79218. */
  79219. then(action: Action): Action;
  79220. /**
  79221. * Internal only
  79222. * @hidden
  79223. */
  79224. _getProperty(propertyPath: string): string;
  79225. /**
  79226. * Internal only
  79227. * @hidden
  79228. */
  79229. _getEffectiveTarget(target: any, propertyPath: string): any;
  79230. /**
  79231. * Serialize placeholder for child classes
  79232. * @param parent of child
  79233. * @returns the serialized object
  79234. */
  79235. serialize(parent: any): any;
  79236. /**
  79237. * Internal only called by serialize
  79238. * @hidden
  79239. */
  79240. protected _serialize(serializedAction: any, parent?: any): any;
  79241. /**
  79242. * Internal only
  79243. * @hidden
  79244. */
  79245. static _SerializeValueAsString: (value: any) => string;
  79246. /**
  79247. * Internal only
  79248. * @hidden
  79249. */
  79250. static _GetTargetProperty: (target: Node | Scene) => {
  79251. name: string;
  79252. targetType: string;
  79253. value: string;
  79254. };
  79255. }
  79256. }
  79257. declare module BABYLON {
  79258. /**
  79259. * A Condition applied to an Action
  79260. */
  79261. export class Condition {
  79262. /**
  79263. * Internal only - manager for action
  79264. * @hidden
  79265. */
  79266. _actionManager: ActionManager;
  79267. /**
  79268. * Internal only
  79269. * @hidden
  79270. */
  79271. _evaluationId: number;
  79272. /**
  79273. * Internal only
  79274. * @hidden
  79275. */
  79276. _currentResult: boolean;
  79277. /**
  79278. * Creates a new Condition
  79279. * @param actionManager the manager of the action the condition is applied to
  79280. */
  79281. constructor(actionManager: ActionManager);
  79282. /**
  79283. * Check if the current condition is valid
  79284. * @returns a boolean
  79285. */
  79286. isValid(): boolean;
  79287. /**
  79288. * Internal only
  79289. * @hidden
  79290. */
  79291. _getProperty(propertyPath: string): string;
  79292. /**
  79293. * Internal only
  79294. * @hidden
  79295. */
  79296. _getEffectiveTarget(target: any, propertyPath: string): any;
  79297. /**
  79298. * Serialize placeholder for child classes
  79299. * @returns the serialized object
  79300. */
  79301. serialize(): any;
  79302. /**
  79303. * Internal only
  79304. * @hidden
  79305. */
  79306. protected _serialize(serializedCondition: any): any;
  79307. }
  79308. /**
  79309. * Defines specific conditional operators as extensions of Condition
  79310. */
  79311. export class ValueCondition extends Condition {
  79312. /** path to specify the property of the target the conditional operator uses */
  79313. propertyPath: string;
  79314. /** the value compared by the conditional operator against the current value of the property */
  79315. value: any;
  79316. /** the conditional operator, default ValueCondition.IsEqual */
  79317. operator: number;
  79318. /**
  79319. * Internal only
  79320. * @hidden
  79321. */
  79322. private static _IsEqual;
  79323. /**
  79324. * Internal only
  79325. * @hidden
  79326. */
  79327. private static _IsDifferent;
  79328. /**
  79329. * Internal only
  79330. * @hidden
  79331. */
  79332. private static _IsGreater;
  79333. /**
  79334. * Internal only
  79335. * @hidden
  79336. */
  79337. private static _IsLesser;
  79338. /**
  79339. * returns the number for IsEqual
  79340. */
  79341. static readonly IsEqual: number;
  79342. /**
  79343. * Returns the number for IsDifferent
  79344. */
  79345. static readonly IsDifferent: number;
  79346. /**
  79347. * Returns the number for IsGreater
  79348. */
  79349. static readonly IsGreater: number;
  79350. /**
  79351. * Returns the number for IsLesser
  79352. */
  79353. static readonly IsLesser: number;
  79354. /**
  79355. * Internal only The action manager for the condition
  79356. * @hidden
  79357. */
  79358. _actionManager: ActionManager;
  79359. /**
  79360. * Internal only
  79361. * @hidden
  79362. */
  79363. private _target;
  79364. /**
  79365. * Internal only
  79366. * @hidden
  79367. */
  79368. private _effectiveTarget;
  79369. /**
  79370. * Internal only
  79371. * @hidden
  79372. */
  79373. private _property;
  79374. /**
  79375. * Creates a new ValueCondition
  79376. * @param actionManager manager for the action the condition applies to
  79377. * @param target for the action
  79378. * @param propertyPath path to specify the property of the target the conditional operator uses
  79379. * @param value the value compared by the conditional operator against the current value of the property
  79380. * @param operator the conditional operator, default ValueCondition.IsEqual
  79381. */
  79382. constructor(actionManager: ActionManager, target: any,
  79383. /** path to specify the property of the target the conditional operator uses */
  79384. propertyPath: string,
  79385. /** the value compared by the conditional operator against the current value of the property */
  79386. value: any,
  79387. /** the conditional operator, default ValueCondition.IsEqual */
  79388. operator?: number);
  79389. /**
  79390. * Compares the given value with the property value for the specified conditional operator
  79391. * @returns the result of the comparison
  79392. */
  79393. isValid(): boolean;
  79394. /**
  79395. * Serialize the ValueCondition into a JSON compatible object
  79396. * @returns serialization object
  79397. */
  79398. serialize(): any;
  79399. /**
  79400. * Gets the name of the conditional operator for the ValueCondition
  79401. * @param operator the conditional operator
  79402. * @returns the name
  79403. */
  79404. static GetOperatorName(operator: number): string;
  79405. }
  79406. /**
  79407. * Defines a predicate condition as an extension of Condition
  79408. */
  79409. export class PredicateCondition extends Condition {
  79410. /** defines the predicate function used to validate the condition */
  79411. predicate: () => boolean;
  79412. /**
  79413. * Internal only - manager for action
  79414. * @hidden
  79415. */
  79416. _actionManager: ActionManager;
  79417. /**
  79418. * Creates a new PredicateCondition
  79419. * @param actionManager manager for the action the condition applies to
  79420. * @param predicate defines the predicate function used to validate the condition
  79421. */
  79422. constructor(actionManager: ActionManager,
  79423. /** defines the predicate function used to validate the condition */
  79424. predicate: () => boolean);
  79425. /**
  79426. * @returns the validity of the predicate condition
  79427. */
  79428. isValid(): boolean;
  79429. }
  79430. /**
  79431. * Defines a state condition as an extension of Condition
  79432. */
  79433. export class StateCondition extends Condition {
  79434. /** Value to compare with target state */
  79435. value: string;
  79436. /**
  79437. * Internal only - manager for action
  79438. * @hidden
  79439. */
  79440. _actionManager: ActionManager;
  79441. /**
  79442. * Internal only
  79443. * @hidden
  79444. */
  79445. private _target;
  79446. /**
  79447. * Creates a new StateCondition
  79448. * @param actionManager manager for the action the condition applies to
  79449. * @param target of the condition
  79450. * @param value to compare with target state
  79451. */
  79452. constructor(actionManager: ActionManager, target: any,
  79453. /** Value to compare with target state */
  79454. value: string);
  79455. /**
  79456. * Gets a boolean indicating if the current condition is met
  79457. * @returns the validity of the state
  79458. */
  79459. isValid(): boolean;
  79460. /**
  79461. * Serialize the StateCondition into a JSON compatible object
  79462. * @returns serialization object
  79463. */
  79464. serialize(): any;
  79465. }
  79466. }
  79467. declare module BABYLON {
  79468. /**
  79469. * This defines an action responsible to toggle a boolean once triggered.
  79470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79471. */
  79472. export class SwitchBooleanAction extends Action {
  79473. /**
  79474. * The path to the boolean property in the target object
  79475. */
  79476. propertyPath: string;
  79477. private _target;
  79478. private _effectiveTarget;
  79479. private _property;
  79480. /**
  79481. * Instantiate the action
  79482. * @param triggerOptions defines the trigger options
  79483. * @param target defines the object containing the boolean
  79484. * @param propertyPath defines the path to the boolean property in the target object
  79485. * @param condition defines the trigger related conditions
  79486. */
  79487. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79488. /** @hidden */
  79489. _prepare(): void;
  79490. /**
  79491. * Execute the action toggle the boolean value.
  79492. */
  79493. execute(): void;
  79494. /**
  79495. * Serializes the actions and its related information.
  79496. * @param parent defines the object to serialize in
  79497. * @returns the serialized object
  79498. */
  79499. serialize(parent: any): any;
  79500. }
  79501. /**
  79502. * This defines an action responsible to set a the state field of the target
  79503. * to a desired value once triggered.
  79504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79505. */
  79506. export class SetStateAction extends Action {
  79507. /**
  79508. * The value to store in the state field.
  79509. */
  79510. value: string;
  79511. private _target;
  79512. /**
  79513. * Instantiate the action
  79514. * @param triggerOptions defines the trigger options
  79515. * @param target defines the object containing the state property
  79516. * @param value defines the value to store in the state field
  79517. * @param condition defines the trigger related conditions
  79518. */
  79519. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79520. /**
  79521. * Execute the action and store the value on the target state property.
  79522. */
  79523. execute(): void;
  79524. /**
  79525. * Serializes the actions and its related information.
  79526. * @param parent defines the object to serialize in
  79527. * @returns the serialized object
  79528. */
  79529. serialize(parent: any): any;
  79530. }
  79531. /**
  79532. * This defines an action responsible to set a property of the target
  79533. * to a desired value once triggered.
  79534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79535. */
  79536. export class SetValueAction extends Action {
  79537. /**
  79538. * The path of the property to set in the target.
  79539. */
  79540. propertyPath: string;
  79541. /**
  79542. * The value to set in the property
  79543. */
  79544. value: any;
  79545. private _target;
  79546. private _effectiveTarget;
  79547. private _property;
  79548. /**
  79549. * Instantiate the action
  79550. * @param triggerOptions defines the trigger options
  79551. * @param target defines the object containing the property
  79552. * @param propertyPath defines the path of the property to set in the target
  79553. * @param value defines the value to set in the property
  79554. * @param condition defines the trigger related conditions
  79555. */
  79556. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79557. /** @hidden */
  79558. _prepare(): void;
  79559. /**
  79560. * Execute the action and set the targetted property to the desired value.
  79561. */
  79562. execute(): void;
  79563. /**
  79564. * Serializes the actions and its related information.
  79565. * @param parent defines the object to serialize in
  79566. * @returns the serialized object
  79567. */
  79568. serialize(parent: any): any;
  79569. }
  79570. /**
  79571. * This defines an action responsible to increment the target value
  79572. * to a desired value once triggered.
  79573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79574. */
  79575. export class IncrementValueAction extends Action {
  79576. /**
  79577. * The path of the property to increment in the target.
  79578. */
  79579. propertyPath: string;
  79580. /**
  79581. * The value we should increment the property by.
  79582. */
  79583. value: any;
  79584. private _target;
  79585. private _effectiveTarget;
  79586. private _property;
  79587. /**
  79588. * Instantiate the action
  79589. * @param triggerOptions defines the trigger options
  79590. * @param target defines the object containing the property
  79591. * @param propertyPath defines the path of the property to increment in the target
  79592. * @param value defines the value value we should increment the property by
  79593. * @param condition defines the trigger related conditions
  79594. */
  79595. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79596. /** @hidden */
  79597. _prepare(): void;
  79598. /**
  79599. * Execute the action and increment the target of the value amount.
  79600. */
  79601. execute(): void;
  79602. /**
  79603. * Serializes the actions and its related information.
  79604. * @param parent defines the object to serialize in
  79605. * @returns the serialized object
  79606. */
  79607. serialize(parent: any): any;
  79608. }
  79609. /**
  79610. * This defines an action responsible to start an animation once triggered.
  79611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79612. */
  79613. export class PlayAnimationAction extends Action {
  79614. /**
  79615. * Where the animation should start (animation frame)
  79616. */
  79617. from: number;
  79618. /**
  79619. * Where the animation should stop (animation frame)
  79620. */
  79621. to: number;
  79622. /**
  79623. * Define if the animation should loop or stop after the first play.
  79624. */
  79625. loop?: boolean;
  79626. private _target;
  79627. /**
  79628. * Instantiate the action
  79629. * @param triggerOptions defines the trigger options
  79630. * @param target defines the target animation or animation name
  79631. * @param from defines from where the animation should start (animation frame)
  79632. * @param end defines where the animation should stop (animation frame)
  79633. * @param loop defines if the animation should loop or stop after the first play
  79634. * @param condition defines the trigger related conditions
  79635. */
  79636. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79637. /** @hidden */
  79638. _prepare(): void;
  79639. /**
  79640. * Execute the action and play the animation.
  79641. */
  79642. execute(): void;
  79643. /**
  79644. * Serializes the actions and its related information.
  79645. * @param parent defines the object to serialize in
  79646. * @returns the serialized object
  79647. */
  79648. serialize(parent: any): any;
  79649. }
  79650. /**
  79651. * This defines an action responsible to stop an animation once triggered.
  79652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79653. */
  79654. export class StopAnimationAction extends Action {
  79655. private _target;
  79656. /**
  79657. * Instantiate the action
  79658. * @param triggerOptions defines the trigger options
  79659. * @param target defines the target animation or animation name
  79660. * @param condition defines the trigger related conditions
  79661. */
  79662. constructor(triggerOptions: any, target: any, condition?: Condition);
  79663. /** @hidden */
  79664. _prepare(): void;
  79665. /**
  79666. * Execute the action and stop the animation.
  79667. */
  79668. execute(): void;
  79669. /**
  79670. * Serializes the actions and its related information.
  79671. * @param parent defines the object to serialize in
  79672. * @returns the serialized object
  79673. */
  79674. serialize(parent: any): any;
  79675. }
  79676. /**
  79677. * This defines an action responsible that does nothing once triggered.
  79678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79679. */
  79680. export class DoNothingAction extends Action {
  79681. /**
  79682. * Instantiate the action
  79683. * @param triggerOptions defines the trigger options
  79684. * @param condition defines the trigger related conditions
  79685. */
  79686. constructor(triggerOptions?: any, condition?: Condition);
  79687. /**
  79688. * Execute the action and do nothing.
  79689. */
  79690. execute(): void;
  79691. /**
  79692. * Serializes the actions and its related information.
  79693. * @param parent defines the object to serialize in
  79694. * @returns the serialized object
  79695. */
  79696. serialize(parent: any): any;
  79697. }
  79698. /**
  79699. * This defines an action responsible to trigger several actions once triggered.
  79700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79701. */
  79702. export class CombineAction extends Action {
  79703. /**
  79704. * The list of aggregated animations to run.
  79705. */
  79706. children: Action[];
  79707. /**
  79708. * Instantiate the action
  79709. * @param triggerOptions defines the trigger options
  79710. * @param children defines the list of aggregated animations to run
  79711. * @param condition defines the trigger related conditions
  79712. */
  79713. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79714. /** @hidden */
  79715. _prepare(): void;
  79716. /**
  79717. * Execute the action and executes all the aggregated actions.
  79718. */
  79719. execute(evt: ActionEvent): void;
  79720. /**
  79721. * Serializes the actions and its related information.
  79722. * @param parent defines the object to serialize in
  79723. * @returns the serialized object
  79724. */
  79725. serialize(parent: any): any;
  79726. }
  79727. /**
  79728. * This defines an action responsible to run code (external event) once triggered.
  79729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79730. */
  79731. export class ExecuteCodeAction extends Action {
  79732. /**
  79733. * The callback function to run.
  79734. */
  79735. func: (evt: ActionEvent) => void;
  79736. /**
  79737. * Instantiate the action
  79738. * @param triggerOptions defines the trigger options
  79739. * @param func defines the callback function to run
  79740. * @param condition defines the trigger related conditions
  79741. */
  79742. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79743. /**
  79744. * Execute the action and run the attached code.
  79745. */
  79746. execute(evt: ActionEvent): void;
  79747. }
  79748. /**
  79749. * This defines an action responsible to set the parent property of the target once triggered.
  79750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79751. */
  79752. export class SetParentAction extends Action {
  79753. private _parent;
  79754. private _target;
  79755. /**
  79756. * Instantiate the action
  79757. * @param triggerOptions defines the trigger options
  79758. * @param target defines the target containing the parent property
  79759. * @param parent defines from where the animation should start (animation frame)
  79760. * @param condition defines the trigger related conditions
  79761. */
  79762. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79763. /** @hidden */
  79764. _prepare(): void;
  79765. /**
  79766. * Execute the action and set the parent property.
  79767. */
  79768. execute(): void;
  79769. /**
  79770. * Serializes the actions and its related information.
  79771. * @param parent defines the object to serialize in
  79772. * @returns the serialized object
  79773. */
  79774. serialize(parent: any): any;
  79775. }
  79776. }
  79777. declare module BABYLON {
  79778. /**
  79779. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79780. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79782. */
  79783. export class ActionManager extends AbstractActionManager {
  79784. /**
  79785. * Nothing
  79786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79787. */
  79788. static readonly NothingTrigger: number;
  79789. /**
  79790. * On pick
  79791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79792. */
  79793. static readonly OnPickTrigger: number;
  79794. /**
  79795. * On left pick
  79796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79797. */
  79798. static readonly OnLeftPickTrigger: number;
  79799. /**
  79800. * On right pick
  79801. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79802. */
  79803. static readonly OnRightPickTrigger: number;
  79804. /**
  79805. * On center pick
  79806. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79807. */
  79808. static readonly OnCenterPickTrigger: number;
  79809. /**
  79810. * On pick down
  79811. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79812. */
  79813. static readonly OnPickDownTrigger: number;
  79814. /**
  79815. * On double pick
  79816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79817. */
  79818. static readonly OnDoublePickTrigger: number;
  79819. /**
  79820. * On pick up
  79821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79822. */
  79823. static readonly OnPickUpTrigger: number;
  79824. /**
  79825. * On pick out.
  79826. * This trigger will only be raised if you also declared a OnPickDown
  79827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79828. */
  79829. static readonly OnPickOutTrigger: number;
  79830. /**
  79831. * On long press
  79832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79833. */
  79834. static readonly OnLongPressTrigger: number;
  79835. /**
  79836. * On pointer over
  79837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79838. */
  79839. static readonly OnPointerOverTrigger: number;
  79840. /**
  79841. * On pointer out
  79842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79843. */
  79844. static readonly OnPointerOutTrigger: number;
  79845. /**
  79846. * On every frame
  79847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79848. */
  79849. static readonly OnEveryFrameTrigger: number;
  79850. /**
  79851. * On intersection enter
  79852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79853. */
  79854. static readonly OnIntersectionEnterTrigger: number;
  79855. /**
  79856. * On intersection exit
  79857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79858. */
  79859. static readonly OnIntersectionExitTrigger: number;
  79860. /**
  79861. * On key down
  79862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79863. */
  79864. static readonly OnKeyDownTrigger: number;
  79865. /**
  79866. * On key up
  79867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79868. */
  79869. static readonly OnKeyUpTrigger: number;
  79870. private _scene;
  79871. /**
  79872. * Creates a new action manager
  79873. * @param scene defines the hosting scene
  79874. */
  79875. constructor(scene: Scene);
  79876. /**
  79877. * Releases all associated resources
  79878. */
  79879. dispose(): void;
  79880. /**
  79881. * Gets hosting scene
  79882. * @returns the hosting scene
  79883. */
  79884. getScene(): Scene;
  79885. /**
  79886. * Does this action manager handles actions of any of the given triggers
  79887. * @param triggers defines the triggers to be tested
  79888. * @return a boolean indicating whether one (or more) of the triggers is handled
  79889. */
  79890. hasSpecificTriggers(triggers: number[]): boolean;
  79891. /**
  79892. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79893. * speed.
  79894. * @param triggerA defines the trigger to be tested
  79895. * @param triggerB defines the trigger to be tested
  79896. * @return a boolean indicating whether one (or more) of the triggers is handled
  79897. */
  79898. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79899. /**
  79900. * Does this action manager handles actions of a given trigger
  79901. * @param trigger defines the trigger to be tested
  79902. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79903. * @return whether the trigger is handled
  79904. */
  79905. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79906. /**
  79907. * Does this action manager has pointer triggers
  79908. */
  79909. readonly hasPointerTriggers: boolean;
  79910. /**
  79911. * Does this action manager has pick triggers
  79912. */
  79913. readonly hasPickTriggers: boolean;
  79914. /**
  79915. * Registers an action to this action manager
  79916. * @param action defines the action to be registered
  79917. * @return the action amended (prepared) after registration
  79918. */
  79919. registerAction(action: IAction): Nullable<IAction>;
  79920. /**
  79921. * Unregisters an action to this action manager
  79922. * @param action defines the action to be unregistered
  79923. * @return a boolean indicating whether the action has been unregistered
  79924. */
  79925. unregisterAction(action: IAction): Boolean;
  79926. /**
  79927. * Process a specific trigger
  79928. * @param trigger defines the trigger to process
  79929. * @param evt defines the event details to be processed
  79930. */
  79931. processTrigger(trigger: number, evt?: IActionEvent): void;
  79932. /** @hidden */
  79933. _getEffectiveTarget(target: any, propertyPath: string): any;
  79934. /** @hidden */
  79935. _getProperty(propertyPath: string): string;
  79936. /**
  79937. * Serialize this manager to a JSON object
  79938. * @param name defines the property name to store this manager
  79939. * @returns a JSON representation of this manager
  79940. */
  79941. serialize(name: string): any;
  79942. /**
  79943. * Creates a new ActionManager from a JSON data
  79944. * @param parsedActions defines the JSON data to read from
  79945. * @param object defines the hosting mesh
  79946. * @param scene defines the hosting scene
  79947. */
  79948. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79949. /**
  79950. * Get a trigger name by index
  79951. * @param trigger defines the trigger index
  79952. * @returns a trigger name
  79953. */
  79954. static GetTriggerName(trigger: number): string;
  79955. }
  79956. }
  79957. declare module BABYLON {
  79958. /**
  79959. * Class representing a ray with position and direction
  79960. */
  79961. export class Ray {
  79962. /** origin point */
  79963. origin: Vector3;
  79964. /** direction */
  79965. direction: Vector3;
  79966. /** length of the ray */
  79967. length: number;
  79968. private static readonly TmpVector3;
  79969. private _tmpRay;
  79970. /**
  79971. * Creates a new ray
  79972. * @param origin origin point
  79973. * @param direction direction
  79974. * @param length length of the ray
  79975. */
  79976. constructor(
  79977. /** origin point */
  79978. origin: Vector3,
  79979. /** direction */
  79980. direction: Vector3,
  79981. /** length of the ray */
  79982. length?: number);
  79983. /**
  79984. * Checks if the ray intersects a box
  79985. * @param minimum bound of the box
  79986. * @param maximum bound of the box
  79987. * @param intersectionTreshold extra extend to be added to the box in all direction
  79988. * @returns if the box was hit
  79989. */
  79990. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79991. /**
  79992. * Checks if the ray intersects a box
  79993. * @param box the bounding box to check
  79994. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79995. * @returns if the box was hit
  79996. */
  79997. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79998. /**
  79999. * If the ray hits a sphere
  80000. * @param sphere the bounding sphere to check
  80001. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80002. * @returns true if it hits the sphere
  80003. */
  80004. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80005. /**
  80006. * If the ray hits a triange
  80007. * @param vertex0 triangle vertex
  80008. * @param vertex1 triangle vertex
  80009. * @param vertex2 triangle vertex
  80010. * @returns intersection information if hit
  80011. */
  80012. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80013. /**
  80014. * Checks if ray intersects a plane
  80015. * @param plane the plane to check
  80016. * @returns the distance away it was hit
  80017. */
  80018. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80019. /**
  80020. * Calculate the intercept of a ray on a given axis
  80021. * @param axis to check 'x' | 'y' | 'z'
  80022. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80023. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80024. */
  80025. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80026. /**
  80027. * Checks if ray intersects a mesh
  80028. * @param mesh the mesh to check
  80029. * @param fastCheck if only the bounding box should checked
  80030. * @returns picking info of the intersecton
  80031. */
  80032. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80033. /**
  80034. * Checks if ray intersects a mesh
  80035. * @param meshes the meshes to check
  80036. * @param fastCheck if only the bounding box should checked
  80037. * @param results array to store result in
  80038. * @returns Array of picking infos
  80039. */
  80040. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80041. private _comparePickingInfo;
  80042. private static smallnum;
  80043. private static rayl;
  80044. /**
  80045. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80046. * @param sega the first point of the segment to test the intersection against
  80047. * @param segb the second point of the segment to test the intersection against
  80048. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80049. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80050. */
  80051. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80052. /**
  80053. * Update the ray from viewport position
  80054. * @param x position
  80055. * @param y y position
  80056. * @param viewportWidth viewport width
  80057. * @param viewportHeight viewport height
  80058. * @param world world matrix
  80059. * @param view view matrix
  80060. * @param projection projection matrix
  80061. * @returns this ray updated
  80062. */
  80063. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80064. /**
  80065. * Creates a ray with origin and direction of 0,0,0
  80066. * @returns the new ray
  80067. */
  80068. static Zero(): Ray;
  80069. /**
  80070. * Creates a new ray from screen space and viewport
  80071. * @param x position
  80072. * @param y y position
  80073. * @param viewportWidth viewport width
  80074. * @param viewportHeight viewport height
  80075. * @param world world matrix
  80076. * @param view view matrix
  80077. * @param projection projection matrix
  80078. * @returns new ray
  80079. */
  80080. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80081. /**
  80082. * 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
  80083. * transformed to the given world matrix.
  80084. * @param origin The origin point
  80085. * @param end The end point
  80086. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80087. * @returns the new ray
  80088. */
  80089. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80090. /**
  80091. * Transforms a ray by a matrix
  80092. * @param ray ray to transform
  80093. * @param matrix matrix to apply
  80094. * @returns the resulting new ray
  80095. */
  80096. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80097. /**
  80098. * Transforms a ray by a matrix
  80099. * @param ray ray to transform
  80100. * @param matrix matrix to apply
  80101. * @param result ray to store result in
  80102. */
  80103. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80104. /**
  80105. * Unproject a ray from screen space to object space
  80106. * @param sourceX defines the screen space x coordinate to use
  80107. * @param sourceY defines the screen space y coordinate to use
  80108. * @param viewportWidth defines the current width of the viewport
  80109. * @param viewportHeight defines the current height of the viewport
  80110. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80111. * @param view defines the view matrix to use
  80112. * @param projection defines the projection matrix to use
  80113. */
  80114. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80115. }
  80116. /**
  80117. * Type used to define predicate used to select faces when a mesh intersection is detected
  80118. */
  80119. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80120. interface Scene {
  80121. /** @hidden */
  80122. _tempPickingRay: Nullable<Ray>;
  80123. /** @hidden */
  80124. _cachedRayForTransform: Ray;
  80125. /** @hidden */
  80126. _pickWithRayInverseMatrix: Matrix;
  80127. /** @hidden */
  80128. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80129. /** @hidden */
  80130. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80131. }
  80132. }
  80133. declare module BABYLON {
  80134. /**
  80135. * Groups all the scene component constants in one place to ease maintenance.
  80136. * @hidden
  80137. */
  80138. export class SceneComponentConstants {
  80139. static readonly NAME_EFFECTLAYER: string;
  80140. static readonly NAME_LAYER: string;
  80141. static readonly NAME_LENSFLARESYSTEM: string;
  80142. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80143. static readonly NAME_PARTICLESYSTEM: string;
  80144. static readonly NAME_GAMEPAD: string;
  80145. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80146. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80147. static readonly NAME_DEPTHRENDERER: string;
  80148. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80149. static readonly NAME_SPRITE: string;
  80150. static readonly NAME_OUTLINERENDERER: string;
  80151. static readonly NAME_PROCEDURALTEXTURE: string;
  80152. static readonly NAME_SHADOWGENERATOR: string;
  80153. static readonly NAME_OCTREE: string;
  80154. static readonly NAME_PHYSICSENGINE: string;
  80155. static readonly NAME_AUDIO: string;
  80156. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80157. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80158. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80159. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80160. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80161. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80162. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80163. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80164. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80165. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80166. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80167. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80168. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80169. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80170. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80171. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80172. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80173. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80174. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80175. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80176. static readonly STEP_AFTERRENDER_AUDIO: number;
  80177. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80178. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80179. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80180. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80181. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80182. static readonly STEP_POINTERMOVE_SPRITE: number;
  80183. static readonly STEP_POINTERDOWN_SPRITE: number;
  80184. static readonly STEP_POINTERUP_SPRITE: number;
  80185. }
  80186. /**
  80187. * This represents a scene component.
  80188. *
  80189. * This is used to decouple the dependency the scene is having on the different workloads like
  80190. * layers, post processes...
  80191. */
  80192. export interface ISceneComponent {
  80193. /**
  80194. * The name of the component. Each component must have a unique name.
  80195. */
  80196. name: string;
  80197. /**
  80198. * The scene the component belongs to.
  80199. */
  80200. scene: Scene;
  80201. /**
  80202. * Register the component to one instance of a scene.
  80203. */
  80204. register(): void;
  80205. /**
  80206. * Rebuilds the elements related to this component in case of
  80207. * context lost for instance.
  80208. */
  80209. rebuild(): void;
  80210. /**
  80211. * Disposes the component and the associated ressources.
  80212. */
  80213. dispose(): void;
  80214. }
  80215. /**
  80216. * This represents a SERIALIZABLE scene component.
  80217. *
  80218. * This extends Scene Component to add Serialization methods on top.
  80219. */
  80220. export interface ISceneSerializableComponent extends ISceneComponent {
  80221. /**
  80222. * Adds all the elements from the container to the scene
  80223. * @param container the container holding the elements
  80224. */
  80225. addFromContainer(container: AbstractScene): void;
  80226. /**
  80227. * Removes all the elements in the container from the scene
  80228. * @param container contains the elements to remove
  80229. * @param dispose if the removed element should be disposed (default: false)
  80230. */
  80231. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80232. /**
  80233. * Serializes the component data to the specified json object
  80234. * @param serializationObject The object to serialize to
  80235. */
  80236. serialize(serializationObject: any): void;
  80237. }
  80238. /**
  80239. * Strong typing of a Mesh related stage step action
  80240. */
  80241. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80242. /**
  80243. * Strong typing of a Evaluate Sub Mesh related stage step action
  80244. */
  80245. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80246. /**
  80247. * Strong typing of a Active Mesh related stage step action
  80248. */
  80249. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80250. /**
  80251. * Strong typing of a Camera related stage step action
  80252. */
  80253. export type CameraStageAction = (camera: Camera) => void;
  80254. /**
  80255. * Strong typing of a Camera Frame buffer related stage step action
  80256. */
  80257. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80258. /**
  80259. * Strong typing of a Render Target related stage step action
  80260. */
  80261. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80262. /**
  80263. * Strong typing of a RenderingGroup related stage step action
  80264. */
  80265. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80266. /**
  80267. * Strong typing of a Mesh Render related stage step action
  80268. */
  80269. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80270. /**
  80271. * Strong typing of a simple stage step action
  80272. */
  80273. export type SimpleStageAction = () => void;
  80274. /**
  80275. * Strong typing of a render target action.
  80276. */
  80277. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80278. /**
  80279. * Strong typing of a pointer move action.
  80280. */
  80281. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80282. /**
  80283. * Strong typing of a pointer up/down action.
  80284. */
  80285. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80286. /**
  80287. * Representation of a stage in the scene (Basically a list of ordered steps)
  80288. * @hidden
  80289. */
  80290. export class Stage<T extends Function> extends Array<{
  80291. index: number;
  80292. component: ISceneComponent;
  80293. action: T;
  80294. }> {
  80295. /**
  80296. * Hide ctor from the rest of the world.
  80297. * @param items The items to add.
  80298. */
  80299. private constructor();
  80300. /**
  80301. * Creates a new Stage.
  80302. * @returns A new instance of a Stage
  80303. */
  80304. static Create<T extends Function>(): Stage<T>;
  80305. /**
  80306. * Registers a step in an ordered way in the targeted stage.
  80307. * @param index Defines the position to register the step in
  80308. * @param component Defines the component attached to the step
  80309. * @param action Defines the action to launch during the step
  80310. */
  80311. registerStep(index: number, component: ISceneComponent, action: T): void;
  80312. /**
  80313. * Clears all the steps from the stage.
  80314. */
  80315. clear(): void;
  80316. }
  80317. }
  80318. declare module BABYLON {
  80319. interface Scene {
  80320. /** @hidden */
  80321. _pointerOverSprite: Nullable<Sprite>;
  80322. /** @hidden */
  80323. _pickedDownSprite: Nullable<Sprite>;
  80324. /** @hidden */
  80325. _tempSpritePickingRay: Nullable<Ray>;
  80326. /**
  80327. * All of the sprite managers added to this scene
  80328. * @see http://doc.babylonjs.com/babylon101/sprites
  80329. */
  80330. spriteManagers: Array<ISpriteManager>;
  80331. /**
  80332. * An event triggered when sprites rendering is about to start
  80333. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80334. */
  80335. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80336. /**
  80337. * An event triggered when sprites rendering is done
  80338. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80339. */
  80340. onAfterSpritesRenderingObservable: Observable<Scene>;
  80341. /** @hidden */
  80342. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80343. /** Launch a ray to try to pick a sprite in the scene
  80344. * @param x position on screen
  80345. * @param y position on screen
  80346. * @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
  80347. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80348. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80349. * @returns a PickingInfo
  80350. */
  80351. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80352. /** Use the given ray to pick a sprite in the scene
  80353. * @param ray The ray (in world space) to use to pick meshes
  80354. * @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
  80355. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80356. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80357. * @returns a PickingInfo
  80358. */
  80359. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80360. /** @hidden */
  80361. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80362. /** Launch a ray to try to pick sprites in the scene
  80363. * @param x position on screen
  80364. * @param y position on screen
  80365. * @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
  80366. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80367. * @returns a PickingInfo array
  80368. */
  80369. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80370. /** Use the given ray to pick sprites in the scene
  80371. * @param ray The ray (in world space) to use to pick meshes
  80372. * @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
  80373. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80374. * @returns a PickingInfo array
  80375. */
  80376. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80377. /**
  80378. * Force the sprite under the pointer
  80379. * @param sprite defines the sprite to use
  80380. */
  80381. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80382. /**
  80383. * Gets the sprite under the pointer
  80384. * @returns a Sprite or null if no sprite is under the pointer
  80385. */
  80386. getPointerOverSprite(): Nullable<Sprite>;
  80387. }
  80388. /**
  80389. * Defines the sprite scene component responsible to manage sprites
  80390. * in a given scene.
  80391. */
  80392. export class SpriteSceneComponent implements ISceneComponent {
  80393. /**
  80394. * The component name helpfull to identify the component in the list of scene components.
  80395. */
  80396. readonly name: string;
  80397. /**
  80398. * The scene the component belongs to.
  80399. */
  80400. scene: Scene;
  80401. /** @hidden */
  80402. private _spritePredicate;
  80403. /**
  80404. * Creates a new instance of the component for the given scene
  80405. * @param scene Defines the scene to register the component in
  80406. */
  80407. constructor(scene: Scene);
  80408. /**
  80409. * Registers the component in a given scene
  80410. */
  80411. register(): void;
  80412. /**
  80413. * Rebuilds the elements related to this component in case of
  80414. * context lost for instance.
  80415. */
  80416. rebuild(): void;
  80417. /**
  80418. * Disposes the component and the associated ressources.
  80419. */
  80420. dispose(): void;
  80421. private _pickSpriteButKeepRay;
  80422. private _pointerMove;
  80423. private _pointerDown;
  80424. private _pointerUp;
  80425. }
  80426. }
  80427. declare module BABYLON {
  80428. /** @hidden */
  80429. export var fogFragmentDeclaration: {
  80430. name: string;
  80431. shader: string;
  80432. };
  80433. }
  80434. declare module BABYLON {
  80435. /** @hidden */
  80436. export var fogFragment: {
  80437. name: string;
  80438. shader: string;
  80439. };
  80440. }
  80441. declare module BABYLON {
  80442. /** @hidden */
  80443. export var spritesPixelShader: {
  80444. name: string;
  80445. shader: string;
  80446. };
  80447. }
  80448. declare module BABYLON {
  80449. /** @hidden */
  80450. export var fogVertexDeclaration: {
  80451. name: string;
  80452. shader: string;
  80453. };
  80454. }
  80455. declare module BABYLON {
  80456. /** @hidden */
  80457. export var spritesVertexShader: {
  80458. name: string;
  80459. shader: string;
  80460. };
  80461. }
  80462. declare module BABYLON {
  80463. /**
  80464. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80465. */
  80466. export interface ISpriteManager extends IDisposable {
  80467. /**
  80468. * Restricts the camera to viewing objects with the same layerMask.
  80469. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80470. */
  80471. layerMask: number;
  80472. /**
  80473. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80474. */
  80475. isPickable: boolean;
  80476. /**
  80477. * Specifies the rendering group id for this mesh (0 by default)
  80478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80479. */
  80480. renderingGroupId: number;
  80481. /**
  80482. * Defines the list of sprites managed by the manager.
  80483. */
  80484. sprites: Array<Sprite>;
  80485. /**
  80486. * Tests the intersection of a sprite with a specific ray.
  80487. * @param ray The ray we are sending to test the collision
  80488. * @param camera The camera space we are sending rays in
  80489. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80490. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80491. * @returns picking info or null.
  80492. */
  80493. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80494. /**
  80495. * Intersects the sprites with a ray
  80496. * @param ray defines the ray to intersect with
  80497. * @param camera defines the current active camera
  80498. * @param predicate defines a predicate used to select candidate sprites
  80499. * @returns null if no hit or a PickingInfo array
  80500. */
  80501. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80502. /**
  80503. * Renders the list of sprites on screen.
  80504. */
  80505. render(): void;
  80506. }
  80507. /**
  80508. * Class used to manage multiple sprites on the same spritesheet
  80509. * @see http://doc.babylonjs.com/babylon101/sprites
  80510. */
  80511. export class SpriteManager implements ISpriteManager {
  80512. /** defines the manager's name */
  80513. name: string;
  80514. /** Gets the list of sprites */
  80515. sprites: Sprite[];
  80516. /** Gets or sets the rendering group id (0 by default) */
  80517. renderingGroupId: number;
  80518. /** Gets or sets camera layer mask */
  80519. layerMask: number;
  80520. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80521. fogEnabled: boolean;
  80522. /** Gets or sets a boolean indicating if the sprites are pickable */
  80523. isPickable: boolean;
  80524. /** Defines the default width of a cell in the spritesheet */
  80525. cellWidth: number;
  80526. /** Defines the default height of a cell in the spritesheet */
  80527. cellHeight: number;
  80528. /** Associative array from JSON sprite data file */
  80529. private _cellData;
  80530. /** Array of sprite names from JSON sprite data file */
  80531. private _spriteMap;
  80532. /** True when packed cell data from JSON file is ready*/
  80533. private _packedAndReady;
  80534. /**
  80535. * An event triggered when the manager is disposed.
  80536. */
  80537. onDisposeObservable: Observable<SpriteManager>;
  80538. private _onDisposeObserver;
  80539. /**
  80540. * Callback called when the manager is disposed
  80541. */
  80542. onDispose: () => void;
  80543. private _capacity;
  80544. private _fromPacked;
  80545. private _spriteTexture;
  80546. private _epsilon;
  80547. private _scene;
  80548. private _vertexData;
  80549. private _buffer;
  80550. private _vertexBuffers;
  80551. private _indexBuffer;
  80552. private _effectBase;
  80553. private _effectFog;
  80554. /**
  80555. * Gets or sets the spritesheet texture
  80556. */
  80557. texture: Texture;
  80558. /**
  80559. * Creates a new sprite manager
  80560. * @param name defines the manager's name
  80561. * @param imgUrl defines the sprite sheet url
  80562. * @param capacity defines the maximum allowed number of sprites
  80563. * @param cellSize defines the size of a sprite cell
  80564. * @param scene defines the hosting scene
  80565. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80566. * @param samplingMode defines the smapling mode to use with spritesheet
  80567. * @param fromPacked set to false; do not alter
  80568. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80569. */
  80570. constructor(
  80571. /** defines the manager's name */
  80572. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80573. private _makePacked;
  80574. private _appendSpriteVertex;
  80575. /**
  80576. * Intersects the sprites with a ray
  80577. * @param ray defines the ray to intersect with
  80578. * @param camera defines the current active camera
  80579. * @param predicate defines a predicate used to select candidate sprites
  80580. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80581. * @returns null if no hit or a PickingInfo
  80582. */
  80583. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80584. /**
  80585. * Intersects the sprites with a ray
  80586. * @param ray defines the ray to intersect with
  80587. * @param camera defines the current active camera
  80588. * @param predicate defines a predicate used to select candidate sprites
  80589. * @returns null if no hit or a PickingInfo array
  80590. */
  80591. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80592. /**
  80593. * Render all child sprites
  80594. */
  80595. render(): void;
  80596. /**
  80597. * Release associated resources
  80598. */
  80599. dispose(): void;
  80600. }
  80601. }
  80602. declare module BABYLON {
  80603. /**
  80604. * Class used to represent a sprite
  80605. * @see http://doc.babylonjs.com/babylon101/sprites
  80606. */
  80607. export class Sprite {
  80608. /** defines the name */
  80609. name: string;
  80610. /** Gets or sets the current world position */
  80611. position: Vector3;
  80612. /** Gets or sets the main color */
  80613. color: Color4;
  80614. /** Gets or sets the width */
  80615. width: number;
  80616. /** Gets or sets the height */
  80617. height: number;
  80618. /** Gets or sets rotation angle */
  80619. angle: number;
  80620. /** Gets or sets the cell index in the sprite sheet */
  80621. cellIndex: number;
  80622. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80623. cellRef: string;
  80624. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80625. invertU: number;
  80626. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80627. invertV: number;
  80628. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80629. disposeWhenFinishedAnimating: boolean;
  80630. /** Gets the list of attached animations */
  80631. animations: Animation[];
  80632. /** Gets or sets a boolean indicating if the sprite can be picked */
  80633. isPickable: boolean;
  80634. /**
  80635. * Gets or sets the associated action manager
  80636. */
  80637. actionManager: Nullable<ActionManager>;
  80638. private _animationStarted;
  80639. private _loopAnimation;
  80640. private _fromIndex;
  80641. private _toIndex;
  80642. private _delay;
  80643. private _direction;
  80644. private _manager;
  80645. private _time;
  80646. private _onAnimationEnd;
  80647. /**
  80648. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80649. */
  80650. isVisible: boolean;
  80651. /**
  80652. * Gets or sets the sprite size
  80653. */
  80654. size: number;
  80655. /**
  80656. * Creates a new Sprite
  80657. * @param name defines the name
  80658. * @param manager defines the manager
  80659. */
  80660. constructor(
  80661. /** defines the name */
  80662. name: string, manager: ISpriteManager);
  80663. /**
  80664. * Starts an animation
  80665. * @param from defines the initial key
  80666. * @param to defines the end key
  80667. * @param loop defines if the animation must loop
  80668. * @param delay defines the start delay (in ms)
  80669. * @param onAnimationEnd defines a callback to call when animation ends
  80670. */
  80671. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80672. /** Stops current animation (if any) */
  80673. stopAnimation(): void;
  80674. /** @hidden */
  80675. _animate(deltaTime: number): void;
  80676. /** Release associated resources */
  80677. dispose(): void;
  80678. }
  80679. }
  80680. declare module BABYLON {
  80681. /**
  80682. * Information about the result of picking within a scene
  80683. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80684. */
  80685. export class PickingInfo {
  80686. /** @hidden */
  80687. _pickingUnavailable: boolean;
  80688. /**
  80689. * If the pick collided with an object
  80690. */
  80691. hit: boolean;
  80692. /**
  80693. * Distance away where the pick collided
  80694. */
  80695. distance: number;
  80696. /**
  80697. * The location of pick collision
  80698. */
  80699. pickedPoint: Nullable<Vector3>;
  80700. /**
  80701. * The mesh corresponding the the pick collision
  80702. */
  80703. pickedMesh: Nullable<AbstractMesh>;
  80704. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80705. bu: number;
  80706. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80707. bv: number;
  80708. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80709. faceId: number;
  80710. /** Id of the the submesh that was picked */
  80711. subMeshId: number;
  80712. /** If a sprite was picked, this will be the sprite the pick collided with */
  80713. pickedSprite: Nullable<Sprite>;
  80714. /**
  80715. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80716. */
  80717. originMesh: Nullable<AbstractMesh>;
  80718. /**
  80719. * The ray that was used to perform the picking.
  80720. */
  80721. ray: Nullable<Ray>;
  80722. /**
  80723. * Gets the normal correspodning to the face the pick collided with
  80724. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80725. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80726. * @returns The normal correspodning to the face the pick collided with
  80727. */
  80728. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80729. /**
  80730. * Gets the texture coordinates of where the pick occured
  80731. * @returns the vector containing the coordnates of the texture
  80732. */
  80733. getTextureCoordinates(): Nullable<Vector2>;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /**
  80738. * Gather the list of pointer event types as constants.
  80739. */
  80740. export class PointerEventTypes {
  80741. /**
  80742. * 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.
  80743. */
  80744. static readonly POINTERDOWN: number;
  80745. /**
  80746. * The pointerup event is fired when a pointer is no longer active.
  80747. */
  80748. static readonly POINTERUP: number;
  80749. /**
  80750. * The pointermove event is fired when a pointer changes coordinates.
  80751. */
  80752. static readonly POINTERMOVE: number;
  80753. /**
  80754. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80755. */
  80756. static readonly POINTERWHEEL: number;
  80757. /**
  80758. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80759. */
  80760. static readonly POINTERPICK: number;
  80761. /**
  80762. * The pointertap event is fired when a the object has been touched and released without drag.
  80763. */
  80764. static readonly POINTERTAP: number;
  80765. /**
  80766. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80767. */
  80768. static readonly POINTERDOUBLETAP: number;
  80769. }
  80770. /**
  80771. * Base class of pointer info types.
  80772. */
  80773. export class PointerInfoBase {
  80774. /**
  80775. * Defines the type of event (PointerEventTypes)
  80776. */
  80777. type: number;
  80778. /**
  80779. * Defines the related dom event
  80780. */
  80781. event: PointerEvent | MouseWheelEvent;
  80782. /**
  80783. * Instantiates the base class of pointers info.
  80784. * @param type Defines the type of event (PointerEventTypes)
  80785. * @param event Defines the related dom event
  80786. */
  80787. constructor(
  80788. /**
  80789. * Defines the type of event (PointerEventTypes)
  80790. */
  80791. type: number,
  80792. /**
  80793. * Defines the related dom event
  80794. */
  80795. event: PointerEvent | MouseWheelEvent);
  80796. }
  80797. /**
  80798. * This class is used to store pointer related info for the onPrePointerObservable event.
  80799. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80800. */
  80801. export class PointerInfoPre extends PointerInfoBase {
  80802. /**
  80803. * Ray from a pointer if availible (eg. 6dof controller)
  80804. */
  80805. ray: Nullable<Ray>;
  80806. /**
  80807. * Defines the local position of the pointer on the canvas.
  80808. */
  80809. localPosition: Vector2;
  80810. /**
  80811. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80812. */
  80813. skipOnPointerObservable: boolean;
  80814. /**
  80815. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80816. * @param type Defines the type of event (PointerEventTypes)
  80817. * @param event Defines the related dom event
  80818. * @param localX Defines the local x coordinates of the pointer when the event occured
  80819. * @param localY Defines the local y coordinates of the pointer when the event occured
  80820. */
  80821. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80822. }
  80823. /**
  80824. * This type contains all the data related to a pointer event in Babylon.js.
  80825. * 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.
  80826. */
  80827. export class PointerInfo extends PointerInfoBase {
  80828. /**
  80829. * Defines the picking info associated to the info (if any)\
  80830. */
  80831. pickInfo: Nullable<PickingInfo>;
  80832. /**
  80833. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80834. * @param type Defines the type of event (PointerEventTypes)
  80835. * @param event Defines the related dom event
  80836. * @param pickInfo Defines the picking info associated to the info (if any)\
  80837. */
  80838. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80839. /**
  80840. * Defines the picking info associated to the info (if any)\
  80841. */
  80842. pickInfo: Nullable<PickingInfo>);
  80843. }
  80844. /**
  80845. * Data relating to a touch event on the screen.
  80846. */
  80847. export interface PointerTouch {
  80848. /**
  80849. * X coordinate of touch.
  80850. */
  80851. x: number;
  80852. /**
  80853. * Y coordinate of touch.
  80854. */
  80855. y: number;
  80856. /**
  80857. * Id of touch. Unique for each finger.
  80858. */
  80859. pointerId: number;
  80860. /**
  80861. * Event type passed from DOM.
  80862. */
  80863. type: any;
  80864. }
  80865. }
  80866. declare module BABYLON {
  80867. /**
  80868. * Manage the mouse inputs to control the movement of a free camera.
  80869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80870. */
  80871. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80872. /**
  80873. * Define if touch is enabled in the mouse input
  80874. */
  80875. touchEnabled: boolean;
  80876. /**
  80877. * Defines the camera the input is attached to.
  80878. */
  80879. camera: FreeCamera;
  80880. /**
  80881. * Defines the buttons associated with the input to handle camera move.
  80882. */
  80883. buttons: number[];
  80884. /**
  80885. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80886. */
  80887. angularSensibility: number;
  80888. private _pointerInput;
  80889. private _onMouseMove;
  80890. private _observer;
  80891. private previousPosition;
  80892. /**
  80893. * Observable for when a pointer move event occurs containing the move offset
  80894. */
  80895. onPointerMovedObservable: Observable<{
  80896. offsetX: number;
  80897. offsetY: number;
  80898. }>;
  80899. /**
  80900. * @hidden
  80901. * If the camera should be rotated automatically based on pointer movement
  80902. */
  80903. _allowCameraRotation: boolean;
  80904. /**
  80905. * Manage the mouse inputs to control the movement of a free camera.
  80906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80907. * @param touchEnabled Defines if touch is enabled or not
  80908. */
  80909. constructor(
  80910. /**
  80911. * Define if touch is enabled in the mouse input
  80912. */
  80913. touchEnabled?: boolean);
  80914. /**
  80915. * Attach the input controls to a specific dom element to get the input from.
  80916. * @param element Defines the element the controls should be listened from
  80917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80918. */
  80919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80920. /**
  80921. * Called on JS contextmenu event.
  80922. * Override this method to provide functionality.
  80923. */
  80924. protected onContextMenu(evt: PointerEvent): void;
  80925. /**
  80926. * Detach the current controls from the specified dom element.
  80927. * @param element Defines the element to stop listening the inputs from
  80928. */
  80929. detachControl(element: Nullable<HTMLElement>): void;
  80930. /**
  80931. * Gets the class name of the current intput.
  80932. * @returns the class name
  80933. */
  80934. getClassName(): string;
  80935. /**
  80936. * Get the friendly name associated with the input class.
  80937. * @returns the input friendly name
  80938. */
  80939. getSimpleName(): string;
  80940. }
  80941. }
  80942. declare module BABYLON {
  80943. /**
  80944. * Manage the touch inputs to control the movement of a free camera.
  80945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80946. */
  80947. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80948. /**
  80949. * Defines the camera the input is attached to.
  80950. */
  80951. camera: FreeCamera;
  80952. /**
  80953. * Defines the touch sensibility for rotation.
  80954. * The higher the faster.
  80955. */
  80956. touchAngularSensibility: number;
  80957. /**
  80958. * Defines the touch sensibility for move.
  80959. * The higher the faster.
  80960. */
  80961. touchMoveSensibility: number;
  80962. private _offsetX;
  80963. private _offsetY;
  80964. private _pointerPressed;
  80965. private _pointerInput;
  80966. private _observer;
  80967. private _onLostFocus;
  80968. /**
  80969. * Attach the input controls to a specific dom element to get the input from.
  80970. * @param element Defines the element the controls should be listened from
  80971. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80972. */
  80973. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80974. /**
  80975. * Detach the current controls from the specified dom element.
  80976. * @param element Defines the element to stop listening the inputs from
  80977. */
  80978. detachControl(element: Nullable<HTMLElement>): void;
  80979. /**
  80980. * Update the current camera state depending on the inputs that have been used this frame.
  80981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80982. */
  80983. checkInputs(): void;
  80984. /**
  80985. * Gets the class name of the current intput.
  80986. * @returns the class name
  80987. */
  80988. getClassName(): string;
  80989. /**
  80990. * Get the friendly name associated with the input class.
  80991. * @returns the input friendly name
  80992. */
  80993. getSimpleName(): string;
  80994. }
  80995. }
  80996. declare module BABYLON {
  80997. /**
  80998. * Default Inputs manager for the FreeCamera.
  80999. * It groups all the default supported inputs for ease of use.
  81000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81001. */
  81002. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81003. /**
  81004. * @hidden
  81005. */
  81006. _mouseInput: Nullable<FreeCameraMouseInput>;
  81007. /**
  81008. * Instantiates a new FreeCameraInputsManager.
  81009. * @param camera Defines the camera the inputs belong to
  81010. */
  81011. constructor(camera: FreeCamera);
  81012. /**
  81013. * Add keyboard input support to the input manager.
  81014. * @returns the current input manager
  81015. */
  81016. addKeyboard(): FreeCameraInputsManager;
  81017. /**
  81018. * Add mouse input support to the input manager.
  81019. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81020. * @returns the current input manager
  81021. */
  81022. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81023. /**
  81024. * Removes the mouse input support from the manager
  81025. * @returns the current input manager
  81026. */
  81027. removeMouse(): FreeCameraInputsManager;
  81028. /**
  81029. * Add touch input support to the input manager.
  81030. * @returns the current input manager
  81031. */
  81032. addTouch(): FreeCameraInputsManager;
  81033. /**
  81034. * Remove all attached input methods from a camera
  81035. */
  81036. clear(): void;
  81037. }
  81038. }
  81039. declare module BABYLON {
  81040. /**
  81041. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81042. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81043. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81044. */
  81045. export class FreeCamera extends TargetCamera {
  81046. /**
  81047. * Define the collision ellipsoid of the camera.
  81048. * This is helpful to simulate a camera body like the player body around the camera
  81049. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81050. */
  81051. ellipsoid: Vector3;
  81052. /**
  81053. * Define an offset for the position of the ellipsoid around the camera.
  81054. * This can be helpful to determine the center of the body near the gravity center of the body
  81055. * instead of its head.
  81056. */
  81057. ellipsoidOffset: Vector3;
  81058. /**
  81059. * Enable or disable collisions of the camera with the rest of the scene objects.
  81060. */
  81061. checkCollisions: boolean;
  81062. /**
  81063. * Enable or disable gravity on the camera.
  81064. */
  81065. applyGravity: boolean;
  81066. /**
  81067. * Define the input manager associated to the camera.
  81068. */
  81069. inputs: FreeCameraInputsManager;
  81070. /**
  81071. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81072. * Higher values reduce sensitivity.
  81073. */
  81074. /**
  81075. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81076. * Higher values reduce sensitivity.
  81077. */
  81078. angularSensibility: number;
  81079. /**
  81080. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81081. */
  81082. keysUp: number[];
  81083. /**
  81084. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81085. */
  81086. keysDown: number[];
  81087. /**
  81088. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81089. */
  81090. keysLeft: number[];
  81091. /**
  81092. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81093. */
  81094. keysRight: number[];
  81095. /**
  81096. * Event raised when the camera collide with a mesh in the scene.
  81097. */
  81098. onCollide: (collidedMesh: AbstractMesh) => void;
  81099. private _collider;
  81100. private _needMoveForGravity;
  81101. private _oldPosition;
  81102. private _diffPosition;
  81103. private _newPosition;
  81104. /** @hidden */
  81105. _localDirection: Vector3;
  81106. /** @hidden */
  81107. _transformedDirection: Vector3;
  81108. /**
  81109. * Instantiates a Free Camera.
  81110. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81111. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81113. * @param name Define the name of the camera in the scene
  81114. * @param position Define the start position of the camera in the scene
  81115. * @param scene Define the scene the camera belongs to
  81116. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81117. */
  81118. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81119. /**
  81120. * Attached controls to the current camera.
  81121. * @param element Defines the element the controls should be listened from
  81122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81123. */
  81124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81125. /**
  81126. * Detach the current controls from the camera.
  81127. * The camera will stop reacting to inputs.
  81128. * @param element Defines the element to stop listening the inputs from
  81129. */
  81130. detachControl(element: HTMLElement): void;
  81131. private _collisionMask;
  81132. /**
  81133. * Define a collision mask to limit the list of object the camera can collide with
  81134. */
  81135. collisionMask: number;
  81136. /** @hidden */
  81137. _collideWithWorld(displacement: Vector3): void;
  81138. private _onCollisionPositionChange;
  81139. /** @hidden */
  81140. _checkInputs(): void;
  81141. /** @hidden */
  81142. _decideIfNeedsToMove(): boolean;
  81143. /** @hidden */
  81144. _updatePosition(): void;
  81145. /**
  81146. * Destroy the camera and release the current resources hold by it.
  81147. */
  81148. dispose(): void;
  81149. /**
  81150. * Gets the current object class name.
  81151. * @return the class name
  81152. */
  81153. getClassName(): string;
  81154. }
  81155. }
  81156. declare module BABYLON {
  81157. /**
  81158. * Represents a gamepad control stick position
  81159. */
  81160. export class StickValues {
  81161. /**
  81162. * The x component of the control stick
  81163. */
  81164. x: number;
  81165. /**
  81166. * The y component of the control stick
  81167. */
  81168. y: number;
  81169. /**
  81170. * Initializes the gamepad x and y control stick values
  81171. * @param x The x component of the gamepad control stick value
  81172. * @param y The y component of the gamepad control stick value
  81173. */
  81174. constructor(
  81175. /**
  81176. * The x component of the control stick
  81177. */
  81178. x: number,
  81179. /**
  81180. * The y component of the control stick
  81181. */
  81182. y: number);
  81183. }
  81184. /**
  81185. * An interface which manages callbacks for gamepad button changes
  81186. */
  81187. export interface GamepadButtonChanges {
  81188. /**
  81189. * Called when a gamepad has been changed
  81190. */
  81191. changed: boolean;
  81192. /**
  81193. * Called when a gamepad press event has been triggered
  81194. */
  81195. pressChanged: boolean;
  81196. /**
  81197. * Called when a touch event has been triggered
  81198. */
  81199. touchChanged: boolean;
  81200. /**
  81201. * Called when a value has changed
  81202. */
  81203. valueChanged: boolean;
  81204. }
  81205. /**
  81206. * Represents a gamepad
  81207. */
  81208. export class Gamepad {
  81209. /**
  81210. * The id of the gamepad
  81211. */
  81212. id: string;
  81213. /**
  81214. * The index of the gamepad
  81215. */
  81216. index: number;
  81217. /**
  81218. * The browser gamepad
  81219. */
  81220. browserGamepad: any;
  81221. /**
  81222. * Specifies what type of gamepad this represents
  81223. */
  81224. type: number;
  81225. private _leftStick;
  81226. private _rightStick;
  81227. /** @hidden */
  81228. _isConnected: boolean;
  81229. private _leftStickAxisX;
  81230. private _leftStickAxisY;
  81231. private _rightStickAxisX;
  81232. private _rightStickAxisY;
  81233. /**
  81234. * Triggered when the left control stick has been changed
  81235. */
  81236. private _onleftstickchanged;
  81237. /**
  81238. * Triggered when the right control stick has been changed
  81239. */
  81240. private _onrightstickchanged;
  81241. /**
  81242. * Represents a gamepad controller
  81243. */
  81244. static GAMEPAD: number;
  81245. /**
  81246. * Represents a generic controller
  81247. */
  81248. static GENERIC: number;
  81249. /**
  81250. * Represents an XBox controller
  81251. */
  81252. static XBOX: number;
  81253. /**
  81254. * Represents a pose-enabled controller
  81255. */
  81256. static POSE_ENABLED: number;
  81257. /**
  81258. * Represents an Dual Shock controller
  81259. */
  81260. static DUALSHOCK: number;
  81261. /**
  81262. * Specifies whether the left control stick should be Y-inverted
  81263. */
  81264. protected _invertLeftStickY: boolean;
  81265. /**
  81266. * Specifies if the gamepad has been connected
  81267. */
  81268. readonly isConnected: boolean;
  81269. /**
  81270. * Initializes the gamepad
  81271. * @param id The id of the gamepad
  81272. * @param index The index of the gamepad
  81273. * @param browserGamepad The browser gamepad
  81274. * @param leftStickX The x component of the left joystick
  81275. * @param leftStickY The y component of the left joystick
  81276. * @param rightStickX The x component of the right joystick
  81277. * @param rightStickY The y component of the right joystick
  81278. */
  81279. constructor(
  81280. /**
  81281. * The id of the gamepad
  81282. */
  81283. id: string,
  81284. /**
  81285. * The index of the gamepad
  81286. */
  81287. index: number,
  81288. /**
  81289. * The browser gamepad
  81290. */
  81291. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81292. /**
  81293. * Callback triggered when the left joystick has changed
  81294. * @param callback
  81295. */
  81296. onleftstickchanged(callback: (values: StickValues) => void): void;
  81297. /**
  81298. * Callback triggered when the right joystick has changed
  81299. * @param callback
  81300. */
  81301. onrightstickchanged(callback: (values: StickValues) => void): void;
  81302. /**
  81303. * Gets the left joystick
  81304. */
  81305. /**
  81306. * Sets the left joystick values
  81307. */
  81308. leftStick: StickValues;
  81309. /**
  81310. * Gets the right joystick
  81311. */
  81312. /**
  81313. * Sets the right joystick value
  81314. */
  81315. rightStick: StickValues;
  81316. /**
  81317. * Updates the gamepad joystick positions
  81318. */
  81319. update(): void;
  81320. /**
  81321. * Disposes the gamepad
  81322. */
  81323. dispose(): void;
  81324. }
  81325. /**
  81326. * Represents a generic gamepad
  81327. */
  81328. export class GenericPad extends Gamepad {
  81329. private _buttons;
  81330. private _onbuttondown;
  81331. private _onbuttonup;
  81332. /**
  81333. * Observable triggered when a button has been pressed
  81334. */
  81335. onButtonDownObservable: Observable<number>;
  81336. /**
  81337. * Observable triggered when a button has been released
  81338. */
  81339. onButtonUpObservable: Observable<number>;
  81340. /**
  81341. * Callback triggered when a button has been pressed
  81342. * @param callback Called when a button has been pressed
  81343. */
  81344. onbuttondown(callback: (buttonPressed: number) => void): void;
  81345. /**
  81346. * Callback triggered when a button has been released
  81347. * @param callback Called when a button has been released
  81348. */
  81349. onbuttonup(callback: (buttonReleased: number) => void): void;
  81350. /**
  81351. * Initializes the generic gamepad
  81352. * @param id The id of the generic gamepad
  81353. * @param index The index of the generic gamepad
  81354. * @param browserGamepad The browser gamepad
  81355. */
  81356. constructor(id: string, index: number, browserGamepad: any);
  81357. private _setButtonValue;
  81358. /**
  81359. * Updates the generic gamepad
  81360. */
  81361. update(): void;
  81362. /**
  81363. * Disposes the generic gamepad
  81364. */
  81365. dispose(): void;
  81366. }
  81367. }
  81368. declare module BABYLON {
  81369. interface Engine {
  81370. /**
  81371. * Creates a raw texture
  81372. * @param data defines the data to store in the texture
  81373. * @param width defines the width of the texture
  81374. * @param height defines the height of the texture
  81375. * @param format defines the format of the data
  81376. * @param generateMipMaps defines if the engine should generate the mip levels
  81377. * @param invertY defines if data must be stored with Y axis inverted
  81378. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81379. * @param compression defines the compression used (null by default)
  81380. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81381. * @returns the raw texture inside an InternalTexture
  81382. */
  81383. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81384. /**
  81385. * Update a raw texture
  81386. * @param texture defines the texture to update
  81387. * @param data defines the data to store in the texture
  81388. * @param format defines the format of the data
  81389. * @param invertY defines if data must be stored with Y axis inverted
  81390. */
  81391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81392. /**
  81393. * Update a raw texture
  81394. * @param texture defines the texture to update
  81395. * @param data defines the data to store in the texture
  81396. * @param format defines the format of the data
  81397. * @param invertY defines if data must be stored with Y axis inverted
  81398. * @param compression defines the compression used (null by default)
  81399. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81400. */
  81401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81402. /**
  81403. * Creates a new raw cube texture
  81404. * @param data defines the array of data to use to create each face
  81405. * @param size defines the size of the textures
  81406. * @param format defines the format of the data
  81407. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81408. * @param generateMipMaps defines if the engine should generate the mip levels
  81409. * @param invertY defines if data must be stored with Y axis inverted
  81410. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81411. * @param compression defines the compression used (null by default)
  81412. * @returns the cube texture as an InternalTexture
  81413. */
  81414. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81415. /**
  81416. * Update a raw cube texture
  81417. * @param texture defines the texture to udpdate
  81418. * @param data defines the data to store
  81419. * @param format defines the data format
  81420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81421. * @param invertY defines if data must be stored with Y axis inverted
  81422. */
  81423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81424. /**
  81425. * Update a raw cube texture
  81426. * @param texture defines the texture to udpdate
  81427. * @param data defines the data to store
  81428. * @param format defines the data format
  81429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81430. * @param invertY defines if data must be stored with Y axis inverted
  81431. * @param compression defines the compression used (null by default)
  81432. */
  81433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81434. /**
  81435. * Update a raw cube texture
  81436. * @param texture defines the texture to udpdate
  81437. * @param data defines the data to store
  81438. * @param format defines the data format
  81439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81440. * @param invertY defines if data must be stored with Y axis inverted
  81441. * @param compression defines the compression used (null by default)
  81442. * @param level defines which level of the texture to update
  81443. */
  81444. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81445. /**
  81446. * Creates a new raw cube texture from a specified url
  81447. * @param url defines the url where the data is located
  81448. * @param scene defines the current scene
  81449. * @param size defines the size of the textures
  81450. * @param format defines the format of the data
  81451. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81452. * @param noMipmap defines if the engine should avoid generating the mip levels
  81453. * @param callback defines a callback used to extract texture data from loaded data
  81454. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81455. * @param onLoad defines a callback called when texture is loaded
  81456. * @param onError defines a callback called if there is an error
  81457. * @returns the cube texture as an InternalTexture
  81458. */
  81459. 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;
  81460. /**
  81461. * Creates a new raw cube texture from a specified url
  81462. * @param url defines the url where the data is located
  81463. * @param scene defines the current scene
  81464. * @param size defines the size of the textures
  81465. * @param format defines the format of the data
  81466. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81467. * @param noMipmap defines if the engine should avoid generating the mip levels
  81468. * @param callback defines a callback used to extract texture data from loaded data
  81469. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81470. * @param onLoad defines a callback called when texture is loaded
  81471. * @param onError defines a callback called if there is an error
  81472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81473. * @param invertY defines if data must be stored with Y axis inverted
  81474. * @returns the cube texture as an InternalTexture
  81475. */
  81476. 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;
  81477. /**
  81478. * Creates a new raw 3D texture
  81479. * @param data defines the data used to create the texture
  81480. * @param width defines the width of the texture
  81481. * @param height defines the height of the texture
  81482. * @param depth defines the depth of the texture
  81483. * @param format defines the format of the texture
  81484. * @param generateMipMaps defines if the engine must generate mip levels
  81485. * @param invertY defines if data must be stored with Y axis inverted
  81486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81487. * @param compression defines the compressed used (can be null)
  81488. * @param textureType defines the compressed used (can be null)
  81489. * @returns a new raw 3D texture (stored in an InternalTexture)
  81490. */
  81491. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81492. /**
  81493. * Update a raw 3D texture
  81494. * @param texture defines the texture to update
  81495. * @param data defines the data to store
  81496. * @param format defines the data format
  81497. * @param invertY defines if data must be stored with Y axis inverted
  81498. */
  81499. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81500. /**
  81501. * Update a raw 3D texture
  81502. * @param texture defines the texture to update
  81503. * @param data defines the data to store
  81504. * @param format defines the data format
  81505. * @param invertY defines if data must be stored with Y axis inverted
  81506. * @param compression defines the used compression (can be null)
  81507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81508. */
  81509. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81510. /**
  81511. * Creates a new raw 2D array texture
  81512. * @param data defines the data used to create the texture
  81513. * @param width defines the width of the texture
  81514. * @param height defines the height of the texture
  81515. * @param depth defines the number of layers of the texture
  81516. * @param format defines the format of the texture
  81517. * @param generateMipMaps defines if the engine must generate mip levels
  81518. * @param invertY defines if data must be stored with Y axis inverted
  81519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81520. * @param compression defines the compressed used (can be null)
  81521. * @param textureType defines the compressed used (can be null)
  81522. * @returns a new raw 2D array texture (stored in an InternalTexture)
  81523. */
  81524. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81525. /**
  81526. * Update a raw 2D array texture
  81527. * @param texture defines the texture to update
  81528. * @param data defines the data to store
  81529. * @param format defines the data format
  81530. * @param invertY defines if data must be stored with Y axis inverted
  81531. */
  81532. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81533. /**
  81534. * Update a raw 2D array texture
  81535. * @param texture defines the texture to update
  81536. * @param data defines the data to store
  81537. * @param format defines the data format
  81538. * @param invertY defines if data must be stored with Y axis inverted
  81539. * @param compression defines the used compression (can be null)
  81540. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81541. */
  81542. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81543. }
  81544. }
  81545. declare module BABYLON {
  81546. /**
  81547. * Raw texture can help creating a texture directly from an array of data.
  81548. * This can be super useful if you either get the data from an uncompressed source or
  81549. * if you wish to create your texture pixel by pixel.
  81550. */
  81551. export class RawTexture extends Texture {
  81552. /**
  81553. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81554. */
  81555. format: number;
  81556. private _engine;
  81557. /**
  81558. * Instantiates a new RawTexture.
  81559. * Raw texture can help creating a texture directly from an array of data.
  81560. * This can be super useful if you either get the data from an uncompressed source or
  81561. * if you wish to create your texture pixel by pixel.
  81562. * @param data define the array of data to use to create the texture
  81563. * @param width define the width of the texture
  81564. * @param height define the height of the texture
  81565. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81566. * @param scene define the scene the texture belongs to
  81567. * @param generateMipMaps define whether mip maps should be generated or not
  81568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81570. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81571. */
  81572. constructor(data: ArrayBufferView, width: number, height: number,
  81573. /**
  81574. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81575. */
  81576. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81577. /**
  81578. * Updates the texture underlying data.
  81579. * @param data Define the new data of the texture
  81580. */
  81581. update(data: ArrayBufferView): void;
  81582. /**
  81583. * Creates a luminance texture from some data.
  81584. * @param data Define the texture data
  81585. * @param width Define the width of the texture
  81586. * @param height Define the height of the texture
  81587. * @param scene Define the scene the texture belongs to
  81588. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81589. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81590. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81591. * @returns the luminance texture
  81592. */
  81593. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81594. /**
  81595. * Creates a luminance alpha texture from some data.
  81596. * @param data Define the texture data
  81597. * @param width Define the width of the texture
  81598. * @param height Define the height of the texture
  81599. * @param scene Define the scene the texture belongs to
  81600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81603. * @returns the luminance alpha texture
  81604. */
  81605. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81606. /**
  81607. * Creates an alpha texture from some data.
  81608. * @param data Define the texture data
  81609. * @param width Define the width of the texture
  81610. * @param height Define the height of the texture
  81611. * @param scene Define the scene the texture belongs to
  81612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81615. * @returns the alpha texture
  81616. */
  81617. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81618. /**
  81619. * Creates a RGB texture from some data.
  81620. * @param data Define the texture data
  81621. * @param width Define the width of the texture
  81622. * @param height Define the height of the texture
  81623. * @param scene Define the scene the texture belongs to
  81624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81627. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81628. * @returns the RGB alpha texture
  81629. */
  81630. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81631. /**
  81632. * Creates a RGBA texture from some data.
  81633. * @param data Define the texture data
  81634. * @param width Define the width of the texture
  81635. * @param height Define the height of the texture
  81636. * @param scene Define the scene the texture belongs to
  81637. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81638. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81639. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81640. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81641. * @returns the RGBA texture
  81642. */
  81643. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81644. /**
  81645. * Creates a R texture from some data.
  81646. * @param data Define the texture data
  81647. * @param width Define the width of the texture
  81648. * @param height Define the height of the texture
  81649. * @param scene Define the scene the texture belongs to
  81650. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81651. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81652. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81653. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81654. * @returns the R texture
  81655. */
  81656. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81657. }
  81658. }
  81659. declare module BABYLON {
  81660. /**
  81661. * Interface for the size containing width and height
  81662. */
  81663. export interface ISize {
  81664. /**
  81665. * Width
  81666. */
  81667. width: number;
  81668. /**
  81669. * Heighht
  81670. */
  81671. height: number;
  81672. }
  81673. /**
  81674. * Size containing widht and height
  81675. */
  81676. export class Size implements ISize {
  81677. /**
  81678. * Width
  81679. */
  81680. width: number;
  81681. /**
  81682. * Height
  81683. */
  81684. height: number;
  81685. /**
  81686. * Creates a Size object from the given width and height (floats).
  81687. * @param width width of the new size
  81688. * @param height height of the new size
  81689. */
  81690. constructor(width: number, height: number);
  81691. /**
  81692. * Returns a string with the Size width and height
  81693. * @returns a string with the Size width and height
  81694. */
  81695. toString(): string;
  81696. /**
  81697. * "Size"
  81698. * @returns the string "Size"
  81699. */
  81700. getClassName(): string;
  81701. /**
  81702. * Returns the Size hash code.
  81703. * @returns a hash code for a unique width and height
  81704. */
  81705. getHashCode(): number;
  81706. /**
  81707. * Updates the current size from the given one.
  81708. * @param src the given size
  81709. */
  81710. copyFrom(src: Size): void;
  81711. /**
  81712. * Updates in place the current Size from the given floats.
  81713. * @param width width of the new size
  81714. * @param height height of the new size
  81715. * @returns the updated Size.
  81716. */
  81717. copyFromFloats(width: number, height: number): Size;
  81718. /**
  81719. * Updates in place the current Size from the given floats.
  81720. * @param width width to set
  81721. * @param height height to set
  81722. * @returns the updated Size.
  81723. */
  81724. set(width: number, height: number): Size;
  81725. /**
  81726. * Multiplies the width and height by numbers
  81727. * @param w factor to multiple the width by
  81728. * @param h factor to multiple the height by
  81729. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81730. */
  81731. multiplyByFloats(w: number, h: number): Size;
  81732. /**
  81733. * Clones the size
  81734. * @returns a new Size copied from the given one.
  81735. */
  81736. clone(): Size;
  81737. /**
  81738. * True if the current Size and the given one width and height are strictly equal.
  81739. * @param other the other size to compare against
  81740. * @returns True if the current Size and the given one width and height are strictly equal.
  81741. */
  81742. equals(other: Size): boolean;
  81743. /**
  81744. * The surface of the Size : width * height (float).
  81745. */
  81746. readonly surface: number;
  81747. /**
  81748. * Create a new size of zero
  81749. * @returns a new Size set to (0.0, 0.0)
  81750. */
  81751. static Zero(): Size;
  81752. /**
  81753. * Sums the width and height of two sizes
  81754. * @param otherSize size to add to this size
  81755. * @returns a new Size set as the addition result of the current Size and the given one.
  81756. */
  81757. add(otherSize: Size): Size;
  81758. /**
  81759. * Subtracts the width and height of two
  81760. * @param otherSize size to subtract to this size
  81761. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81762. */
  81763. subtract(otherSize: Size): Size;
  81764. /**
  81765. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81766. * @param start starting size to lerp between
  81767. * @param end end size to lerp between
  81768. * @param amount amount to lerp between the start and end values
  81769. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81770. */
  81771. static Lerp(start: Size, end: Size, amount: number): Size;
  81772. }
  81773. }
  81774. declare module BABYLON {
  81775. /**
  81776. * Defines a runtime animation
  81777. */
  81778. export class RuntimeAnimation {
  81779. private _events;
  81780. /**
  81781. * The current frame of the runtime animation
  81782. */
  81783. private _currentFrame;
  81784. /**
  81785. * The animation used by the runtime animation
  81786. */
  81787. private _animation;
  81788. /**
  81789. * The target of the runtime animation
  81790. */
  81791. private _target;
  81792. /**
  81793. * The initiating animatable
  81794. */
  81795. private _host;
  81796. /**
  81797. * The original value of the runtime animation
  81798. */
  81799. private _originalValue;
  81800. /**
  81801. * The original blend value of the runtime animation
  81802. */
  81803. private _originalBlendValue;
  81804. /**
  81805. * The offsets cache of the runtime animation
  81806. */
  81807. private _offsetsCache;
  81808. /**
  81809. * The high limits cache of the runtime animation
  81810. */
  81811. private _highLimitsCache;
  81812. /**
  81813. * Specifies if the runtime animation has been stopped
  81814. */
  81815. private _stopped;
  81816. /**
  81817. * The blending factor of the runtime animation
  81818. */
  81819. private _blendingFactor;
  81820. /**
  81821. * The BabylonJS scene
  81822. */
  81823. private _scene;
  81824. /**
  81825. * The current value of the runtime animation
  81826. */
  81827. private _currentValue;
  81828. /** @hidden */
  81829. _animationState: _IAnimationState;
  81830. /**
  81831. * The active target of the runtime animation
  81832. */
  81833. private _activeTargets;
  81834. private _currentActiveTarget;
  81835. private _directTarget;
  81836. /**
  81837. * The target path of the runtime animation
  81838. */
  81839. private _targetPath;
  81840. /**
  81841. * The weight of the runtime animation
  81842. */
  81843. private _weight;
  81844. /**
  81845. * The ratio offset of the runtime animation
  81846. */
  81847. private _ratioOffset;
  81848. /**
  81849. * The previous delay of the runtime animation
  81850. */
  81851. private _previousDelay;
  81852. /**
  81853. * The previous ratio of the runtime animation
  81854. */
  81855. private _previousRatio;
  81856. private _enableBlending;
  81857. private _keys;
  81858. private _minFrame;
  81859. private _maxFrame;
  81860. private _minValue;
  81861. private _maxValue;
  81862. private _targetIsArray;
  81863. /**
  81864. * Gets the current frame of the runtime animation
  81865. */
  81866. readonly currentFrame: number;
  81867. /**
  81868. * Gets the weight of the runtime animation
  81869. */
  81870. readonly weight: number;
  81871. /**
  81872. * Gets the current value of the runtime animation
  81873. */
  81874. readonly currentValue: any;
  81875. /**
  81876. * Gets the target path of the runtime animation
  81877. */
  81878. readonly targetPath: string;
  81879. /**
  81880. * Gets the actual target of the runtime animation
  81881. */
  81882. readonly target: any;
  81883. /** @hidden */
  81884. _onLoop: () => void;
  81885. /**
  81886. * Create a new RuntimeAnimation object
  81887. * @param target defines the target of the animation
  81888. * @param animation defines the source animation object
  81889. * @param scene defines the hosting scene
  81890. * @param host defines the initiating Animatable
  81891. */
  81892. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81893. private _preparePath;
  81894. /**
  81895. * Gets the animation from the runtime animation
  81896. */
  81897. readonly animation: Animation;
  81898. /**
  81899. * Resets the runtime animation to the beginning
  81900. * @param restoreOriginal defines whether to restore the target property to the original value
  81901. */
  81902. reset(restoreOriginal?: boolean): void;
  81903. /**
  81904. * Specifies if the runtime animation is stopped
  81905. * @returns Boolean specifying if the runtime animation is stopped
  81906. */
  81907. isStopped(): boolean;
  81908. /**
  81909. * Disposes of the runtime animation
  81910. */
  81911. dispose(): void;
  81912. /**
  81913. * Apply the interpolated value to the target
  81914. * @param currentValue defines the value computed by the animation
  81915. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81916. */
  81917. setValue(currentValue: any, weight: number): void;
  81918. private _getOriginalValues;
  81919. private _setValue;
  81920. /**
  81921. * Gets the loop pmode of the runtime animation
  81922. * @returns Loop Mode
  81923. */
  81924. private _getCorrectLoopMode;
  81925. /**
  81926. * Move the current animation to a given frame
  81927. * @param frame defines the frame to move to
  81928. */
  81929. goToFrame(frame: number): void;
  81930. /**
  81931. * @hidden Internal use only
  81932. */
  81933. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81934. /**
  81935. * Execute the current animation
  81936. * @param delay defines the delay to add to the current frame
  81937. * @param from defines the lower bound of the animation range
  81938. * @param to defines the upper bound of the animation range
  81939. * @param loop defines if the current animation must loop
  81940. * @param speedRatio defines the current speed ratio
  81941. * @param weight defines the weight of the animation (default is -1 so no weight)
  81942. * @param onLoop optional callback called when animation loops
  81943. * @returns a boolean indicating if the animation is running
  81944. */
  81945. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81946. }
  81947. }
  81948. declare module BABYLON {
  81949. /**
  81950. * Class used to store an actual running animation
  81951. */
  81952. export class Animatable {
  81953. /** defines the target object */
  81954. target: any;
  81955. /** defines the starting frame number (default is 0) */
  81956. fromFrame: number;
  81957. /** defines the ending frame number (default is 100) */
  81958. toFrame: number;
  81959. /** defines if the animation must loop (default is false) */
  81960. loopAnimation: boolean;
  81961. /** defines a callback to call when animation ends if it is not looping */
  81962. onAnimationEnd?: (() => void) | null | undefined;
  81963. /** defines a callback to call when animation loops */
  81964. onAnimationLoop?: (() => void) | null | undefined;
  81965. private _localDelayOffset;
  81966. private _pausedDelay;
  81967. private _runtimeAnimations;
  81968. private _paused;
  81969. private _scene;
  81970. private _speedRatio;
  81971. private _weight;
  81972. private _syncRoot;
  81973. /**
  81974. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81975. * This will only apply for non looping animation (default is true)
  81976. */
  81977. disposeOnEnd: boolean;
  81978. /**
  81979. * Gets a boolean indicating if the animation has started
  81980. */
  81981. animationStarted: boolean;
  81982. /**
  81983. * Observer raised when the animation ends
  81984. */
  81985. onAnimationEndObservable: Observable<Animatable>;
  81986. /**
  81987. * Observer raised when the animation loops
  81988. */
  81989. onAnimationLoopObservable: Observable<Animatable>;
  81990. /**
  81991. * Gets the root Animatable used to synchronize and normalize animations
  81992. */
  81993. readonly syncRoot: Nullable<Animatable>;
  81994. /**
  81995. * Gets the current frame of the first RuntimeAnimation
  81996. * Used to synchronize Animatables
  81997. */
  81998. readonly masterFrame: number;
  81999. /**
  82000. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82001. */
  82002. weight: number;
  82003. /**
  82004. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82005. */
  82006. speedRatio: number;
  82007. /**
  82008. * Creates a new Animatable
  82009. * @param scene defines the hosting scene
  82010. * @param target defines the target object
  82011. * @param fromFrame defines the starting frame number (default is 0)
  82012. * @param toFrame defines the ending frame number (default is 100)
  82013. * @param loopAnimation defines if the animation must loop (default is false)
  82014. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82015. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82016. * @param animations defines a group of animation to add to the new Animatable
  82017. * @param onAnimationLoop defines a callback to call when animation loops
  82018. */
  82019. constructor(scene: Scene,
  82020. /** defines the target object */
  82021. target: any,
  82022. /** defines the starting frame number (default is 0) */
  82023. fromFrame?: number,
  82024. /** defines the ending frame number (default is 100) */
  82025. toFrame?: number,
  82026. /** defines if the animation must loop (default is false) */
  82027. loopAnimation?: boolean, speedRatio?: number,
  82028. /** defines a callback to call when animation ends if it is not looping */
  82029. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82030. /** defines a callback to call when animation loops */
  82031. onAnimationLoop?: (() => void) | null | undefined);
  82032. /**
  82033. * Synchronize and normalize current Animatable with a source Animatable
  82034. * This is useful when using animation weights and when animations are not of the same length
  82035. * @param root defines the root Animatable to synchronize with
  82036. * @returns the current Animatable
  82037. */
  82038. syncWith(root: Animatable): Animatable;
  82039. /**
  82040. * Gets the list of runtime animations
  82041. * @returns an array of RuntimeAnimation
  82042. */
  82043. getAnimations(): RuntimeAnimation[];
  82044. /**
  82045. * Adds more animations to the current animatable
  82046. * @param target defines the target of the animations
  82047. * @param animations defines the new animations to add
  82048. */
  82049. appendAnimations(target: any, animations: Animation[]): void;
  82050. /**
  82051. * Gets the source animation for a specific property
  82052. * @param property defines the propertyu to look for
  82053. * @returns null or the source animation for the given property
  82054. */
  82055. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82056. /**
  82057. * Gets the runtime animation for a specific property
  82058. * @param property defines the propertyu to look for
  82059. * @returns null or the runtime animation for the given property
  82060. */
  82061. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82062. /**
  82063. * Resets the animatable to its original state
  82064. */
  82065. reset(): void;
  82066. /**
  82067. * Allows the animatable to blend with current running animations
  82068. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82069. * @param blendingSpeed defines the blending speed to use
  82070. */
  82071. enableBlending(blendingSpeed: number): void;
  82072. /**
  82073. * Disable animation blending
  82074. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82075. */
  82076. disableBlending(): void;
  82077. /**
  82078. * Jump directly to a given frame
  82079. * @param frame defines the frame to jump to
  82080. */
  82081. goToFrame(frame: number): void;
  82082. /**
  82083. * Pause the animation
  82084. */
  82085. pause(): void;
  82086. /**
  82087. * Restart the animation
  82088. */
  82089. restart(): void;
  82090. private _raiseOnAnimationEnd;
  82091. /**
  82092. * Stop and delete the current animation
  82093. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82094. * @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)
  82095. */
  82096. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82097. /**
  82098. * Wait asynchronously for the animation to end
  82099. * @returns a promise which will be fullfilled when the animation ends
  82100. */
  82101. waitAsync(): Promise<Animatable>;
  82102. /** @hidden */
  82103. _animate(delay: number): boolean;
  82104. }
  82105. interface Scene {
  82106. /** @hidden */
  82107. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82108. /** @hidden */
  82109. _processLateAnimationBindingsForMatrices(holder: {
  82110. totalWeight: number;
  82111. animations: RuntimeAnimation[];
  82112. originalValue: Matrix;
  82113. }): any;
  82114. /** @hidden */
  82115. _processLateAnimationBindingsForQuaternions(holder: {
  82116. totalWeight: number;
  82117. animations: RuntimeAnimation[];
  82118. originalValue: Quaternion;
  82119. }, refQuaternion: Quaternion): Quaternion;
  82120. /** @hidden */
  82121. _processLateAnimationBindings(): void;
  82122. /**
  82123. * Will start the animation sequence of a given target
  82124. * @param target defines the target
  82125. * @param from defines from which frame should animation start
  82126. * @param to defines until which frame should animation run.
  82127. * @param weight defines the weight to apply to the animation (1.0 by default)
  82128. * @param loop defines if the animation loops
  82129. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82130. * @param onAnimationEnd defines the function to be executed when the animation ends
  82131. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82132. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82133. * @param onAnimationLoop defines the callback to call when an animation loops
  82134. * @returns the animatable object created for this animation
  82135. */
  82136. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82137. /**
  82138. * Will start the animation sequence of a given target
  82139. * @param target defines the target
  82140. * @param from defines from which frame should animation start
  82141. * @param to defines until which frame should animation run.
  82142. * @param loop defines if the animation loops
  82143. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82144. * @param onAnimationEnd defines the function to be executed when the animation ends
  82145. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82146. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82147. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82148. * @param onAnimationLoop defines the callback to call when an animation loops
  82149. * @returns the animatable object created for this animation
  82150. */
  82151. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82152. /**
  82153. * Will start the animation sequence of a given target and its hierarchy
  82154. * @param target defines the target
  82155. * @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.
  82156. * @param from defines from which frame should animation start
  82157. * @param to defines until which frame should animation run.
  82158. * @param loop defines if the animation loops
  82159. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82160. * @param onAnimationEnd defines the function to be executed when the animation ends
  82161. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82162. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82163. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82164. * @param onAnimationLoop defines the callback to call when an animation loops
  82165. * @returns the list of created animatables
  82166. */
  82167. 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[];
  82168. /**
  82169. * Begin a new animation on a given node
  82170. * @param target defines the target where the animation will take place
  82171. * @param animations defines the list of animations to start
  82172. * @param from defines the initial value
  82173. * @param to defines the final value
  82174. * @param loop defines if you want animation to loop (off by default)
  82175. * @param speedRatio defines the speed ratio to apply to all animations
  82176. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82177. * @param onAnimationLoop defines the callback to call when an animation loops
  82178. * @returns the list of created animatables
  82179. */
  82180. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82181. /**
  82182. * Begin a new animation on a given node and its hierarchy
  82183. * @param target defines the root node where the animation will take place
  82184. * @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.
  82185. * @param animations defines the list of animations to start
  82186. * @param from defines the initial value
  82187. * @param to defines the final value
  82188. * @param loop defines if you want animation to loop (off by default)
  82189. * @param speedRatio defines the speed ratio to apply to all animations
  82190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82191. * @param onAnimationLoop defines the callback to call when an animation loops
  82192. * @returns the list of animatables created for all nodes
  82193. */
  82194. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82195. /**
  82196. * Gets the animatable associated with a specific target
  82197. * @param target defines the target of the animatable
  82198. * @returns the required animatable if found
  82199. */
  82200. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82201. /**
  82202. * Gets all animatables associated with a given target
  82203. * @param target defines the target to look animatables for
  82204. * @returns an array of Animatables
  82205. */
  82206. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82207. /**
  82208. * Stops and removes all animations that have been applied to the scene
  82209. */
  82210. stopAllAnimations(): void;
  82211. /**
  82212. * Gets the current delta time used by animation engine
  82213. */
  82214. deltaTime: number;
  82215. }
  82216. interface Bone {
  82217. /**
  82218. * Copy an animation range from another bone
  82219. * @param source defines the source bone
  82220. * @param rangeName defines the range name to copy
  82221. * @param frameOffset defines the frame offset
  82222. * @param rescaleAsRequired defines if rescaling must be applied if required
  82223. * @param skelDimensionsRatio defines the scaling ratio
  82224. * @returns true if operation was successful
  82225. */
  82226. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82227. }
  82228. }
  82229. declare module BABYLON {
  82230. /**
  82231. * Class used to override all child animations of a given target
  82232. */
  82233. export class AnimationPropertiesOverride {
  82234. /**
  82235. * Gets or sets a value indicating if animation blending must be used
  82236. */
  82237. enableBlending: boolean;
  82238. /**
  82239. * Gets or sets the blending speed to use when enableBlending is true
  82240. */
  82241. blendingSpeed: number;
  82242. /**
  82243. * Gets or sets the default loop mode to use
  82244. */
  82245. loopMode: number;
  82246. }
  82247. }
  82248. declare module BABYLON {
  82249. /**
  82250. * Class used to handle skinning animations
  82251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82252. */
  82253. export class Skeleton implements IAnimatable {
  82254. /** defines the skeleton name */
  82255. name: string;
  82256. /** defines the skeleton Id */
  82257. id: string;
  82258. /**
  82259. * Defines the list of child bones
  82260. */
  82261. bones: Bone[];
  82262. /**
  82263. * Defines an estimate of the dimension of the skeleton at rest
  82264. */
  82265. dimensionsAtRest: Vector3;
  82266. /**
  82267. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82268. */
  82269. needInitialSkinMatrix: boolean;
  82270. /**
  82271. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82272. */
  82273. overrideMesh: Nullable<AbstractMesh>;
  82274. /**
  82275. * Gets the list of animations attached to this skeleton
  82276. */
  82277. animations: Array<Animation>;
  82278. private _scene;
  82279. private _isDirty;
  82280. private _transformMatrices;
  82281. private _transformMatrixTexture;
  82282. private _meshesWithPoseMatrix;
  82283. private _animatables;
  82284. private _identity;
  82285. private _synchronizedWithMesh;
  82286. private _ranges;
  82287. private _lastAbsoluteTransformsUpdateId;
  82288. private _canUseTextureForBones;
  82289. private _uniqueId;
  82290. /** @hidden */
  82291. _numBonesWithLinkedTransformNode: number;
  82292. /** @hidden */
  82293. _hasWaitingData: Nullable<boolean>;
  82294. /**
  82295. * Specifies if the skeleton should be serialized
  82296. */
  82297. doNotSerialize: boolean;
  82298. private _useTextureToStoreBoneMatrices;
  82299. /**
  82300. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82301. * Please note that this option is not available if the hardware does not support it
  82302. */
  82303. useTextureToStoreBoneMatrices: boolean;
  82304. private _animationPropertiesOverride;
  82305. /**
  82306. * Gets or sets the animation properties override
  82307. */
  82308. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82309. /**
  82310. * List of inspectable custom properties (used by the Inspector)
  82311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82312. */
  82313. inspectableCustomProperties: IInspectable[];
  82314. /**
  82315. * An observable triggered before computing the skeleton's matrices
  82316. */
  82317. onBeforeComputeObservable: Observable<Skeleton>;
  82318. /**
  82319. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82320. */
  82321. readonly isUsingTextureForMatrices: boolean;
  82322. /**
  82323. * Gets the unique ID of this skeleton
  82324. */
  82325. readonly uniqueId: number;
  82326. /**
  82327. * Creates a new skeleton
  82328. * @param name defines the skeleton name
  82329. * @param id defines the skeleton Id
  82330. * @param scene defines the hosting scene
  82331. */
  82332. constructor(
  82333. /** defines the skeleton name */
  82334. name: string,
  82335. /** defines the skeleton Id */
  82336. id: string, scene: Scene);
  82337. /**
  82338. * Gets the current object class name.
  82339. * @return the class name
  82340. */
  82341. getClassName(): string;
  82342. /**
  82343. * Returns an array containing the root bones
  82344. * @returns an array containing the root bones
  82345. */
  82346. getChildren(): Array<Bone>;
  82347. /**
  82348. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82349. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82350. * @returns a Float32Array containing matrices data
  82351. */
  82352. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82353. /**
  82354. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82355. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82356. * @returns a raw texture containing the data
  82357. */
  82358. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82359. /**
  82360. * Gets the current hosting scene
  82361. * @returns a scene object
  82362. */
  82363. getScene(): Scene;
  82364. /**
  82365. * Gets a string representing the current skeleton data
  82366. * @param fullDetails defines a boolean indicating if we want a verbose version
  82367. * @returns a string representing the current skeleton data
  82368. */
  82369. toString(fullDetails?: boolean): string;
  82370. /**
  82371. * Get bone's index searching by name
  82372. * @param name defines bone's name to search for
  82373. * @return the indice of the bone. Returns -1 if not found
  82374. */
  82375. getBoneIndexByName(name: string): number;
  82376. /**
  82377. * Creater a new animation range
  82378. * @param name defines the name of the range
  82379. * @param from defines the start key
  82380. * @param to defines the end key
  82381. */
  82382. createAnimationRange(name: string, from: number, to: number): void;
  82383. /**
  82384. * Delete a specific animation range
  82385. * @param name defines the name of the range
  82386. * @param deleteFrames defines if frames must be removed as well
  82387. */
  82388. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82389. /**
  82390. * Gets a specific animation range
  82391. * @param name defines the name of the range to look for
  82392. * @returns the requested animation range or null if not found
  82393. */
  82394. getAnimationRange(name: string): Nullable<AnimationRange>;
  82395. /**
  82396. * Gets the list of all animation ranges defined on this skeleton
  82397. * @returns an array
  82398. */
  82399. getAnimationRanges(): Nullable<AnimationRange>[];
  82400. /**
  82401. * Copy animation range from a source skeleton.
  82402. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82403. * @param source defines the source skeleton
  82404. * @param name defines the name of the range to copy
  82405. * @param rescaleAsRequired defines if rescaling must be applied if required
  82406. * @returns true if operation was successful
  82407. */
  82408. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82409. /**
  82410. * Forces the skeleton to go to rest pose
  82411. */
  82412. returnToRest(): void;
  82413. private _getHighestAnimationFrame;
  82414. /**
  82415. * Begin a specific animation range
  82416. * @param name defines the name of the range to start
  82417. * @param loop defines if looping must be turned on (false by default)
  82418. * @param speedRatio defines the speed ratio to apply (1 by default)
  82419. * @param onAnimationEnd defines a callback which will be called when animation will end
  82420. * @returns a new animatable
  82421. */
  82422. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82423. /** @hidden */
  82424. _markAsDirty(): void;
  82425. /** @hidden */
  82426. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82427. /** @hidden */
  82428. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82429. private _computeTransformMatrices;
  82430. /**
  82431. * Build all resources required to render a skeleton
  82432. */
  82433. prepare(): void;
  82434. /**
  82435. * Gets the list of animatables currently running for this skeleton
  82436. * @returns an array of animatables
  82437. */
  82438. getAnimatables(): IAnimatable[];
  82439. /**
  82440. * Clone the current skeleton
  82441. * @param name defines the name of the new skeleton
  82442. * @param id defines the id of the new skeleton
  82443. * @returns the new skeleton
  82444. */
  82445. clone(name: string, id?: string): Skeleton;
  82446. /**
  82447. * Enable animation blending for this skeleton
  82448. * @param blendingSpeed defines the blending speed to apply
  82449. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82450. */
  82451. enableBlending(blendingSpeed?: number): void;
  82452. /**
  82453. * Releases all resources associated with the current skeleton
  82454. */
  82455. dispose(): void;
  82456. /**
  82457. * Serialize the skeleton in a JSON object
  82458. * @returns a JSON object
  82459. */
  82460. serialize(): any;
  82461. /**
  82462. * Creates a new skeleton from serialized data
  82463. * @param parsedSkeleton defines the serialized data
  82464. * @param scene defines the hosting scene
  82465. * @returns a new skeleton
  82466. */
  82467. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82468. /**
  82469. * Compute all node absolute transforms
  82470. * @param forceUpdate defines if computation must be done even if cache is up to date
  82471. */
  82472. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82473. /**
  82474. * Gets the root pose matrix
  82475. * @returns a matrix
  82476. */
  82477. getPoseMatrix(): Nullable<Matrix>;
  82478. /**
  82479. * Sorts bones per internal index
  82480. */
  82481. sortBones(): void;
  82482. private _sortBones;
  82483. }
  82484. }
  82485. declare module BABYLON {
  82486. /**
  82487. * Class used to store bone information
  82488. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82489. */
  82490. export class Bone extends Node {
  82491. /**
  82492. * defines the bone name
  82493. */
  82494. name: string;
  82495. private static _tmpVecs;
  82496. private static _tmpQuat;
  82497. private static _tmpMats;
  82498. /**
  82499. * Gets the list of child bones
  82500. */
  82501. children: Bone[];
  82502. /** Gets the animations associated with this bone */
  82503. animations: Animation[];
  82504. /**
  82505. * Gets or sets bone length
  82506. */
  82507. length: number;
  82508. /**
  82509. * @hidden Internal only
  82510. * Set this value to map this bone to a different index in the transform matrices
  82511. * Set this value to -1 to exclude the bone from the transform matrices
  82512. */
  82513. _index: Nullable<number>;
  82514. private _skeleton;
  82515. private _localMatrix;
  82516. private _restPose;
  82517. private _baseMatrix;
  82518. private _absoluteTransform;
  82519. private _invertedAbsoluteTransform;
  82520. private _parent;
  82521. private _scalingDeterminant;
  82522. private _worldTransform;
  82523. private _localScaling;
  82524. private _localRotation;
  82525. private _localPosition;
  82526. private _needToDecompose;
  82527. private _needToCompose;
  82528. /** @hidden */
  82529. _linkedTransformNode: Nullable<TransformNode>;
  82530. /** @hidden */
  82531. _waitingTransformNodeId: Nullable<string>;
  82532. /** @hidden */
  82533. /** @hidden */
  82534. _matrix: Matrix;
  82535. /**
  82536. * Create a new bone
  82537. * @param name defines the bone name
  82538. * @param skeleton defines the parent skeleton
  82539. * @param parentBone defines the parent (can be null if the bone is the root)
  82540. * @param localMatrix defines the local matrix
  82541. * @param restPose defines the rest pose matrix
  82542. * @param baseMatrix defines the base matrix
  82543. * @param index defines index of the bone in the hiearchy
  82544. */
  82545. constructor(
  82546. /**
  82547. * defines the bone name
  82548. */
  82549. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82550. /**
  82551. * Gets the current object class name.
  82552. * @return the class name
  82553. */
  82554. getClassName(): string;
  82555. /**
  82556. * Gets the parent skeleton
  82557. * @returns a skeleton
  82558. */
  82559. getSkeleton(): Skeleton;
  82560. /**
  82561. * Gets parent bone
  82562. * @returns a bone or null if the bone is the root of the bone hierarchy
  82563. */
  82564. getParent(): Nullable<Bone>;
  82565. /**
  82566. * Returns an array containing the root bones
  82567. * @returns an array containing the root bones
  82568. */
  82569. getChildren(): Array<Bone>;
  82570. /**
  82571. * Gets the node index in matrix array generated for rendering
  82572. * @returns the node index
  82573. */
  82574. getIndex(): number;
  82575. /**
  82576. * Sets the parent bone
  82577. * @param parent defines the parent (can be null if the bone is the root)
  82578. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82579. */
  82580. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82581. /**
  82582. * Gets the local matrix
  82583. * @returns a matrix
  82584. */
  82585. getLocalMatrix(): Matrix;
  82586. /**
  82587. * Gets the base matrix (initial matrix which remains unchanged)
  82588. * @returns a matrix
  82589. */
  82590. getBaseMatrix(): Matrix;
  82591. /**
  82592. * Gets the rest pose matrix
  82593. * @returns a matrix
  82594. */
  82595. getRestPose(): Matrix;
  82596. /**
  82597. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82598. */
  82599. getWorldMatrix(): Matrix;
  82600. /**
  82601. * Sets the local matrix to rest pose matrix
  82602. */
  82603. returnToRest(): void;
  82604. /**
  82605. * Gets the inverse of the absolute transform matrix.
  82606. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82607. * @returns a matrix
  82608. */
  82609. getInvertedAbsoluteTransform(): Matrix;
  82610. /**
  82611. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82612. * @returns a matrix
  82613. */
  82614. getAbsoluteTransform(): Matrix;
  82615. /**
  82616. * Links with the given transform node.
  82617. * The local matrix of this bone is copied from the transform node every frame.
  82618. * @param transformNode defines the transform node to link to
  82619. */
  82620. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82621. /**
  82622. * Gets the node used to drive the bone's transformation
  82623. * @returns a transform node or null
  82624. */
  82625. getTransformNode(): Nullable<TransformNode>;
  82626. /** Gets or sets current position (in local space) */
  82627. position: Vector3;
  82628. /** Gets or sets current rotation (in local space) */
  82629. rotation: Vector3;
  82630. /** Gets or sets current rotation quaternion (in local space) */
  82631. rotationQuaternion: Quaternion;
  82632. /** Gets or sets current scaling (in local space) */
  82633. scaling: Vector3;
  82634. /**
  82635. * Gets the animation properties override
  82636. */
  82637. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82638. private _decompose;
  82639. private _compose;
  82640. /**
  82641. * Update the base and local matrices
  82642. * @param matrix defines the new base or local matrix
  82643. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82644. * @param updateLocalMatrix defines if the local matrix should be updated
  82645. */
  82646. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82647. /** @hidden */
  82648. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82649. /**
  82650. * Flag the bone as dirty (Forcing it to update everything)
  82651. */
  82652. markAsDirty(): void;
  82653. /** @hidden */
  82654. _markAsDirtyAndCompose(): void;
  82655. private _markAsDirtyAndDecompose;
  82656. /**
  82657. * Translate the bone in local or world space
  82658. * @param vec The amount to translate the bone
  82659. * @param space The space that the translation is in
  82660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82661. */
  82662. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82663. /**
  82664. * Set the postion of the bone in local or world space
  82665. * @param position The position to set the bone
  82666. * @param space The space that the position is in
  82667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82668. */
  82669. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82670. /**
  82671. * Set the absolute position of the bone (world space)
  82672. * @param position The position to set the bone
  82673. * @param mesh The mesh that this bone is attached to
  82674. */
  82675. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82676. /**
  82677. * Scale the bone on the x, y and z axes (in local space)
  82678. * @param x The amount to scale the bone on the x axis
  82679. * @param y The amount to scale the bone on the y axis
  82680. * @param z The amount to scale the bone on the z axis
  82681. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82682. */
  82683. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82684. /**
  82685. * Set the bone scaling in local space
  82686. * @param scale defines the scaling vector
  82687. */
  82688. setScale(scale: Vector3): void;
  82689. /**
  82690. * Gets the current scaling in local space
  82691. * @returns the current scaling vector
  82692. */
  82693. getScale(): Vector3;
  82694. /**
  82695. * Gets the current scaling in local space and stores it in a target vector
  82696. * @param result defines the target vector
  82697. */
  82698. getScaleToRef(result: Vector3): void;
  82699. /**
  82700. * Set the yaw, pitch, and roll of the bone in local or world space
  82701. * @param yaw The rotation of the bone on the y axis
  82702. * @param pitch The rotation of the bone on the x axis
  82703. * @param roll The rotation of the bone on the z axis
  82704. * @param space The space that the axes of rotation are in
  82705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82706. */
  82707. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82708. /**
  82709. * Add a rotation to the bone on an axis in local or world space
  82710. * @param axis The axis to rotate the bone on
  82711. * @param amount The amount to rotate the bone
  82712. * @param space The space that the axis is in
  82713. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82714. */
  82715. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82716. /**
  82717. * Set the rotation of the bone to a particular axis angle in local or world space
  82718. * @param axis The axis to rotate the bone on
  82719. * @param angle The angle that the bone should be rotated to
  82720. * @param space The space that the axis is in
  82721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82722. */
  82723. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82724. /**
  82725. * Set the euler rotation of the bone in local of world space
  82726. * @param rotation The euler rotation that the bone should be set to
  82727. * @param space The space that the rotation is in
  82728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82729. */
  82730. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82731. /**
  82732. * Set the quaternion rotation of the bone in local of world space
  82733. * @param quat The quaternion rotation that the bone should be set to
  82734. * @param space The space that the rotation is in
  82735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82736. */
  82737. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82738. /**
  82739. * Set the rotation matrix of the bone in local of world space
  82740. * @param rotMat The rotation matrix that the bone should be set to
  82741. * @param space The space that the rotation is in
  82742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82743. */
  82744. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82745. private _rotateWithMatrix;
  82746. private _getNegativeRotationToRef;
  82747. /**
  82748. * Get the position of the bone in local or world space
  82749. * @param space The space that the returned position is in
  82750. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82751. * @returns The position of the bone
  82752. */
  82753. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82754. /**
  82755. * Copy the position of the bone to a vector3 in local or world space
  82756. * @param space The space that the returned position is in
  82757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82758. * @param result The vector3 to copy the position to
  82759. */
  82760. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82761. /**
  82762. * Get the absolute position of the bone (world space)
  82763. * @param mesh The mesh that this bone is attached to
  82764. * @returns The absolute position of the bone
  82765. */
  82766. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82767. /**
  82768. * Copy the absolute position of the bone (world space) to the result param
  82769. * @param mesh The mesh that this bone is attached to
  82770. * @param result The vector3 to copy the absolute position to
  82771. */
  82772. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82773. /**
  82774. * Compute the absolute transforms of this bone and its children
  82775. */
  82776. computeAbsoluteTransforms(): void;
  82777. /**
  82778. * Get the world direction from an axis that is in the local space of the bone
  82779. * @param localAxis The local direction that is used to compute the world direction
  82780. * @param mesh The mesh that this bone is attached to
  82781. * @returns The world direction
  82782. */
  82783. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82784. /**
  82785. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82786. * @param localAxis The local direction that is used to compute the world direction
  82787. * @param mesh The mesh that this bone is attached to
  82788. * @param result The vector3 that the world direction will be copied to
  82789. */
  82790. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82791. /**
  82792. * Get the euler rotation of the bone in local or world space
  82793. * @param space The space that the rotation should be in
  82794. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82795. * @returns The euler rotation
  82796. */
  82797. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82798. /**
  82799. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82800. * @param space The space that the rotation should be in
  82801. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82802. * @param result The vector3 that the rotation should be copied to
  82803. */
  82804. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82805. /**
  82806. * Get the quaternion rotation of the bone in either local or world space
  82807. * @param space The space that the rotation should be in
  82808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82809. * @returns The quaternion rotation
  82810. */
  82811. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82812. /**
  82813. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82814. * @param space The space that the rotation should be in
  82815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82816. * @param result The quaternion that the rotation should be copied to
  82817. */
  82818. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82819. /**
  82820. * Get the rotation matrix of the bone in local or world space
  82821. * @param space The space that the rotation should be in
  82822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82823. * @returns The rotation matrix
  82824. */
  82825. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82826. /**
  82827. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82828. * @param space The space that the rotation should be in
  82829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82830. * @param result The quaternion that the rotation should be copied to
  82831. */
  82832. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82833. /**
  82834. * Get the world position of a point that is in the local space of the bone
  82835. * @param position The local position
  82836. * @param mesh The mesh that this bone is attached to
  82837. * @returns The world position
  82838. */
  82839. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82840. /**
  82841. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82842. * @param position The local position
  82843. * @param mesh The mesh that this bone is attached to
  82844. * @param result The vector3 that the world position should be copied to
  82845. */
  82846. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82847. /**
  82848. * Get the local position of a point that is in world space
  82849. * @param position The world position
  82850. * @param mesh The mesh that this bone is attached to
  82851. * @returns The local position
  82852. */
  82853. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82854. /**
  82855. * Get the local position of a point that is in world space and copy it to the result param
  82856. * @param position The world position
  82857. * @param mesh The mesh that this bone is attached to
  82858. * @param result The vector3 that the local position should be copied to
  82859. */
  82860. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82861. }
  82862. }
  82863. declare module BABYLON {
  82864. /**
  82865. * 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.
  82866. * @see https://doc.babylonjs.com/how_to/transformnode
  82867. */
  82868. export class TransformNode extends Node {
  82869. /**
  82870. * Object will not rotate to face the camera
  82871. */
  82872. static BILLBOARDMODE_NONE: number;
  82873. /**
  82874. * Object will rotate to face the camera but only on the x axis
  82875. */
  82876. static BILLBOARDMODE_X: number;
  82877. /**
  82878. * Object will rotate to face the camera but only on the y axis
  82879. */
  82880. static BILLBOARDMODE_Y: number;
  82881. /**
  82882. * Object will rotate to face the camera but only on the z axis
  82883. */
  82884. static BILLBOARDMODE_Z: number;
  82885. /**
  82886. * Object will rotate to face the camera
  82887. */
  82888. static BILLBOARDMODE_ALL: number;
  82889. /**
  82890. * Object will rotate to face the camera's position instead of orientation
  82891. */
  82892. static BILLBOARDMODE_USE_POSITION: number;
  82893. private _forward;
  82894. private _forwardInverted;
  82895. private _up;
  82896. private _right;
  82897. private _rightInverted;
  82898. private _position;
  82899. private _rotation;
  82900. private _rotationQuaternion;
  82901. protected _scaling: Vector3;
  82902. protected _isDirty: boolean;
  82903. private _transformToBoneReferal;
  82904. private _isAbsoluteSynced;
  82905. private _billboardMode;
  82906. /**
  82907. * Gets or sets the billboard mode. Default is 0.
  82908. *
  82909. * | Value | Type | Description |
  82910. * | --- | --- | --- |
  82911. * | 0 | BILLBOARDMODE_NONE | |
  82912. * | 1 | BILLBOARDMODE_X | |
  82913. * | 2 | BILLBOARDMODE_Y | |
  82914. * | 4 | BILLBOARDMODE_Z | |
  82915. * | 7 | BILLBOARDMODE_ALL | |
  82916. *
  82917. */
  82918. billboardMode: number;
  82919. private _preserveParentRotationForBillboard;
  82920. /**
  82921. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82922. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82923. */
  82924. preserveParentRotationForBillboard: boolean;
  82925. /**
  82926. * 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
  82927. */
  82928. scalingDeterminant: number;
  82929. private _infiniteDistance;
  82930. /**
  82931. * Gets or sets the distance of the object to max, often used by skybox
  82932. */
  82933. infiniteDistance: boolean;
  82934. /**
  82935. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82936. * By default the system will update normals to compensate
  82937. */
  82938. ignoreNonUniformScaling: boolean;
  82939. /**
  82940. * 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
  82941. */
  82942. reIntegrateRotationIntoRotationQuaternion: boolean;
  82943. /** @hidden */
  82944. _poseMatrix: Nullable<Matrix>;
  82945. /** @hidden */
  82946. _localMatrix: Matrix;
  82947. private _usePivotMatrix;
  82948. private _absolutePosition;
  82949. private _absoluteScaling;
  82950. private _absoluteRotationQuaternion;
  82951. private _pivotMatrix;
  82952. private _pivotMatrixInverse;
  82953. protected _postMultiplyPivotMatrix: boolean;
  82954. protected _isWorldMatrixFrozen: boolean;
  82955. /** @hidden */
  82956. _indexInSceneTransformNodesArray: number;
  82957. /**
  82958. * An event triggered after the world matrix is updated
  82959. */
  82960. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82961. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82962. /**
  82963. * Gets a string identifying the name of the class
  82964. * @returns "TransformNode" string
  82965. */
  82966. getClassName(): string;
  82967. /**
  82968. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82969. */
  82970. position: Vector3;
  82971. /**
  82972. * 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)).
  82973. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82974. */
  82975. rotation: Vector3;
  82976. /**
  82977. * 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)).
  82978. */
  82979. scaling: Vector3;
  82980. /**
  82981. * 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).
  82982. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82983. */
  82984. rotationQuaternion: Nullable<Quaternion>;
  82985. /**
  82986. * The forward direction of that transform in world space.
  82987. */
  82988. readonly forward: Vector3;
  82989. /**
  82990. * The up direction of that transform in world space.
  82991. */
  82992. readonly up: Vector3;
  82993. /**
  82994. * The right direction of that transform in world space.
  82995. */
  82996. readonly right: Vector3;
  82997. /**
  82998. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82999. * @param matrix the matrix to copy the pose from
  83000. * @returns this TransformNode.
  83001. */
  83002. updatePoseMatrix(matrix: Matrix): TransformNode;
  83003. /**
  83004. * Returns the mesh Pose matrix.
  83005. * @returns the pose matrix
  83006. */
  83007. getPoseMatrix(): Matrix;
  83008. /** @hidden */
  83009. _isSynchronized(): boolean;
  83010. /** @hidden */
  83011. _initCache(): void;
  83012. /**
  83013. * Flag the transform node as dirty (Forcing it to update everything)
  83014. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83015. * @returns this transform node
  83016. */
  83017. markAsDirty(property: string): TransformNode;
  83018. /**
  83019. * Returns the current mesh absolute position.
  83020. * Returns a Vector3.
  83021. */
  83022. readonly absolutePosition: Vector3;
  83023. /**
  83024. * Returns the current mesh absolute scaling.
  83025. * Returns a Vector3.
  83026. */
  83027. readonly absoluteScaling: Vector3;
  83028. /**
  83029. * Returns the current mesh absolute rotation.
  83030. * Returns a Quaternion.
  83031. */
  83032. readonly absoluteRotationQuaternion: Quaternion;
  83033. /**
  83034. * Sets a new matrix to apply before all other transformation
  83035. * @param matrix defines the transform matrix
  83036. * @returns the current TransformNode
  83037. */
  83038. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83039. /**
  83040. * Sets a new pivot matrix to the current node
  83041. * @param matrix defines the new pivot matrix to use
  83042. * @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
  83043. * @returns the current TransformNode
  83044. */
  83045. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83046. /**
  83047. * Returns the mesh pivot matrix.
  83048. * Default : Identity.
  83049. * @returns the matrix
  83050. */
  83051. getPivotMatrix(): Matrix;
  83052. /**
  83053. * Instantiate (when possible) or clone that node with its hierarchy
  83054. * @param newParent defines the new parent to use for the instance (or clone)
  83055. * @param options defines options to configure how copy is done
  83056. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83057. * @returns an instance (or a clone) of the current node with its hiearchy
  83058. */
  83059. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83060. doNotInstantiate: boolean;
  83061. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83062. /**
  83063. * Prevents the World matrix to be computed any longer
  83064. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83065. * @returns the TransformNode.
  83066. */
  83067. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83068. /**
  83069. * Allows back the World matrix computation.
  83070. * @returns the TransformNode.
  83071. */
  83072. unfreezeWorldMatrix(): this;
  83073. /**
  83074. * True if the World matrix has been frozen.
  83075. */
  83076. readonly isWorldMatrixFrozen: boolean;
  83077. /**
  83078. * Retuns the mesh absolute position in the World.
  83079. * @returns a Vector3.
  83080. */
  83081. getAbsolutePosition(): Vector3;
  83082. /**
  83083. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83084. * @param absolutePosition the absolute position to set
  83085. * @returns the TransformNode.
  83086. */
  83087. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83088. /**
  83089. * Sets the mesh position in its local space.
  83090. * @param vector3 the position to set in localspace
  83091. * @returns the TransformNode.
  83092. */
  83093. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83094. /**
  83095. * Returns the mesh position in the local space from the current World matrix values.
  83096. * @returns a new Vector3.
  83097. */
  83098. getPositionExpressedInLocalSpace(): Vector3;
  83099. /**
  83100. * Translates the mesh along the passed Vector3 in its local space.
  83101. * @param vector3 the distance to translate in localspace
  83102. * @returns the TransformNode.
  83103. */
  83104. locallyTranslate(vector3: Vector3): TransformNode;
  83105. private static _lookAtVectorCache;
  83106. /**
  83107. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83108. * @param targetPoint the position (must be in same space as current mesh) to look at
  83109. * @param yawCor optional yaw (y-axis) correction in radians
  83110. * @param pitchCor optional pitch (x-axis) correction in radians
  83111. * @param rollCor optional roll (z-axis) correction in radians
  83112. * @param space the choosen space of the target
  83113. * @returns the TransformNode.
  83114. */
  83115. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83116. /**
  83117. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83118. * This Vector3 is expressed in the World space.
  83119. * @param localAxis axis to rotate
  83120. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83121. */
  83122. getDirection(localAxis: Vector3): Vector3;
  83123. /**
  83124. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83125. * localAxis is expressed in the mesh local space.
  83126. * result is computed in the Wordl space from the mesh World matrix.
  83127. * @param localAxis axis to rotate
  83128. * @param result the resulting transformnode
  83129. * @returns this TransformNode.
  83130. */
  83131. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83132. /**
  83133. * Sets this transform node rotation to the given local axis.
  83134. * @param localAxis the axis in local space
  83135. * @param yawCor optional yaw (y-axis) correction in radians
  83136. * @param pitchCor optional pitch (x-axis) correction in radians
  83137. * @param rollCor optional roll (z-axis) correction in radians
  83138. * @returns this TransformNode
  83139. */
  83140. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83141. /**
  83142. * Sets a new pivot point to the current node
  83143. * @param point defines the new pivot point to use
  83144. * @param space defines if the point is in world or local space (local by default)
  83145. * @returns the current TransformNode
  83146. */
  83147. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83148. /**
  83149. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83150. * @returns the pivot point
  83151. */
  83152. getPivotPoint(): Vector3;
  83153. /**
  83154. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83155. * @param result the vector3 to store the result
  83156. * @returns this TransformNode.
  83157. */
  83158. getPivotPointToRef(result: Vector3): TransformNode;
  83159. /**
  83160. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83161. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83162. */
  83163. getAbsolutePivotPoint(): Vector3;
  83164. /**
  83165. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83166. * @param result vector3 to store the result
  83167. * @returns this TransformNode.
  83168. */
  83169. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83170. /**
  83171. * Defines the passed node as the parent of the current node.
  83172. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83173. * @see https://doc.babylonjs.com/how_to/parenting
  83174. * @param node the node ot set as the parent
  83175. * @returns this TransformNode.
  83176. */
  83177. setParent(node: Nullable<Node>): TransformNode;
  83178. private _nonUniformScaling;
  83179. /**
  83180. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83181. */
  83182. readonly nonUniformScaling: boolean;
  83183. /** @hidden */
  83184. _updateNonUniformScalingState(value: boolean): boolean;
  83185. /**
  83186. * Attach the current TransformNode to another TransformNode associated with a bone
  83187. * @param bone Bone affecting the TransformNode
  83188. * @param affectedTransformNode TransformNode associated with the bone
  83189. * @returns this object
  83190. */
  83191. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83192. /**
  83193. * Detach the transform node if its associated with a bone
  83194. * @returns this object
  83195. */
  83196. detachFromBone(): TransformNode;
  83197. private static _rotationAxisCache;
  83198. /**
  83199. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83200. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83201. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83202. * The passed axis is also normalized.
  83203. * @param axis the axis to rotate around
  83204. * @param amount the amount to rotate in radians
  83205. * @param space Space to rotate in (Default: local)
  83206. * @returns the TransformNode.
  83207. */
  83208. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83209. /**
  83210. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83211. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83212. * The passed axis is also normalized. .
  83213. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83214. * @param point the point to rotate around
  83215. * @param axis the axis to rotate around
  83216. * @param amount the amount to rotate in radians
  83217. * @returns the TransformNode
  83218. */
  83219. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83220. /**
  83221. * Translates the mesh along the axis vector for the passed distance in the given space.
  83222. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83223. * @param axis the axis to translate in
  83224. * @param distance the distance to translate
  83225. * @param space Space to rotate in (Default: local)
  83226. * @returns the TransformNode.
  83227. */
  83228. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83229. /**
  83230. * Adds a rotation step to the mesh current rotation.
  83231. * x, y, z are Euler angles expressed in radians.
  83232. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83233. * This means this rotation is made in the mesh local space only.
  83234. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83235. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83236. * ```javascript
  83237. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83238. * ```
  83239. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83240. * 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.
  83241. * @param x Rotation to add
  83242. * @param y Rotation to add
  83243. * @param z Rotation to add
  83244. * @returns the TransformNode.
  83245. */
  83246. addRotation(x: number, y: number, z: number): TransformNode;
  83247. /**
  83248. * @hidden
  83249. */
  83250. protected _getEffectiveParent(): Nullable<Node>;
  83251. /**
  83252. * Computes the world matrix of the node
  83253. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83254. * @returns the world matrix
  83255. */
  83256. computeWorldMatrix(force?: boolean): Matrix;
  83257. protected _afterComputeWorldMatrix(): void;
  83258. /**
  83259. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83260. * @param func callback function to add
  83261. *
  83262. * @returns the TransformNode.
  83263. */
  83264. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83265. /**
  83266. * Removes a registered callback function.
  83267. * @param func callback function to remove
  83268. * @returns the TransformNode.
  83269. */
  83270. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83271. /**
  83272. * Gets the position of the current mesh in camera space
  83273. * @param camera defines the camera to use
  83274. * @returns a position
  83275. */
  83276. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83277. /**
  83278. * Returns the distance from the mesh to the active camera
  83279. * @param camera defines the camera to use
  83280. * @returns the distance
  83281. */
  83282. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83283. /**
  83284. * Clone the current transform node
  83285. * @param name Name of the new clone
  83286. * @param newParent New parent for the clone
  83287. * @param doNotCloneChildren Do not clone children hierarchy
  83288. * @returns the new transform node
  83289. */
  83290. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83291. /**
  83292. * Serializes the objects information.
  83293. * @param currentSerializationObject defines the object to serialize in
  83294. * @returns the serialized object
  83295. */
  83296. serialize(currentSerializationObject?: any): any;
  83297. /**
  83298. * Returns a new TransformNode object parsed from the source provided.
  83299. * @param parsedTransformNode is the source.
  83300. * @param scene the scne the object belongs to
  83301. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83302. * @returns a new TransformNode object parsed from the source provided.
  83303. */
  83304. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83305. /**
  83306. * Get all child-transformNodes of this node
  83307. * @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
  83308. * @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
  83309. * @returns an array of TransformNode
  83310. */
  83311. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83312. /**
  83313. * Releases resources associated with this transform node.
  83314. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83315. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83316. */
  83317. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83318. /**
  83319. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83320. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83321. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83322. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83323. * @returns the current mesh
  83324. */
  83325. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83326. private _syncAbsoluteScalingAndRotation;
  83327. }
  83328. }
  83329. declare module BABYLON {
  83330. /**
  83331. * Defines the types of pose enabled controllers that are supported
  83332. */
  83333. export enum PoseEnabledControllerType {
  83334. /**
  83335. * HTC Vive
  83336. */
  83337. VIVE = 0,
  83338. /**
  83339. * Oculus Rift
  83340. */
  83341. OCULUS = 1,
  83342. /**
  83343. * Windows mixed reality
  83344. */
  83345. WINDOWS = 2,
  83346. /**
  83347. * Samsung gear VR
  83348. */
  83349. GEAR_VR = 3,
  83350. /**
  83351. * Google Daydream
  83352. */
  83353. DAYDREAM = 4,
  83354. /**
  83355. * Generic
  83356. */
  83357. GENERIC = 5
  83358. }
  83359. /**
  83360. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83361. */
  83362. export interface MutableGamepadButton {
  83363. /**
  83364. * Value of the button/trigger
  83365. */
  83366. value: number;
  83367. /**
  83368. * If the button/trigger is currently touched
  83369. */
  83370. touched: boolean;
  83371. /**
  83372. * If the button/trigger is currently pressed
  83373. */
  83374. pressed: boolean;
  83375. }
  83376. /**
  83377. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83378. * @hidden
  83379. */
  83380. export interface ExtendedGamepadButton extends GamepadButton {
  83381. /**
  83382. * If the button/trigger is currently pressed
  83383. */
  83384. readonly pressed: boolean;
  83385. /**
  83386. * If the button/trigger is currently touched
  83387. */
  83388. readonly touched: boolean;
  83389. /**
  83390. * Value of the button/trigger
  83391. */
  83392. readonly value: number;
  83393. }
  83394. /** @hidden */
  83395. export interface _GamePadFactory {
  83396. /**
  83397. * Returns wether or not the current gamepad can be created for this type of controller.
  83398. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83399. * @returns true if it can be created, otherwise false
  83400. */
  83401. canCreate(gamepadInfo: any): boolean;
  83402. /**
  83403. * Creates a new instance of the Gamepad.
  83404. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83405. * @returns the new gamepad instance
  83406. */
  83407. create(gamepadInfo: any): Gamepad;
  83408. }
  83409. /**
  83410. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83411. */
  83412. export class PoseEnabledControllerHelper {
  83413. /** @hidden */
  83414. static _ControllerFactories: _GamePadFactory[];
  83415. /** @hidden */
  83416. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83417. /**
  83418. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83419. * @param vrGamepad the gamepad to initialized
  83420. * @returns a vr controller of the type the gamepad identified as
  83421. */
  83422. static InitiateController(vrGamepad: any): Gamepad;
  83423. }
  83424. /**
  83425. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83426. */
  83427. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83428. /**
  83429. * If the controller is used in a webXR session
  83430. */
  83431. isXR: boolean;
  83432. private _deviceRoomPosition;
  83433. private _deviceRoomRotationQuaternion;
  83434. /**
  83435. * The device position in babylon space
  83436. */
  83437. devicePosition: Vector3;
  83438. /**
  83439. * The device rotation in babylon space
  83440. */
  83441. deviceRotationQuaternion: Quaternion;
  83442. /**
  83443. * The scale factor of the device in babylon space
  83444. */
  83445. deviceScaleFactor: number;
  83446. /**
  83447. * (Likely devicePosition should be used instead) The device position in its room space
  83448. */
  83449. position: Vector3;
  83450. /**
  83451. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83452. */
  83453. rotationQuaternion: Quaternion;
  83454. /**
  83455. * The type of controller (Eg. Windows mixed reality)
  83456. */
  83457. controllerType: PoseEnabledControllerType;
  83458. protected _calculatedPosition: Vector3;
  83459. private _calculatedRotation;
  83460. /**
  83461. * The raw pose from the device
  83462. */
  83463. rawPose: DevicePose;
  83464. private _trackPosition;
  83465. private _maxRotationDistFromHeadset;
  83466. private _draggedRoomRotation;
  83467. /**
  83468. * @hidden
  83469. */
  83470. _disableTrackPosition(fixedPosition: Vector3): void;
  83471. /**
  83472. * Internal, the mesh attached to the controller
  83473. * @hidden
  83474. */
  83475. _mesh: Nullable<AbstractMesh>;
  83476. private _poseControlledCamera;
  83477. private _leftHandSystemQuaternion;
  83478. /**
  83479. * Internal, matrix used to convert room space to babylon space
  83480. * @hidden
  83481. */
  83482. _deviceToWorld: Matrix;
  83483. /**
  83484. * Node to be used when casting a ray from the controller
  83485. * @hidden
  83486. */
  83487. _pointingPoseNode: Nullable<TransformNode>;
  83488. /**
  83489. * Name of the child mesh that can be used to cast a ray from the controller
  83490. */
  83491. static readonly POINTING_POSE: string;
  83492. /**
  83493. * Creates a new PoseEnabledController from a gamepad
  83494. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83495. */
  83496. constructor(browserGamepad: any);
  83497. private _workingMatrix;
  83498. /**
  83499. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83500. */
  83501. update(): void;
  83502. /**
  83503. * Updates only the pose device and mesh without doing any button event checking
  83504. */
  83505. protected _updatePoseAndMesh(): void;
  83506. /**
  83507. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83508. * @param poseData raw pose fromthe device
  83509. */
  83510. updateFromDevice(poseData: DevicePose): void;
  83511. /**
  83512. * @hidden
  83513. */
  83514. _meshAttachedObservable: Observable<AbstractMesh>;
  83515. /**
  83516. * Attaches a mesh to the controller
  83517. * @param mesh the mesh to be attached
  83518. */
  83519. attachToMesh(mesh: AbstractMesh): void;
  83520. /**
  83521. * Attaches the controllers mesh to a camera
  83522. * @param camera the camera the mesh should be attached to
  83523. */
  83524. attachToPoseControlledCamera(camera: TargetCamera): void;
  83525. /**
  83526. * Disposes of the controller
  83527. */
  83528. dispose(): void;
  83529. /**
  83530. * The mesh that is attached to the controller
  83531. */
  83532. readonly mesh: Nullable<AbstractMesh>;
  83533. /**
  83534. * Gets the ray of the controller in the direction the controller is pointing
  83535. * @param length the length the resulting ray should be
  83536. * @returns a ray in the direction the controller is pointing
  83537. */
  83538. getForwardRay(length?: number): Ray;
  83539. }
  83540. }
  83541. declare module BABYLON {
  83542. /**
  83543. * Defines the WebVRController object that represents controllers tracked in 3D space
  83544. */
  83545. export abstract class WebVRController extends PoseEnabledController {
  83546. /**
  83547. * Internal, the default controller model for the controller
  83548. */
  83549. protected _defaultModel: Nullable<AbstractMesh>;
  83550. /**
  83551. * Fired when the trigger state has changed
  83552. */
  83553. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83554. /**
  83555. * Fired when the main button state has changed
  83556. */
  83557. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83558. /**
  83559. * Fired when the secondary button state has changed
  83560. */
  83561. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83562. /**
  83563. * Fired when the pad state has changed
  83564. */
  83565. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83566. /**
  83567. * Fired when controllers stick values have changed
  83568. */
  83569. onPadValuesChangedObservable: Observable<StickValues>;
  83570. /**
  83571. * Array of button availible on the controller
  83572. */
  83573. protected _buttons: Array<MutableGamepadButton>;
  83574. private _onButtonStateChange;
  83575. /**
  83576. * Fired when a controller button's state has changed
  83577. * @param callback the callback containing the button that was modified
  83578. */
  83579. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83580. /**
  83581. * X and Y axis corresponding to the controllers joystick
  83582. */
  83583. pad: StickValues;
  83584. /**
  83585. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83586. */
  83587. hand: string;
  83588. /**
  83589. * The default controller model for the controller
  83590. */
  83591. readonly defaultModel: Nullable<AbstractMesh>;
  83592. /**
  83593. * Creates a new WebVRController from a gamepad
  83594. * @param vrGamepad the gamepad that the WebVRController should be created from
  83595. */
  83596. constructor(vrGamepad: any);
  83597. /**
  83598. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83599. */
  83600. update(): void;
  83601. /**
  83602. * Function to be called when a button is modified
  83603. */
  83604. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83605. /**
  83606. * Loads a mesh and attaches it to the controller
  83607. * @param scene the scene the mesh should be added to
  83608. * @param meshLoaded callback for when the mesh has been loaded
  83609. */
  83610. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83611. private _setButtonValue;
  83612. private _changes;
  83613. private _checkChanges;
  83614. /**
  83615. * Disposes of th webVRCOntroller
  83616. */
  83617. dispose(): void;
  83618. }
  83619. }
  83620. declare module BABYLON {
  83621. /**
  83622. * The HemisphericLight simulates the ambient environment light,
  83623. * so the passed direction is the light reflection direction, not the incoming direction.
  83624. */
  83625. export class HemisphericLight extends Light {
  83626. /**
  83627. * The groundColor is the light in the opposite direction to the one specified during creation.
  83628. * 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.
  83629. */
  83630. groundColor: Color3;
  83631. /**
  83632. * The light reflection direction, not the incoming direction.
  83633. */
  83634. direction: Vector3;
  83635. /**
  83636. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83637. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83638. * The HemisphericLight can't cast shadows.
  83639. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83640. * @param name The friendly name of the light
  83641. * @param direction The direction of the light reflection
  83642. * @param scene The scene the light belongs to
  83643. */
  83644. constructor(name: string, direction: Vector3, scene: Scene);
  83645. protected _buildUniformLayout(): void;
  83646. /**
  83647. * Returns the string "HemisphericLight".
  83648. * @return The class name
  83649. */
  83650. getClassName(): string;
  83651. /**
  83652. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83653. * Returns the updated direction.
  83654. * @param target The target the direction should point to
  83655. * @return The computed direction
  83656. */
  83657. setDirectionToTarget(target: Vector3): Vector3;
  83658. /**
  83659. * Returns the shadow generator associated to the light.
  83660. * @returns Always null for hemispheric lights because it does not support shadows.
  83661. */
  83662. getShadowGenerator(): Nullable<IShadowGenerator>;
  83663. /**
  83664. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83665. * @param effect The effect to update
  83666. * @param lightIndex The index of the light in the effect to update
  83667. * @returns The hemispheric light
  83668. */
  83669. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83670. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83671. /**
  83672. * Computes the world matrix of the node
  83673. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83674. * @param useWasUpdatedFlag defines a reserved property
  83675. * @returns the world matrix
  83676. */
  83677. computeWorldMatrix(): Matrix;
  83678. /**
  83679. * Returns the integer 3.
  83680. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83681. */
  83682. getTypeID(): number;
  83683. /**
  83684. * Prepares the list of defines specific to the light type.
  83685. * @param defines the list of defines
  83686. * @param lightIndex defines the index of the light for the effect
  83687. */
  83688. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83689. }
  83690. }
  83691. declare module BABYLON {
  83692. /** @hidden */
  83693. export var vrMultiviewToSingleviewPixelShader: {
  83694. name: string;
  83695. shader: string;
  83696. };
  83697. }
  83698. declare module BABYLON {
  83699. /**
  83700. * Renders to multiple views with a single draw call
  83701. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83702. */
  83703. export class MultiviewRenderTarget extends RenderTargetTexture {
  83704. /**
  83705. * Creates a multiview render target
  83706. * @param scene scene used with the render target
  83707. * @param size the size of the render target (used for each view)
  83708. */
  83709. constructor(scene: Scene, size?: number | {
  83710. width: number;
  83711. height: number;
  83712. } | {
  83713. ratio: number;
  83714. });
  83715. /**
  83716. * @hidden
  83717. * @param faceIndex the face index, if its a cube texture
  83718. */
  83719. _bindFrameBuffer(faceIndex?: number): void;
  83720. /**
  83721. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83722. * @returns the view count
  83723. */
  83724. getViewCount(): number;
  83725. }
  83726. }
  83727. declare module BABYLON {
  83728. /**
  83729. * Represents a camera frustum
  83730. */
  83731. export class Frustum {
  83732. /**
  83733. * Gets the planes representing the frustum
  83734. * @param transform matrix to be applied to the returned planes
  83735. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83736. */
  83737. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83738. /**
  83739. * Gets the near frustum plane transformed by the transform matrix
  83740. * @param transform transformation matrix to be applied to the resulting frustum plane
  83741. * @param frustumPlane the resuling frustum plane
  83742. */
  83743. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83744. /**
  83745. * Gets the far frustum plane transformed by the transform matrix
  83746. * @param transform transformation matrix to be applied to the resulting frustum plane
  83747. * @param frustumPlane the resuling frustum plane
  83748. */
  83749. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83750. /**
  83751. * Gets the left frustum plane transformed by the transform matrix
  83752. * @param transform transformation matrix to be applied to the resulting frustum plane
  83753. * @param frustumPlane the resuling frustum plane
  83754. */
  83755. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83756. /**
  83757. * Gets the right frustum plane transformed by the transform matrix
  83758. * @param transform transformation matrix to be applied to the resulting frustum plane
  83759. * @param frustumPlane the resuling frustum plane
  83760. */
  83761. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83762. /**
  83763. * Gets the top frustum plane transformed by the transform matrix
  83764. * @param transform transformation matrix to be applied to the resulting frustum plane
  83765. * @param frustumPlane the resuling frustum plane
  83766. */
  83767. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83768. /**
  83769. * Gets the bottom frustum plane transformed by the transform matrix
  83770. * @param transform transformation matrix to be applied to the resulting frustum plane
  83771. * @param frustumPlane the resuling frustum plane
  83772. */
  83773. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83774. /**
  83775. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83776. * @param transform transformation matrix to be applied to the resulting frustum planes
  83777. * @param frustumPlanes the resuling frustum planes
  83778. */
  83779. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83780. }
  83781. }
  83782. declare module BABYLON {
  83783. interface Engine {
  83784. /**
  83785. * Creates a new multiview render target
  83786. * @param width defines the width of the texture
  83787. * @param height defines the height of the texture
  83788. * @returns the created multiview texture
  83789. */
  83790. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83791. /**
  83792. * Binds a multiview framebuffer to be drawn to
  83793. * @param multiviewTexture texture to bind
  83794. */
  83795. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83796. }
  83797. interface Camera {
  83798. /**
  83799. * @hidden
  83800. * 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)
  83801. */
  83802. _useMultiviewToSingleView: boolean;
  83803. /**
  83804. * @hidden
  83805. * 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)
  83806. */
  83807. _multiviewTexture: Nullable<RenderTargetTexture>;
  83808. /**
  83809. * @hidden
  83810. * ensures the multiview texture of the camera exists and has the specified width/height
  83811. * @param width height to set on the multiview texture
  83812. * @param height width to set on the multiview texture
  83813. */
  83814. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83815. }
  83816. interface Scene {
  83817. /** @hidden */
  83818. _transformMatrixR: Matrix;
  83819. /** @hidden */
  83820. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83821. /** @hidden */
  83822. _createMultiviewUbo(): void;
  83823. /** @hidden */
  83824. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83825. /** @hidden */
  83826. _renderMultiviewToSingleView(camera: Camera): void;
  83827. }
  83828. }
  83829. declare module BABYLON {
  83830. /**
  83831. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83832. * This will not be used for webXR as it supports displaying texture arrays directly
  83833. */
  83834. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83835. /**
  83836. * Initializes a VRMultiviewToSingleview
  83837. * @param name name of the post process
  83838. * @param camera camera to be applied to
  83839. * @param scaleFactor scaling factor to the size of the output texture
  83840. */
  83841. constructor(name: string, camera: Camera, scaleFactor: number);
  83842. }
  83843. }
  83844. declare module BABYLON {
  83845. /**
  83846. * Interface used to define additional presentation attributes
  83847. */
  83848. export interface IVRPresentationAttributes {
  83849. /**
  83850. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83851. */
  83852. highRefreshRate: boolean;
  83853. /**
  83854. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83855. */
  83856. foveationLevel: number;
  83857. }
  83858. interface Engine {
  83859. /** @hidden */
  83860. _vrDisplay: any;
  83861. /** @hidden */
  83862. _vrSupported: boolean;
  83863. /** @hidden */
  83864. _oldSize: Size;
  83865. /** @hidden */
  83866. _oldHardwareScaleFactor: number;
  83867. /** @hidden */
  83868. _vrExclusivePointerMode: boolean;
  83869. /** @hidden */
  83870. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83871. /** @hidden */
  83872. _onVRDisplayPointerRestricted: () => void;
  83873. /** @hidden */
  83874. _onVRDisplayPointerUnrestricted: () => void;
  83875. /** @hidden */
  83876. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83877. /** @hidden */
  83878. _onVrDisplayDisconnect: Nullable<() => void>;
  83879. /** @hidden */
  83880. _onVrDisplayPresentChange: Nullable<() => void>;
  83881. /**
  83882. * Observable signaled when VR display mode changes
  83883. */
  83884. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83885. /**
  83886. * Observable signaled when VR request present is complete
  83887. */
  83888. onVRRequestPresentComplete: Observable<boolean>;
  83889. /**
  83890. * Observable signaled when VR request present starts
  83891. */
  83892. onVRRequestPresentStart: Observable<Engine>;
  83893. /**
  83894. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83895. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83896. */
  83897. isInVRExclusivePointerMode: boolean;
  83898. /**
  83899. * Gets a boolean indicating if a webVR device was detected
  83900. * @returns true if a webVR device was detected
  83901. */
  83902. isVRDevicePresent(): boolean;
  83903. /**
  83904. * Gets the current webVR device
  83905. * @returns the current webVR device (or null)
  83906. */
  83907. getVRDevice(): any;
  83908. /**
  83909. * Initializes a webVR display and starts listening to display change events
  83910. * The onVRDisplayChangedObservable will be notified upon these changes
  83911. * @returns A promise containing a VRDisplay and if vr is supported
  83912. */
  83913. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83914. /** @hidden */
  83915. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83916. /**
  83917. * Gets or sets the presentation attributes used to configure VR rendering
  83918. */
  83919. vrPresentationAttributes?: IVRPresentationAttributes;
  83920. /**
  83921. * Call this function to switch to webVR mode
  83922. * Will do nothing if webVR is not supported or if there is no webVR device
  83923. * @param options the webvr options provided to the camera. mainly used for multiview
  83924. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83925. */
  83926. enableVR(options: WebVROptions): void;
  83927. /** @hidden */
  83928. _onVRFullScreenTriggered(): void;
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /**
  83933. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83934. * IMPORTANT!! The data is right-hand data.
  83935. * @export
  83936. * @interface DevicePose
  83937. */
  83938. export interface DevicePose {
  83939. /**
  83940. * The position of the device, values in array are [x,y,z].
  83941. */
  83942. readonly position: Nullable<Float32Array>;
  83943. /**
  83944. * The linearVelocity of the device, values in array are [x,y,z].
  83945. */
  83946. readonly linearVelocity: Nullable<Float32Array>;
  83947. /**
  83948. * The linearAcceleration of the device, values in array are [x,y,z].
  83949. */
  83950. readonly linearAcceleration: Nullable<Float32Array>;
  83951. /**
  83952. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83953. */
  83954. readonly orientation: Nullable<Float32Array>;
  83955. /**
  83956. * The angularVelocity of the device, values in array are [x,y,z].
  83957. */
  83958. readonly angularVelocity: Nullable<Float32Array>;
  83959. /**
  83960. * The angularAcceleration of the device, values in array are [x,y,z].
  83961. */
  83962. readonly angularAcceleration: Nullable<Float32Array>;
  83963. }
  83964. /**
  83965. * Interface representing a pose controlled object in Babylon.
  83966. * A pose controlled object has both regular pose values as well as pose values
  83967. * from an external device such as a VR head mounted display
  83968. */
  83969. export interface PoseControlled {
  83970. /**
  83971. * The position of the object in babylon space.
  83972. */
  83973. position: Vector3;
  83974. /**
  83975. * The rotation quaternion of the object in babylon space.
  83976. */
  83977. rotationQuaternion: Quaternion;
  83978. /**
  83979. * The position of the device in babylon space.
  83980. */
  83981. devicePosition?: Vector3;
  83982. /**
  83983. * The rotation quaternion of the device in babylon space.
  83984. */
  83985. deviceRotationQuaternion: Quaternion;
  83986. /**
  83987. * The raw pose coming from the device.
  83988. */
  83989. rawPose: Nullable<DevicePose>;
  83990. /**
  83991. * The scale of the device to be used when translating from device space to babylon space.
  83992. */
  83993. deviceScaleFactor: number;
  83994. /**
  83995. * Updates the poseControlled values based on the input device pose.
  83996. * @param poseData the pose data to update the object with
  83997. */
  83998. updateFromDevice(poseData: DevicePose): void;
  83999. }
  84000. /**
  84001. * Set of options to customize the webVRCamera
  84002. */
  84003. export interface WebVROptions {
  84004. /**
  84005. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84006. */
  84007. trackPosition?: boolean;
  84008. /**
  84009. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84010. */
  84011. positionScale?: number;
  84012. /**
  84013. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84014. */
  84015. displayName?: string;
  84016. /**
  84017. * Should the native controller meshes be initialized. (default: true)
  84018. */
  84019. controllerMeshes?: boolean;
  84020. /**
  84021. * Creating a default HemiLight only on controllers. (default: true)
  84022. */
  84023. defaultLightingOnControllers?: boolean;
  84024. /**
  84025. * If you don't want to use the default VR button of the helper. (default: false)
  84026. */
  84027. useCustomVRButton?: boolean;
  84028. /**
  84029. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84030. */
  84031. customVRButton?: HTMLButtonElement;
  84032. /**
  84033. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84034. */
  84035. rayLength?: number;
  84036. /**
  84037. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84038. */
  84039. defaultHeight?: number;
  84040. /**
  84041. * If multiview should be used if availible (default: false)
  84042. */
  84043. useMultiview?: boolean;
  84044. }
  84045. /**
  84046. * This represents a WebVR camera.
  84047. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84048. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84049. */
  84050. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84051. private webVROptions;
  84052. /**
  84053. * @hidden
  84054. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84055. */
  84056. _vrDevice: any;
  84057. /**
  84058. * The rawPose of the vrDevice.
  84059. */
  84060. rawPose: Nullable<DevicePose>;
  84061. private _onVREnabled;
  84062. private _specsVersion;
  84063. private _attached;
  84064. private _frameData;
  84065. protected _descendants: Array<Node>;
  84066. private _deviceRoomPosition;
  84067. /** @hidden */
  84068. _deviceRoomRotationQuaternion: Quaternion;
  84069. private _standingMatrix;
  84070. /**
  84071. * Represents device position in babylon space.
  84072. */
  84073. devicePosition: Vector3;
  84074. /**
  84075. * Represents device rotation in babylon space.
  84076. */
  84077. deviceRotationQuaternion: Quaternion;
  84078. /**
  84079. * The scale of the device to be used when translating from device space to babylon space.
  84080. */
  84081. deviceScaleFactor: number;
  84082. private _deviceToWorld;
  84083. private _worldToDevice;
  84084. /**
  84085. * References to the webVR controllers for the vrDevice.
  84086. */
  84087. controllers: Array<WebVRController>;
  84088. /**
  84089. * Emits an event when a controller is attached.
  84090. */
  84091. onControllersAttachedObservable: Observable<WebVRController[]>;
  84092. /**
  84093. * Emits an event when a controller's mesh has been loaded;
  84094. */
  84095. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84096. /**
  84097. * Emits an event when the HMD's pose has been updated.
  84098. */
  84099. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84100. private _poseSet;
  84101. /**
  84102. * If the rig cameras be used as parent instead of this camera.
  84103. */
  84104. rigParenting: boolean;
  84105. private _lightOnControllers;
  84106. private _defaultHeight?;
  84107. /**
  84108. * Instantiates a WebVRFreeCamera.
  84109. * @param name The name of the WebVRFreeCamera
  84110. * @param position The starting anchor position for the camera
  84111. * @param scene The scene the camera belongs to
  84112. * @param webVROptions a set of customizable options for the webVRCamera
  84113. */
  84114. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84115. /**
  84116. * Gets the device distance from the ground in meters.
  84117. * @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.
  84118. */
  84119. deviceDistanceToRoomGround(): number;
  84120. /**
  84121. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84122. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84123. */
  84124. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84125. /**
  84126. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84127. * @returns A promise with a boolean set to if the standing matrix is supported.
  84128. */
  84129. useStandingMatrixAsync(): Promise<boolean>;
  84130. /**
  84131. * Disposes the camera
  84132. */
  84133. dispose(): void;
  84134. /**
  84135. * Gets a vrController by name.
  84136. * @param name The name of the controller to retreive
  84137. * @returns the controller matching the name specified or null if not found
  84138. */
  84139. getControllerByName(name: string): Nullable<WebVRController>;
  84140. private _leftController;
  84141. /**
  84142. * The controller corresponding to the users left hand.
  84143. */
  84144. readonly leftController: Nullable<WebVRController>;
  84145. private _rightController;
  84146. /**
  84147. * The controller corresponding to the users right hand.
  84148. */
  84149. readonly rightController: Nullable<WebVRController>;
  84150. /**
  84151. * Casts a ray forward from the vrCamera's gaze.
  84152. * @param length Length of the ray (default: 100)
  84153. * @returns the ray corresponding to the gaze
  84154. */
  84155. getForwardRay(length?: number): Ray;
  84156. /**
  84157. * @hidden
  84158. * Updates the camera based on device's frame data
  84159. */
  84160. _checkInputs(): void;
  84161. /**
  84162. * Updates the poseControlled values based on the input device pose.
  84163. * @param poseData Pose coming from the device
  84164. */
  84165. updateFromDevice(poseData: DevicePose): void;
  84166. private _htmlElementAttached;
  84167. private _detachIfAttached;
  84168. /**
  84169. * WebVR's attach control will start broadcasting frames to the device.
  84170. * Note that in certain browsers (chrome for example) this function must be called
  84171. * within a user-interaction callback. Example:
  84172. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84173. *
  84174. * @param element html element to attach the vrDevice to
  84175. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84176. */
  84177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84178. /**
  84179. * Detaches the camera from the html element and disables VR
  84180. *
  84181. * @param element html element to detach from
  84182. */
  84183. detachControl(element: HTMLElement): void;
  84184. /**
  84185. * @returns the name of this class
  84186. */
  84187. getClassName(): string;
  84188. /**
  84189. * Calls resetPose on the vrDisplay
  84190. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84191. */
  84192. resetToCurrentRotation(): void;
  84193. /**
  84194. * @hidden
  84195. * Updates the rig cameras (left and right eye)
  84196. */
  84197. _updateRigCameras(): void;
  84198. private _workingVector;
  84199. private _oneVector;
  84200. private _workingMatrix;
  84201. private updateCacheCalled;
  84202. private _correctPositionIfNotTrackPosition;
  84203. /**
  84204. * @hidden
  84205. * Updates the cached values of the camera
  84206. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84207. */
  84208. _updateCache(ignoreParentClass?: boolean): void;
  84209. /**
  84210. * @hidden
  84211. * Get current device position in babylon world
  84212. */
  84213. _computeDevicePosition(): void;
  84214. /**
  84215. * Updates the current device position and rotation in the babylon world
  84216. */
  84217. update(): void;
  84218. /**
  84219. * @hidden
  84220. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84221. * @returns an identity matrix
  84222. */
  84223. _getViewMatrix(): Matrix;
  84224. private _tmpMatrix;
  84225. /**
  84226. * This function is called by the two RIG cameras.
  84227. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84228. * @hidden
  84229. */
  84230. _getWebVRViewMatrix(): Matrix;
  84231. /** @hidden */
  84232. _getWebVRProjectionMatrix(): Matrix;
  84233. private _onGamepadConnectedObserver;
  84234. private _onGamepadDisconnectedObserver;
  84235. private _updateCacheWhenTrackingDisabledObserver;
  84236. /**
  84237. * Initializes the controllers and their meshes
  84238. */
  84239. initControllers(): void;
  84240. }
  84241. }
  84242. declare module BABYLON {
  84243. /**
  84244. * Size options for a post process
  84245. */
  84246. export type PostProcessOptions = {
  84247. width: number;
  84248. height: number;
  84249. };
  84250. /**
  84251. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84252. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84253. */
  84254. export class PostProcess {
  84255. /** Name of the PostProcess. */
  84256. name: string;
  84257. /**
  84258. * Gets or sets the unique id of the post process
  84259. */
  84260. uniqueId: number;
  84261. /**
  84262. * Width of the texture to apply the post process on
  84263. */
  84264. width: number;
  84265. /**
  84266. * Height of the texture to apply the post process on
  84267. */
  84268. height: number;
  84269. /**
  84270. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84271. * @hidden
  84272. */
  84273. _outputTexture: Nullable<InternalTexture>;
  84274. /**
  84275. * Sampling mode used by the shader
  84276. * See https://doc.babylonjs.com/classes/3.1/texture
  84277. */
  84278. renderTargetSamplingMode: number;
  84279. /**
  84280. * Clear color to use when screen clearing
  84281. */
  84282. clearColor: Color4;
  84283. /**
  84284. * If the buffer needs to be cleared before applying the post process. (default: true)
  84285. * Should be set to false if shader will overwrite all previous pixels.
  84286. */
  84287. autoClear: boolean;
  84288. /**
  84289. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84290. */
  84291. alphaMode: number;
  84292. /**
  84293. * Sets the setAlphaBlendConstants of the babylon engine
  84294. */
  84295. alphaConstants: Color4;
  84296. /**
  84297. * Animations to be used for the post processing
  84298. */
  84299. animations: Animation[];
  84300. /**
  84301. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84302. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84303. */
  84304. enablePixelPerfectMode: boolean;
  84305. /**
  84306. * Force the postprocess to be applied without taking in account viewport
  84307. */
  84308. forceFullscreenViewport: boolean;
  84309. /**
  84310. * List of inspectable custom properties (used by the Inspector)
  84311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84312. */
  84313. inspectableCustomProperties: IInspectable[];
  84314. /**
  84315. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84316. *
  84317. * | Value | Type | Description |
  84318. * | ----- | ----------------------------------- | ----------- |
  84319. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84320. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84321. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84322. *
  84323. */
  84324. scaleMode: number;
  84325. /**
  84326. * Force textures to be a power of two (default: false)
  84327. */
  84328. alwaysForcePOT: boolean;
  84329. private _samples;
  84330. /**
  84331. * Number of sample textures (default: 1)
  84332. */
  84333. samples: number;
  84334. /**
  84335. * Modify the scale of the post process to be the same as the viewport (default: false)
  84336. */
  84337. adaptScaleToCurrentViewport: boolean;
  84338. private _camera;
  84339. private _scene;
  84340. private _engine;
  84341. private _options;
  84342. private _reusable;
  84343. private _textureType;
  84344. /**
  84345. * Smart array of input and output textures for the post process.
  84346. * @hidden
  84347. */
  84348. _textures: SmartArray<InternalTexture>;
  84349. /**
  84350. * The index in _textures that corresponds to the output texture.
  84351. * @hidden
  84352. */
  84353. _currentRenderTextureInd: number;
  84354. private _effect;
  84355. private _samplers;
  84356. private _fragmentUrl;
  84357. private _vertexUrl;
  84358. private _parameters;
  84359. private _scaleRatio;
  84360. protected _indexParameters: any;
  84361. private _shareOutputWithPostProcess;
  84362. private _texelSize;
  84363. private _forcedOutputTexture;
  84364. /**
  84365. * Returns the fragment url or shader name used in the post process.
  84366. * @returns the fragment url or name in the shader store.
  84367. */
  84368. getEffectName(): string;
  84369. /**
  84370. * An event triggered when the postprocess is activated.
  84371. */
  84372. onActivateObservable: Observable<Camera>;
  84373. private _onActivateObserver;
  84374. /**
  84375. * A function that is added to the onActivateObservable
  84376. */
  84377. onActivate: Nullable<(camera: Camera) => void>;
  84378. /**
  84379. * An event triggered when the postprocess changes its size.
  84380. */
  84381. onSizeChangedObservable: Observable<PostProcess>;
  84382. private _onSizeChangedObserver;
  84383. /**
  84384. * A function that is added to the onSizeChangedObservable
  84385. */
  84386. onSizeChanged: (postProcess: PostProcess) => void;
  84387. /**
  84388. * An event triggered when the postprocess applies its effect.
  84389. */
  84390. onApplyObservable: Observable<Effect>;
  84391. private _onApplyObserver;
  84392. /**
  84393. * A function that is added to the onApplyObservable
  84394. */
  84395. onApply: (effect: Effect) => void;
  84396. /**
  84397. * An event triggered before rendering the postprocess
  84398. */
  84399. onBeforeRenderObservable: Observable<Effect>;
  84400. private _onBeforeRenderObserver;
  84401. /**
  84402. * A function that is added to the onBeforeRenderObservable
  84403. */
  84404. onBeforeRender: (effect: Effect) => void;
  84405. /**
  84406. * An event triggered after rendering the postprocess
  84407. */
  84408. onAfterRenderObservable: Observable<Effect>;
  84409. private _onAfterRenderObserver;
  84410. /**
  84411. * A function that is added to the onAfterRenderObservable
  84412. */
  84413. onAfterRender: (efect: Effect) => void;
  84414. /**
  84415. * 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
  84416. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84417. */
  84418. inputTexture: InternalTexture;
  84419. /**
  84420. * Gets the camera which post process is applied to.
  84421. * @returns The camera the post process is applied to.
  84422. */
  84423. getCamera(): Camera;
  84424. /**
  84425. * Gets the texel size of the postprocess.
  84426. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84427. */
  84428. readonly texelSize: Vector2;
  84429. /**
  84430. * Creates a new instance PostProcess
  84431. * @param name The name of the PostProcess.
  84432. * @param fragmentUrl The url of the fragment shader to be used.
  84433. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84434. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84435. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84436. * @param camera The camera to apply the render pass to.
  84437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84438. * @param engine The engine which the post process will be applied. (default: current engine)
  84439. * @param reusable If the post process can be reused on the same frame. (default: false)
  84440. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84441. * @param textureType Type of textures used when performing the post process. (default: 0)
  84442. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84443. * @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
  84444. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84445. */
  84446. constructor(
  84447. /** Name of the PostProcess. */
  84448. 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);
  84449. /**
  84450. * Gets a string idenfifying the name of the class
  84451. * @returns "PostProcess" string
  84452. */
  84453. getClassName(): string;
  84454. /**
  84455. * Gets the engine which this post process belongs to.
  84456. * @returns The engine the post process was enabled with.
  84457. */
  84458. getEngine(): Engine;
  84459. /**
  84460. * The effect that is created when initializing the post process.
  84461. * @returns The created effect corresponding the the postprocess.
  84462. */
  84463. getEffect(): Effect;
  84464. /**
  84465. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84466. * @param postProcess The post process to share the output with.
  84467. * @returns This post process.
  84468. */
  84469. shareOutputWith(postProcess: PostProcess): PostProcess;
  84470. /**
  84471. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84472. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84473. */
  84474. useOwnOutput(): void;
  84475. /**
  84476. * Updates the effect with the current post process compile time values and recompiles the shader.
  84477. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84478. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84479. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84480. * @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
  84481. * @param onCompiled Called when the shader has been compiled.
  84482. * @param onError Called if there is an error when compiling a shader.
  84483. */
  84484. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84485. /**
  84486. * The post process is reusable if it can be used multiple times within one frame.
  84487. * @returns If the post process is reusable
  84488. */
  84489. isReusable(): boolean;
  84490. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84491. markTextureDirty(): void;
  84492. /**
  84493. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84494. * 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.
  84495. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84496. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84497. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84498. * @returns The target texture that was bound to be written to.
  84499. */
  84500. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84501. /**
  84502. * If the post process is supported.
  84503. */
  84504. readonly isSupported: boolean;
  84505. /**
  84506. * The aspect ratio of the output texture.
  84507. */
  84508. readonly aspectRatio: number;
  84509. /**
  84510. * Get a value indicating if the post-process is ready to be used
  84511. * @returns true if the post-process is ready (shader is compiled)
  84512. */
  84513. isReady(): boolean;
  84514. /**
  84515. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84516. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84517. */
  84518. apply(): Nullable<Effect>;
  84519. private _disposeTextures;
  84520. /**
  84521. * Disposes the post process.
  84522. * @param camera The camera to dispose the post process on.
  84523. */
  84524. dispose(camera?: Camera): void;
  84525. }
  84526. }
  84527. declare module BABYLON {
  84528. /** @hidden */
  84529. export var kernelBlurVaryingDeclaration: {
  84530. name: string;
  84531. shader: string;
  84532. };
  84533. }
  84534. declare module BABYLON {
  84535. /** @hidden */
  84536. export var kernelBlurFragment: {
  84537. name: string;
  84538. shader: string;
  84539. };
  84540. }
  84541. declare module BABYLON {
  84542. /** @hidden */
  84543. export var kernelBlurFragment2: {
  84544. name: string;
  84545. shader: string;
  84546. };
  84547. }
  84548. declare module BABYLON {
  84549. /** @hidden */
  84550. export var kernelBlurPixelShader: {
  84551. name: string;
  84552. shader: string;
  84553. };
  84554. }
  84555. declare module BABYLON {
  84556. /** @hidden */
  84557. export var kernelBlurVertex: {
  84558. name: string;
  84559. shader: string;
  84560. };
  84561. }
  84562. declare module BABYLON {
  84563. /** @hidden */
  84564. export var kernelBlurVertexShader: {
  84565. name: string;
  84566. shader: string;
  84567. };
  84568. }
  84569. declare module BABYLON {
  84570. /**
  84571. * The Blur Post Process which blurs an image based on a kernel and direction.
  84572. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84573. */
  84574. export class BlurPostProcess extends PostProcess {
  84575. /** The direction in which to blur the image. */
  84576. direction: Vector2;
  84577. private blockCompilation;
  84578. protected _kernel: number;
  84579. protected _idealKernel: number;
  84580. protected _packedFloat: boolean;
  84581. private _staticDefines;
  84582. /**
  84583. * Sets the length in pixels of the blur sample region
  84584. */
  84585. /**
  84586. * Gets the length in pixels of the blur sample region
  84587. */
  84588. kernel: number;
  84589. /**
  84590. * Sets wether or not the blur needs to unpack/repack floats
  84591. */
  84592. /**
  84593. * Gets wether or not the blur is unpacking/repacking floats
  84594. */
  84595. packedFloat: boolean;
  84596. /**
  84597. * Creates a new instance BlurPostProcess
  84598. * @param name The name of the effect.
  84599. * @param direction The direction in which to blur the image.
  84600. * @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.
  84601. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84602. * @param camera The camera to apply the render pass to.
  84603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84604. * @param engine The engine which the post process will be applied. (default: current engine)
  84605. * @param reusable If the post process can be reused on the same frame. (default: false)
  84606. * @param textureType Type of textures used when performing the post process. (default: 0)
  84607. * @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)
  84608. */
  84609. constructor(name: string,
  84610. /** The direction in which to blur the image. */
  84611. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84612. /**
  84613. * Updates the effect with the current post process compile time values and recompiles the shader.
  84614. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84615. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84616. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84617. * @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
  84618. * @param onCompiled Called when the shader has been compiled.
  84619. * @param onError Called if there is an error when compiling a shader.
  84620. */
  84621. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84622. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84623. /**
  84624. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84625. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84626. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84627. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84628. * The gaps between physical kernels are compensated for in the weighting of the samples
  84629. * @param idealKernel Ideal blur kernel.
  84630. * @return Nearest best kernel.
  84631. */
  84632. protected _nearestBestKernel(idealKernel: number): number;
  84633. /**
  84634. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84635. * @param x The point on the Gaussian distribution to sample.
  84636. * @return the value of the Gaussian function at x.
  84637. */
  84638. protected _gaussianWeight(x: number): number;
  84639. /**
  84640. * Generates a string that can be used as a floating point number in GLSL.
  84641. * @param x Value to print.
  84642. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84643. * @return GLSL float string.
  84644. */
  84645. protected _glslFloat(x: number, decimalFigures?: number): string;
  84646. }
  84647. }
  84648. declare module BABYLON {
  84649. /**
  84650. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84651. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84652. * You can then easily use it as a reflectionTexture on a flat surface.
  84653. * In case the surface is not a plane, please consider relying on reflection probes.
  84654. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84655. */
  84656. export class MirrorTexture extends RenderTargetTexture {
  84657. private scene;
  84658. /**
  84659. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84660. * 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.
  84661. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84662. */
  84663. mirrorPlane: Plane;
  84664. /**
  84665. * Define the blur ratio used to blur the reflection if needed.
  84666. */
  84667. blurRatio: number;
  84668. /**
  84669. * Define the adaptive blur kernel used to blur the reflection if needed.
  84670. * This will autocompute the closest best match for the `blurKernel`
  84671. */
  84672. adaptiveBlurKernel: number;
  84673. /**
  84674. * Define the blur kernel used to blur the reflection if needed.
  84675. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84676. */
  84677. blurKernel: number;
  84678. /**
  84679. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84680. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84681. */
  84682. blurKernelX: number;
  84683. /**
  84684. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84685. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84686. */
  84687. blurKernelY: number;
  84688. private _autoComputeBlurKernel;
  84689. protected _onRatioRescale(): void;
  84690. private _updateGammaSpace;
  84691. private _imageProcessingConfigChangeObserver;
  84692. private _transformMatrix;
  84693. private _mirrorMatrix;
  84694. private _savedViewMatrix;
  84695. private _blurX;
  84696. private _blurY;
  84697. private _adaptiveBlurKernel;
  84698. private _blurKernelX;
  84699. private _blurKernelY;
  84700. private _blurRatio;
  84701. /**
  84702. * Instantiates a Mirror Texture.
  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. * @param name
  84709. * @param size
  84710. * @param scene
  84711. * @param generateMipMaps
  84712. * @param type
  84713. * @param samplingMode
  84714. * @param generateDepthBuffer
  84715. */
  84716. constructor(name: string, size: number | {
  84717. width: number;
  84718. height: number;
  84719. } | {
  84720. ratio: number;
  84721. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84722. private _preparePostProcesses;
  84723. /**
  84724. * Clone the mirror texture.
  84725. * @returns the cloned texture
  84726. */
  84727. clone(): MirrorTexture;
  84728. /**
  84729. * Serialize the texture to a JSON representation you could use in Parse later on
  84730. * @returns the serialized JSON representation
  84731. */
  84732. serialize(): any;
  84733. /**
  84734. * Dispose the texture and release its associated resources.
  84735. */
  84736. dispose(): void;
  84737. }
  84738. }
  84739. declare module BABYLON {
  84740. /**
  84741. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84742. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84743. */
  84744. export class Texture extends BaseTexture {
  84745. /**
  84746. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84747. */
  84748. static SerializeBuffers: boolean;
  84749. /** @hidden */
  84750. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84751. /** @hidden */
  84752. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84753. /** @hidden */
  84754. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84755. /** nearest is mag = nearest and min = nearest and mip = linear */
  84756. static readonly NEAREST_SAMPLINGMODE: number;
  84757. /** nearest is mag = nearest and min = nearest and mip = linear */
  84758. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84760. static readonly BILINEAR_SAMPLINGMODE: number;
  84761. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84762. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84763. /** Trilinear is mag = linear and min = linear and mip = linear */
  84764. static readonly TRILINEAR_SAMPLINGMODE: number;
  84765. /** Trilinear is mag = linear and min = linear and mip = linear */
  84766. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84767. /** mag = nearest and min = nearest and mip = nearest */
  84768. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84769. /** mag = nearest and min = linear and mip = nearest */
  84770. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84771. /** mag = nearest and min = linear and mip = linear */
  84772. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84773. /** mag = nearest and min = linear and mip = none */
  84774. static readonly NEAREST_LINEAR: number;
  84775. /** mag = nearest and min = nearest and mip = none */
  84776. static readonly NEAREST_NEAREST: number;
  84777. /** mag = linear and min = nearest and mip = nearest */
  84778. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84779. /** mag = linear and min = nearest and mip = linear */
  84780. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84781. /** mag = linear and min = linear and mip = none */
  84782. static readonly LINEAR_LINEAR: number;
  84783. /** mag = linear and min = nearest and mip = none */
  84784. static readonly LINEAR_NEAREST: number;
  84785. /** Explicit coordinates mode */
  84786. static readonly EXPLICIT_MODE: number;
  84787. /** Spherical coordinates mode */
  84788. static readonly SPHERICAL_MODE: number;
  84789. /** Planar coordinates mode */
  84790. static readonly PLANAR_MODE: number;
  84791. /** Cubic coordinates mode */
  84792. static readonly CUBIC_MODE: number;
  84793. /** Projection coordinates mode */
  84794. static readonly PROJECTION_MODE: number;
  84795. /** Inverse Cubic coordinates mode */
  84796. static readonly SKYBOX_MODE: number;
  84797. /** Inverse Cubic coordinates mode */
  84798. static readonly INVCUBIC_MODE: number;
  84799. /** Equirectangular coordinates mode */
  84800. static readonly EQUIRECTANGULAR_MODE: number;
  84801. /** Equirectangular Fixed coordinates mode */
  84802. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84803. /** Equirectangular Fixed Mirrored coordinates mode */
  84804. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84805. /** Texture is not repeating outside of 0..1 UVs */
  84806. static readonly CLAMP_ADDRESSMODE: number;
  84807. /** Texture is repeating outside of 0..1 UVs */
  84808. static readonly WRAP_ADDRESSMODE: number;
  84809. /** Texture is repeating and mirrored */
  84810. static readonly MIRROR_ADDRESSMODE: number;
  84811. /**
  84812. * 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
  84813. */
  84814. static UseSerializedUrlIfAny: boolean;
  84815. /**
  84816. * Define the url of the texture.
  84817. */
  84818. url: Nullable<string>;
  84819. /**
  84820. * Define an offset on the texture to offset the u coordinates of the UVs
  84821. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84822. */
  84823. uOffset: number;
  84824. /**
  84825. * Define an offset on the texture to offset the v coordinates of the UVs
  84826. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84827. */
  84828. vOffset: number;
  84829. /**
  84830. * Define an offset on the texture to scale the u coordinates of the UVs
  84831. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84832. */
  84833. uScale: number;
  84834. /**
  84835. * Define an offset on the texture to scale the v coordinates of the UVs
  84836. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84837. */
  84838. vScale: number;
  84839. /**
  84840. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84841. * @see http://doc.babylonjs.com/how_to/more_materials
  84842. */
  84843. uAng: number;
  84844. /**
  84845. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84846. * @see http://doc.babylonjs.com/how_to/more_materials
  84847. */
  84848. vAng: number;
  84849. /**
  84850. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84851. * @see http://doc.babylonjs.com/how_to/more_materials
  84852. */
  84853. wAng: number;
  84854. /**
  84855. * Defines the center of rotation (U)
  84856. */
  84857. uRotationCenter: number;
  84858. /**
  84859. * Defines the center of rotation (V)
  84860. */
  84861. vRotationCenter: number;
  84862. /**
  84863. * Defines the center of rotation (W)
  84864. */
  84865. wRotationCenter: number;
  84866. /**
  84867. * Are mip maps generated for this texture or not.
  84868. */
  84869. readonly noMipmap: boolean;
  84870. /**
  84871. * List of inspectable custom properties (used by the Inspector)
  84872. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84873. */
  84874. inspectableCustomProperties: Nullable<IInspectable[]>;
  84875. private _noMipmap;
  84876. /** @hidden */
  84877. _invertY: boolean;
  84878. private _rowGenerationMatrix;
  84879. private _cachedTextureMatrix;
  84880. private _projectionModeMatrix;
  84881. private _t0;
  84882. private _t1;
  84883. private _t2;
  84884. private _cachedUOffset;
  84885. private _cachedVOffset;
  84886. private _cachedUScale;
  84887. private _cachedVScale;
  84888. private _cachedUAng;
  84889. private _cachedVAng;
  84890. private _cachedWAng;
  84891. private _cachedProjectionMatrixId;
  84892. private _cachedCoordinatesMode;
  84893. /** @hidden */
  84894. protected _initialSamplingMode: number;
  84895. /** @hidden */
  84896. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84897. private _deleteBuffer;
  84898. protected _format: Nullable<number>;
  84899. private _delayedOnLoad;
  84900. private _delayedOnError;
  84901. private _mimeType?;
  84902. /**
  84903. * Observable triggered once the texture has been loaded.
  84904. */
  84905. onLoadObservable: Observable<Texture>;
  84906. protected _isBlocking: boolean;
  84907. /**
  84908. * Is the texture preventing material to render while loading.
  84909. * If false, a default texture will be used instead of the loading one during the preparation step.
  84910. */
  84911. isBlocking: boolean;
  84912. /**
  84913. * Get the current sampling mode associated with the texture.
  84914. */
  84915. readonly samplingMode: number;
  84916. /**
  84917. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84918. */
  84919. readonly invertY: boolean;
  84920. /**
  84921. * Instantiates a new texture.
  84922. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84923. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84924. * @param url defines the url of the picture to load as a texture
  84925. * @param scene defines the scene or engine the texture will belong to
  84926. * @param noMipmap defines if the texture will require mip maps or not
  84927. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84928. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84929. * @param onLoad defines a callback triggered when the texture has been loaded
  84930. * @param onError defines a callback triggered when an error occurred during the loading session
  84931. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84932. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84933. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84934. * @param mimeType defines an optional mime type information
  84935. */
  84936. 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);
  84937. /**
  84938. * Update the url (and optional buffer) of this texture if url was null during construction.
  84939. * @param url the url of the texture
  84940. * @param buffer the buffer of the texture (defaults to null)
  84941. * @param onLoad callback called when the texture is loaded (defaults to null)
  84942. */
  84943. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84944. /**
  84945. * Finish the loading sequence of a texture flagged as delayed load.
  84946. * @hidden
  84947. */
  84948. delayLoad(): void;
  84949. private _prepareRowForTextureGeneration;
  84950. /**
  84951. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84952. * @returns the transform matrix of the texture.
  84953. */
  84954. getTextureMatrix(uBase?: number): Matrix;
  84955. /**
  84956. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84957. * @returns The reflection texture transform
  84958. */
  84959. getReflectionTextureMatrix(): Matrix;
  84960. /**
  84961. * Clones the texture.
  84962. * @returns the cloned texture
  84963. */
  84964. clone(): Texture;
  84965. /**
  84966. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84967. * @returns The JSON representation of the texture
  84968. */
  84969. serialize(): any;
  84970. /**
  84971. * Get the current class name of the texture useful for serialization or dynamic coding.
  84972. * @returns "Texture"
  84973. */
  84974. getClassName(): string;
  84975. /**
  84976. * Dispose the texture and release its associated resources.
  84977. */
  84978. dispose(): void;
  84979. /**
  84980. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84981. * @param parsedTexture Define the JSON representation of the texture
  84982. * @param scene Define the scene the parsed texture should be instantiated in
  84983. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84984. * @returns The parsed texture if successful
  84985. */
  84986. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84987. /**
  84988. * Creates a texture from its base 64 representation.
  84989. * @param data Define the base64 payload without the data: prefix
  84990. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84991. * @param scene Define the scene the texture should belong to
  84992. * @param noMipmap Forces the texture to not create mip map information if true
  84993. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84994. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84995. * @param onLoad define a callback triggered when the texture has been loaded
  84996. * @param onError define a callback triggered when an error occurred during the loading session
  84997. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84998. * @returns the created texture
  84999. */
  85000. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85001. /**
  85002. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85003. * @param data Define the base64 payload without the data: prefix
  85004. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85005. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85006. * @param scene Define the scene the texture should belong to
  85007. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85008. * @param noMipmap Forces the texture to not create mip map information if true
  85009. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85010. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85011. * @param onLoad define a callback triggered when the texture has been loaded
  85012. * @param onError define a callback triggered when an error occurred during the loading session
  85013. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85014. * @returns the created texture
  85015. */
  85016. 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;
  85017. }
  85018. }
  85019. declare module BABYLON {
  85020. /**
  85021. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85022. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85023. */
  85024. export class PostProcessManager {
  85025. private _scene;
  85026. private _indexBuffer;
  85027. private _vertexBuffers;
  85028. /**
  85029. * Creates a new instance PostProcess
  85030. * @param scene The scene that the post process is associated with.
  85031. */
  85032. constructor(scene: Scene);
  85033. private _prepareBuffers;
  85034. private _buildIndexBuffer;
  85035. /**
  85036. * Rebuilds the vertex buffers of the manager.
  85037. * @hidden
  85038. */
  85039. _rebuild(): void;
  85040. /**
  85041. * Prepares a frame to be run through a post process.
  85042. * @param sourceTexture The input texture to the post procesess. (default: null)
  85043. * @param postProcesses An array of post processes to be run. (default: null)
  85044. * @returns True if the post processes were able to be run.
  85045. * @hidden
  85046. */
  85047. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85048. /**
  85049. * Manually render a set of post processes to a texture.
  85050. * @param postProcesses An array of post processes to be run.
  85051. * @param targetTexture The target texture to render to.
  85052. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85053. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85054. * @param lodLevel defines which lod of the texture to render to
  85055. */
  85056. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85057. /**
  85058. * Finalize the result of the output of the postprocesses.
  85059. * @param doNotPresent If true the result will not be displayed to the screen.
  85060. * @param targetTexture The target texture to render to.
  85061. * @param faceIndex The index of the face to bind the target texture to.
  85062. * @param postProcesses The array of post processes to render.
  85063. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85064. * @hidden
  85065. */
  85066. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85067. /**
  85068. * Disposes of the post process manager.
  85069. */
  85070. dispose(): void;
  85071. }
  85072. }
  85073. declare module BABYLON {
  85074. /** Interface used by value gradients (color, factor, ...) */
  85075. export interface IValueGradient {
  85076. /**
  85077. * Gets or sets the gradient value (between 0 and 1)
  85078. */
  85079. gradient: number;
  85080. }
  85081. /** Class used to store color4 gradient */
  85082. export class ColorGradient implements IValueGradient {
  85083. /**
  85084. * Gets or sets the gradient value (between 0 and 1)
  85085. */
  85086. gradient: number;
  85087. /**
  85088. * Gets or sets first associated color
  85089. */
  85090. color1: Color4;
  85091. /**
  85092. * Gets or sets second associated color
  85093. */
  85094. color2?: Color4;
  85095. /**
  85096. * Will get a color picked randomly between color1 and color2.
  85097. * If color2 is undefined then color1 will be used
  85098. * @param result defines the target Color4 to store the result in
  85099. */
  85100. getColorToRef(result: Color4): void;
  85101. }
  85102. /** Class used to store color 3 gradient */
  85103. export class Color3Gradient implements IValueGradient {
  85104. /**
  85105. * Gets or sets the gradient value (between 0 and 1)
  85106. */
  85107. gradient: number;
  85108. /**
  85109. * Gets or sets the associated color
  85110. */
  85111. color: Color3;
  85112. }
  85113. /** Class used to store factor gradient */
  85114. export class FactorGradient implements IValueGradient {
  85115. /**
  85116. * Gets or sets the gradient value (between 0 and 1)
  85117. */
  85118. gradient: number;
  85119. /**
  85120. * Gets or sets first associated factor
  85121. */
  85122. factor1: number;
  85123. /**
  85124. * Gets or sets second associated factor
  85125. */
  85126. factor2?: number;
  85127. /**
  85128. * Will get a number picked randomly between factor1 and factor2.
  85129. * If factor2 is undefined then factor1 will be used
  85130. * @returns the picked number
  85131. */
  85132. getFactor(): number;
  85133. }
  85134. /**
  85135. * Helper used to simplify some generic gradient tasks
  85136. */
  85137. export class GradientHelper {
  85138. /**
  85139. * Gets the current gradient from an array of IValueGradient
  85140. * @param ratio defines the current ratio to get
  85141. * @param gradients defines the array of IValueGradient
  85142. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85143. */
  85144. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85145. }
  85146. }
  85147. declare module BABYLON {
  85148. interface ThinEngine {
  85149. /**
  85150. * Creates a dynamic texture
  85151. * @param width defines the width of the texture
  85152. * @param height defines the height of the texture
  85153. * @param generateMipMaps defines if the engine should generate the mip levels
  85154. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85155. * @returns the dynamic texture inside an InternalTexture
  85156. */
  85157. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85158. /**
  85159. * Update the content of a dynamic texture
  85160. * @param texture defines the texture to update
  85161. * @param canvas defines the canvas containing the source
  85162. * @param invertY defines if data must be stored with Y axis inverted
  85163. * @param premulAlpha defines if alpha is stored as premultiplied
  85164. * @param format defines the format of the data
  85165. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85166. */
  85167. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85168. }
  85169. }
  85170. declare module BABYLON {
  85171. /**
  85172. * Helper class used to generate a canvas to manipulate images
  85173. */
  85174. export class CanvasGenerator {
  85175. /**
  85176. * Create a new canvas (or offscreen canvas depending on the context)
  85177. * @param width defines the expected width
  85178. * @param height defines the expected height
  85179. * @return a new canvas or offscreen canvas
  85180. */
  85181. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85182. }
  85183. }
  85184. declare module BABYLON {
  85185. /**
  85186. * A class extending Texture allowing drawing on a texture
  85187. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85188. */
  85189. export class DynamicTexture extends Texture {
  85190. private _generateMipMaps;
  85191. private _canvas;
  85192. private _context;
  85193. private _engine;
  85194. /**
  85195. * Creates a DynamicTexture
  85196. * @param name defines the name of the texture
  85197. * @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
  85198. * @param scene defines the scene where you want the texture
  85199. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85200. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85201. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85202. */
  85203. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85204. /**
  85205. * Get the current class name of the texture useful for serialization or dynamic coding.
  85206. * @returns "DynamicTexture"
  85207. */
  85208. getClassName(): string;
  85209. /**
  85210. * Gets the current state of canRescale
  85211. */
  85212. readonly canRescale: boolean;
  85213. private _recreate;
  85214. /**
  85215. * Scales the texture
  85216. * @param ratio the scale factor to apply to both width and height
  85217. */
  85218. scale(ratio: number): void;
  85219. /**
  85220. * Resizes the texture
  85221. * @param width the new width
  85222. * @param height the new height
  85223. */
  85224. scaleTo(width: number, height: number): void;
  85225. /**
  85226. * Gets the context of the canvas used by the texture
  85227. * @returns the canvas context of the dynamic texture
  85228. */
  85229. getContext(): CanvasRenderingContext2D;
  85230. /**
  85231. * Clears the texture
  85232. */
  85233. clear(): void;
  85234. /**
  85235. * Updates the texture
  85236. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85237. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85238. */
  85239. update(invertY?: boolean, premulAlpha?: boolean): void;
  85240. /**
  85241. * Draws text onto the texture
  85242. * @param text defines the text to be drawn
  85243. * @param x defines the placement of the text from the left
  85244. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85245. * @param font defines the font to be used with font-style, font-size, font-name
  85246. * @param color defines the color used for the text
  85247. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85248. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85249. * @param update defines whether texture is immediately update (default is true)
  85250. */
  85251. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85252. /**
  85253. * Clones the texture
  85254. * @returns the clone of the texture.
  85255. */
  85256. clone(): DynamicTexture;
  85257. /**
  85258. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85259. * @returns a serialized dynamic texture object
  85260. */
  85261. serialize(): any;
  85262. /** @hidden */
  85263. _rebuild(): void;
  85264. }
  85265. }
  85266. declare module BABYLON {
  85267. interface AbstractScene {
  85268. /**
  85269. * The list of procedural textures added to the scene
  85270. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85271. */
  85272. proceduralTextures: Array<ProceduralTexture>;
  85273. }
  85274. /**
  85275. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85276. * in a given scene.
  85277. */
  85278. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85279. /**
  85280. * The component name helpfull to identify the component in the list of scene components.
  85281. */
  85282. readonly name: string;
  85283. /**
  85284. * The scene the component belongs to.
  85285. */
  85286. scene: Scene;
  85287. /**
  85288. * Creates a new instance of the component for the given scene
  85289. * @param scene Defines the scene to register the component in
  85290. */
  85291. constructor(scene: Scene);
  85292. /**
  85293. * Registers the component in a given scene
  85294. */
  85295. register(): void;
  85296. /**
  85297. * Rebuilds the elements related to this component in case of
  85298. * context lost for instance.
  85299. */
  85300. rebuild(): void;
  85301. /**
  85302. * Disposes the component and the associated ressources.
  85303. */
  85304. dispose(): void;
  85305. private _beforeClear;
  85306. }
  85307. }
  85308. declare module BABYLON {
  85309. interface ThinEngine {
  85310. /**
  85311. * Creates a new render target cube texture
  85312. * @param size defines the size of the texture
  85313. * @param options defines the options used to create the texture
  85314. * @returns a new render target cube texture stored in an InternalTexture
  85315. */
  85316. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85317. }
  85318. }
  85319. declare module BABYLON {
  85320. /** @hidden */
  85321. export var proceduralVertexShader: {
  85322. name: string;
  85323. shader: string;
  85324. };
  85325. }
  85326. declare module BABYLON {
  85327. /**
  85328. * 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.
  85329. * This is the base class of any Procedural texture and contains most of the shareable code.
  85330. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85331. */
  85332. export class ProceduralTexture extends Texture {
  85333. isCube: boolean;
  85334. /**
  85335. * Define if the texture is enabled or not (disabled texture will not render)
  85336. */
  85337. isEnabled: boolean;
  85338. /**
  85339. * Define if the texture must be cleared before rendering (default is true)
  85340. */
  85341. autoClear: boolean;
  85342. /**
  85343. * Callback called when the texture is generated
  85344. */
  85345. onGenerated: () => void;
  85346. /**
  85347. * Event raised when the texture is generated
  85348. */
  85349. onGeneratedObservable: Observable<ProceduralTexture>;
  85350. /** @hidden */
  85351. _generateMipMaps: boolean;
  85352. /** @hidden **/
  85353. _effect: Effect;
  85354. /** @hidden */
  85355. _textures: {
  85356. [key: string]: Texture;
  85357. };
  85358. private _size;
  85359. private _currentRefreshId;
  85360. private _refreshRate;
  85361. private _vertexBuffers;
  85362. private _indexBuffer;
  85363. private _uniforms;
  85364. private _samplers;
  85365. private _fragment;
  85366. private _floats;
  85367. private _ints;
  85368. private _floatsArrays;
  85369. private _colors3;
  85370. private _colors4;
  85371. private _vectors2;
  85372. private _vectors3;
  85373. private _matrices;
  85374. private _fallbackTexture;
  85375. private _fallbackTextureUsed;
  85376. private _engine;
  85377. private _cachedDefines;
  85378. private _contentUpdateId;
  85379. private _contentData;
  85380. /**
  85381. * Instantiates a new procedural texture.
  85382. * 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.
  85383. * This is the base class of any Procedural texture and contains most of the shareable code.
  85384. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85385. * @param name Define the name of the texture
  85386. * @param size Define the size of the texture to create
  85387. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85388. * @param scene Define the scene the texture belongs to
  85389. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85390. * @param generateMipMaps Define if the texture should creates mip maps or not
  85391. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85392. */
  85393. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85394. /**
  85395. * The effect that is created when initializing the post process.
  85396. * @returns The created effect corresponding the the postprocess.
  85397. */
  85398. getEffect(): Effect;
  85399. /**
  85400. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85401. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85402. */
  85403. getContent(): Nullable<ArrayBufferView>;
  85404. private _createIndexBuffer;
  85405. /** @hidden */
  85406. _rebuild(): void;
  85407. /**
  85408. * Resets the texture in order to recreate its associated resources.
  85409. * This can be called in case of context loss
  85410. */
  85411. reset(): void;
  85412. protected _getDefines(): string;
  85413. /**
  85414. * Is the texture ready to be used ? (rendered at least once)
  85415. * @returns true if ready, otherwise, false.
  85416. */
  85417. isReady(): boolean;
  85418. /**
  85419. * Resets the refresh counter of the texture and start bak from scratch.
  85420. * Could be useful to regenerate the texture if it is setup to render only once.
  85421. */
  85422. resetRefreshCounter(): void;
  85423. /**
  85424. * Set the fragment shader to use in order to render the texture.
  85425. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85426. */
  85427. setFragment(fragment: any): void;
  85428. /**
  85429. * Define the refresh rate of the texture or the rendering frequency.
  85430. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85431. */
  85432. refreshRate: number;
  85433. /** @hidden */
  85434. _shouldRender(): boolean;
  85435. /**
  85436. * Get the size the texture is rendering at.
  85437. * @returns the size (texture is always squared)
  85438. */
  85439. getRenderSize(): number;
  85440. /**
  85441. * Resize the texture to new value.
  85442. * @param size Define the new size the texture should have
  85443. * @param generateMipMaps Define whether the new texture should create mip maps
  85444. */
  85445. resize(size: number, generateMipMaps: boolean): void;
  85446. private _checkUniform;
  85447. /**
  85448. * Set a texture in the shader program used to render.
  85449. * @param name Define the name of the uniform samplers as defined in the shader
  85450. * @param texture Define the texture to bind to this sampler
  85451. * @return the texture itself allowing "fluent" like uniform updates
  85452. */
  85453. setTexture(name: string, texture: Texture): ProceduralTexture;
  85454. /**
  85455. * Set a float in the shader.
  85456. * @param name Define the name of the uniform as defined in the shader
  85457. * @param value Define the value to give to the uniform
  85458. * @return the texture itself allowing "fluent" like uniform updates
  85459. */
  85460. setFloat(name: string, value: number): ProceduralTexture;
  85461. /**
  85462. * Set a int in the shader.
  85463. * @param name Define the name of the uniform as defined in the shader
  85464. * @param value Define the value to give to the uniform
  85465. * @return the texture itself allowing "fluent" like uniform updates
  85466. */
  85467. setInt(name: string, value: number): ProceduralTexture;
  85468. /**
  85469. * Set an array of floats in the shader.
  85470. * @param name Define the name of the uniform as defined in the shader
  85471. * @param value Define the value to give to the uniform
  85472. * @return the texture itself allowing "fluent" like uniform updates
  85473. */
  85474. setFloats(name: string, value: number[]): ProceduralTexture;
  85475. /**
  85476. * Set a vec3 in the shader from a Color3.
  85477. * @param name Define the name of the uniform as defined in the shader
  85478. * @param value Define the value to give to the uniform
  85479. * @return the texture itself allowing "fluent" like uniform updates
  85480. */
  85481. setColor3(name: string, value: Color3): ProceduralTexture;
  85482. /**
  85483. * Set a vec4 in the shader from a Color4.
  85484. * @param name Define the name of the uniform as defined in the shader
  85485. * @param value Define the value to give to the uniform
  85486. * @return the texture itself allowing "fluent" like uniform updates
  85487. */
  85488. setColor4(name: string, value: Color4): ProceduralTexture;
  85489. /**
  85490. * Set a vec2 in the shader from a Vector2.
  85491. * @param name Define the name of the uniform as defined in the shader
  85492. * @param value Define the value to give to the uniform
  85493. * @return the texture itself allowing "fluent" like uniform updates
  85494. */
  85495. setVector2(name: string, value: Vector2): ProceduralTexture;
  85496. /**
  85497. * Set a vec3 in the shader from a Vector3.
  85498. * @param name Define the name of the uniform as defined in the shader
  85499. * @param value Define the value to give to the uniform
  85500. * @return the texture itself allowing "fluent" like uniform updates
  85501. */
  85502. setVector3(name: string, value: Vector3): ProceduralTexture;
  85503. /**
  85504. * Set a mat4 in the shader from a MAtrix.
  85505. * @param name Define the name of the uniform as defined in the shader
  85506. * @param value Define the value to give to the uniform
  85507. * @return the texture itself allowing "fluent" like uniform updates
  85508. */
  85509. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85510. /**
  85511. * Render the texture to its associated render target.
  85512. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85513. */
  85514. render(useCameraPostProcess?: boolean): void;
  85515. /**
  85516. * Clone the texture.
  85517. * @returns the cloned texture
  85518. */
  85519. clone(): ProceduralTexture;
  85520. /**
  85521. * Dispose the texture and release its asoociated resources.
  85522. */
  85523. dispose(): void;
  85524. }
  85525. }
  85526. declare module BABYLON {
  85527. /**
  85528. * This represents the base class for particle system in Babylon.
  85529. * 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.
  85530. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85531. * @example https://doc.babylonjs.com/babylon101/particles
  85532. */
  85533. export class BaseParticleSystem {
  85534. /**
  85535. * Source color is added to the destination color without alpha affecting the result
  85536. */
  85537. static BLENDMODE_ONEONE: number;
  85538. /**
  85539. * Blend current color and particle color using particle’s alpha
  85540. */
  85541. static BLENDMODE_STANDARD: number;
  85542. /**
  85543. * Add current color and particle color multiplied by particle’s alpha
  85544. */
  85545. static BLENDMODE_ADD: number;
  85546. /**
  85547. * Multiply current color with particle color
  85548. */
  85549. static BLENDMODE_MULTIPLY: number;
  85550. /**
  85551. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85552. */
  85553. static BLENDMODE_MULTIPLYADD: number;
  85554. /**
  85555. * List of animations used by the particle system.
  85556. */
  85557. animations: Animation[];
  85558. /**
  85559. * The id of the Particle system.
  85560. */
  85561. id: string;
  85562. /**
  85563. * The friendly name of the Particle system.
  85564. */
  85565. name: string;
  85566. /**
  85567. * The rendering group used by the Particle system to chose when to render.
  85568. */
  85569. renderingGroupId: number;
  85570. /**
  85571. * The emitter represents the Mesh or position we are attaching the particle system to.
  85572. */
  85573. emitter: Nullable<AbstractMesh | Vector3>;
  85574. /**
  85575. * The maximum number of particles to emit per frame
  85576. */
  85577. emitRate: number;
  85578. /**
  85579. * If you want to launch only a few particles at once, that can be done, as well.
  85580. */
  85581. manualEmitCount: number;
  85582. /**
  85583. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85584. */
  85585. updateSpeed: number;
  85586. /**
  85587. * The amount of time the particle system is running (depends of the overall update speed).
  85588. */
  85589. targetStopDuration: number;
  85590. /**
  85591. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85592. */
  85593. disposeOnStop: boolean;
  85594. /**
  85595. * Minimum power of emitting particles.
  85596. */
  85597. minEmitPower: number;
  85598. /**
  85599. * Maximum power of emitting particles.
  85600. */
  85601. maxEmitPower: number;
  85602. /**
  85603. * Minimum life time of emitting particles.
  85604. */
  85605. minLifeTime: number;
  85606. /**
  85607. * Maximum life time of emitting particles.
  85608. */
  85609. maxLifeTime: number;
  85610. /**
  85611. * Minimum Size of emitting particles.
  85612. */
  85613. minSize: number;
  85614. /**
  85615. * Maximum Size of emitting particles.
  85616. */
  85617. maxSize: number;
  85618. /**
  85619. * Minimum scale of emitting particles on X axis.
  85620. */
  85621. minScaleX: number;
  85622. /**
  85623. * Maximum scale of emitting particles on X axis.
  85624. */
  85625. maxScaleX: number;
  85626. /**
  85627. * Minimum scale of emitting particles on Y axis.
  85628. */
  85629. minScaleY: number;
  85630. /**
  85631. * Maximum scale of emitting particles on Y axis.
  85632. */
  85633. maxScaleY: number;
  85634. /**
  85635. * Gets or sets the minimal initial rotation in radians.
  85636. */
  85637. minInitialRotation: number;
  85638. /**
  85639. * Gets or sets the maximal initial rotation in radians.
  85640. */
  85641. maxInitialRotation: number;
  85642. /**
  85643. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85644. */
  85645. minAngularSpeed: number;
  85646. /**
  85647. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85648. */
  85649. maxAngularSpeed: number;
  85650. /**
  85651. * The texture used to render each particle. (this can be a spritesheet)
  85652. */
  85653. particleTexture: Nullable<Texture>;
  85654. /**
  85655. * The layer mask we are rendering the particles through.
  85656. */
  85657. layerMask: number;
  85658. /**
  85659. * This can help using your own shader to render the particle system.
  85660. * The according effect will be created
  85661. */
  85662. customShader: any;
  85663. /**
  85664. * By default particle system starts as soon as they are created. This prevents the
  85665. * automatic start to happen and let you decide when to start emitting particles.
  85666. */
  85667. preventAutoStart: boolean;
  85668. private _noiseTexture;
  85669. /**
  85670. * Gets or sets a texture used to add random noise to particle positions
  85671. */
  85672. noiseTexture: Nullable<ProceduralTexture>;
  85673. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85674. noiseStrength: Vector3;
  85675. /**
  85676. * Callback triggered when the particle animation is ending.
  85677. */
  85678. onAnimationEnd: Nullable<() => void>;
  85679. /**
  85680. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85681. */
  85682. blendMode: number;
  85683. /**
  85684. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85685. * to override the particles.
  85686. */
  85687. forceDepthWrite: boolean;
  85688. /** 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 */
  85689. preWarmCycles: number;
  85690. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85691. preWarmStepOffset: number;
  85692. /**
  85693. * 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)
  85694. */
  85695. spriteCellChangeSpeed: number;
  85696. /**
  85697. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85698. */
  85699. startSpriteCellID: number;
  85700. /**
  85701. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85702. */
  85703. endSpriteCellID: number;
  85704. /**
  85705. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85706. */
  85707. spriteCellWidth: number;
  85708. /**
  85709. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85710. */
  85711. spriteCellHeight: number;
  85712. /**
  85713. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85714. */
  85715. spriteRandomStartCell: boolean;
  85716. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85717. translationPivot: Vector2;
  85718. /** @hidden */
  85719. protected _isAnimationSheetEnabled: boolean;
  85720. /**
  85721. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85722. */
  85723. beginAnimationOnStart: boolean;
  85724. /**
  85725. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85726. */
  85727. beginAnimationFrom: number;
  85728. /**
  85729. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85730. */
  85731. beginAnimationTo: number;
  85732. /**
  85733. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85734. */
  85735. beginAnimationLoop: boolean;
  85736. /**
  85737. * Gets or sets a world offset applied to all particles
  85738. */
  85739. worldOffset: Vector3;
  85740. /**
  85741. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85742. */
  85743. isAnimationSheetEnabled: boolean;
  85744. /**
  85745. * Get hosting scene
  85746. * @returns the scene
  85747. */
  85748. getScene(): Scene;
  85749. /**
  85750. * You can use gravity if you want to give an orientation to your particles.
  85751. */
  85752. gravity: Vector3;
  85753. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85754. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85755. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85756. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85757. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85758. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85759. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85760. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85761. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85762. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85763. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85764. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85765. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85766. /**
  85767. * Defines the delay in milliseconds before starting the system (0 by default)
  85768. */
  85769. startDelay: number;
  85770. /**
  85771. * Gets the current list of drag gradients.
  85772. * You must use addDragGradient and removeDragGradient to udpate this list
  85773. * @returns the list of drag gradients
  85774. */
  85775. getDragGradients(): Nullable<Array<FactorGradient>>;
  85776. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85777. limitVelocityDamping: number;
  85778. /**
  85779. * Gets the current list of limit velocity gradients.
  85780. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85781. * @returns the list of limit velocity gradients
  85782. */
  85783. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85784. /**
  85785. * Gets the current list of color gradients.
  85786. * You must use addColorGradient and removeColorGradient to udpate this list
  85787. * @returns the list of color gradients
  85788. */
  85789. getColorGradients(): Nullable<Array<ColorGradient>>;
  85790. /**
  85791. * Gets the current list of size gradients.
  85792. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85793. * @returns the list of size gradients
  85794. */
  85795. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85796. /**
  85797. * Gets the current list of color remap gradients.
  85798. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85799. * @returns the list of color remap gradients
  85800. */
  85801. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85802. /**
  85803. * Gets the current list of alpha remap gradients.
  85804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85805. * @returns the list of alpha remap gradients
  85806. */
  85807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85808. /**
  85809. * Gets the current list of life time gradients.
  85810. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85811. * @returns the list of life time gradients
  85812. */
  85813. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85814. /**
  85815. * Gets the current list of angular speed gradients.
  85816. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85817. * @returns the list of angular speed gradients
  85818. */
  85819. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85820. /**
  85821. * Gets the current list of velocity gradients.
  85822. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85823. * @returns the list of velocity gradients
  85824. */
  85825. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85826. /**
  85827. * Gets the current list of start size gradients.
  85828. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85829. * @returns the list of start size gradients
  85830. */
  85831. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85832. /**
  85833. * Gets the current list of emit rate gradients.
  85834. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85835. * @returns the list of emit rate gradients
  85836. */
  85837. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85838. /**
  85839. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85840. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85841. */
  85842. direction1: Vector3;
  85843. /**
  85844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85845. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85846. */
  85847. direction2: Vector3;
  85848. /**
  85849. * 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.
  85850. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85851. */
  85852. minEmitBox: Vector3;
  85853. /**
  85854. * 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.
  85855. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85856. */
  85857. maxEmitBox: Vector3;
  85858. /**
  85859. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85860. */
  85861. color1: Color4;
  85862. /**
  85863. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85864. */
  85865. color2: Color4;
  85866. /**
  85867. * Color the particle will have at the end of its lifetime
  85868. */
  85869. colorDead: Color4;
  85870. /**
  85871. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85872. */
  85873. textureMask: Color4;
  85874. /**
  85875. * The particle emitter type defines the emitter used by the particle system.
  85876. * It can be for example box, sphere, or cone...
  85877. */
  85878. particleEmitterType: IParticleEmitterType;
  85879. /** @hidden */
  85880. _isSubEmitter: boolean;
  85881. /**
  85882. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85883. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85884. */
  85885. billboardMode: number;
  85886. protected _isBillboardBased: boolean;
  85887. /**
  85888. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85889. */
  85890. isBillboardBased: boolean;
  85891. /**
  85892. * The scene the particle system belongs to.
  85893. */
  85894. protected _scene: Scene;
  85895. /**
  85896. * Local cache of defines for image processing.
  85897. */
  85898. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85899. /**
  85900. * Default configuration related to image processing available in the standard Material.
  85901. */
  85902. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85903. /**
  85904. * Gets the image processing configuration used either in this material.
  85905. */
  85906. /**
  85907. * Sets the Default image processing configuration used either in the this material.
  85908. *
  85909. * If sets to null, the scene one is in use.
  85910. */
  85911. imageProcessingConfiguration: ImageProcessingConfiguration;
  85912. /**
  85913. * Attaches a new image processing configuration to the Standard Material.
  85914. * @param configuration
  85915. */
  85916. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85917. /** @hidden */
  85918. protected _reset(): void;
  85919. /** @hidden */
  85920. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85921. /**
  85922. * Instantiates a particle system.
  85923. * 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.
  85924. * @param name The name of the particle system
  85925. */
  85926. constructor(name: string);
  85927. /**
  85928. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85931. * @returns the emitter
  85932. */
  85933. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85934. /**
  85935. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85936. * @param radius The radius of the hemisphere to emit from
  85937. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85938. * @returns the emitter
  85939. */
  85940. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85941. /**
  85942. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85943. * @param radius The radius of the sphere to emit from
  85944. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85945. * @returns the emitter
  85946. */
  85947. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85948. /**
  85949. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85950. * @param radius The radius of the sphere to emit from
  85951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85953. * @returns the emitter
  85954. */
  85955. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85956. /**
  85957. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85958. * @param radius The radius of the emission cylinder
  85959. * @param height The height of the emission cylinder
  85960. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85961. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85962. * @returns the emitter
  85963. */
  85964. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85965. /**
  85966. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85967. * @param radius The radius of the cylinder to emit from
  85968. * @param height The height of the emission cylinder
  85969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85972. * @returns the emitter
  85973. */
  85974. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85975. /**
  85976. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85977. * @param radius The radius of the cone to emit from
  85978. * @param angle The base angle of the cone
  85979. * @returns the emitter
  85980. */
  85981. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85982. /**
  85983. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85986. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85987. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85988. * @returns the emitter
  85989. */
  85990. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85991. }
  85992. }
  85993. declare module BABYLON {
  85994. /**
  85995. * Type of sub emitter
  85996. */
  85997. export enum SubEmitterType {
  85998. /**
  85999. * Attached to the particle over it's lifetime
  86000. */
  86001. ATTACHED = 0,
  86002. /**
  86003. * Created when the particle dies
  86004. */
  86005. END = 1
  86006. }
  86007. /**
  86008. * Sub emitter class used to emit particles from an existing particle
  86009. */
  86010. export class SubEmitter {
  86011. /**
  86012. * the particle system to be used by the sub emitter
  86013. */
  86014. particleSystem: ParticleSystem;
  86015. /**
  86016. * Type of the submitter (Default: END)
  86017. */
  86018. type: SubEmitterType;
  86019. /**
  86020. * 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)
  86021. * Note: This only is supported when using an emitter of type Mesh
  86022. */
  86023. inheritDirection: boolean;
  86024. /**
  86025. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86026. */
  86027. inheritedVelocityAmount: number;
  86028. /**
  86029. * Creates a sub emitter
  86030. * @param particleSystem the particle system to be used by the sub emitter
  86031. */
  86032. constructor(
  86033. /**
  86034. * the particle system to be used by the sub emitter
  86035. */
  86036. particleSystem: ParticleSystem);
  86037. /**
  86038. * Clones the sub emitter
  86039. * @returns the cloned sub emitter
  86040. */
  86041. clone(): SubEmitter;
  86042. /**
  86043. * Serialize current object to a JSON object
  86044. * @returns the serialized object
  86045. */
  86046. serialize(): any;
  86047. /** @hidden */
  86048. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86049. /**
  86050. * Creates a new SubEmitter from a serialized JSON version
  86051. * @param serializationObject defines the JSON object to read from
  86052. * @param scene defines the hosting scene
  86053. * @param rootUrl defines the rootUrl for data loading
  86054. * @returns a new SubEmitter
  86055. */
  86056. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86057. /** Release associated resources */
  86058. dispose(): void;
  86059. }
  86060. }
  86061. declare module BABYLON {
  86062. /** @hidden */
  86063. export var clipPlaneFragmentDeclaration: {
  86064. name: string;
  86065. shader: string;
  86066. };
  86067. }
  86068. declare module BABYLON {
  86069. /** @hidden */
  86070. export var imageProcessingDeclaration: {
  86071. name: string;
  86072. shader: string;
  86073. };
  86074. }
  86075. declare module BABYLON {
  86076. /** @hidden */
  86077. export var imageProcessingFunctions: {
  86078. name: string;
  86079. shader: string;
  86080. };
  86081. }
  86082. declare module BABYLON {
  86083. /** @hidden */
  86084. export var clipPlaneFragment: {
  86085. name: string;
  86086. shader: string;
  86087. };
  86088. }
  86089. declare module BABYLON {
  86090. /** @hidden */
  86091. export var particlesPixelShader: {
  86092. name: string;
  86093. shader: string;
  86094. };
  86095. }
  86096. declare module BABYLON {
  86097. /** @hidden */
  86098. export var clipPlaneVertexDeclaration: {
  86099. name: string;
  86100. shader: string;
  86101. };
  86102. }
  86103. declare module BABYLON {
  86104. /** @hidden */
  86105. export var clipPlaneVertex: {
  86106. name: string;
  86107. shader: string;
  86108. };
  86109. }
  86110. declare module BABYLON {
  86111. /** @hidden */
  86112. export var particlesVertexShader: {
  86113. name: string;
  86114. shader: string;
  86115. };
  86116. }
  86117. declare module BABYLON {
  86118. /**
  86119. * This represents a particle system in Babylon.
  86120. * 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.
  86121. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86122. * @example https://doc.babylonjs.com/babylon101/particles
  86123. */
  86124. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86125. /**
  86126. * Billboard mode will only apply to Y axis
  86127. */
  86128. static readonly BILLBOARDMODE_Y: number;
  86129. /**
  86130. * Billboard mode will apply to all axes
  86131. */
  86132. static readonly BILLBOARDMODE_ALL: number;
  86133. /**
  86134. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86135. */
  86136. static readonly BILLBOARDMODE_STRETCHED: number;
  86137. /**
  86138. * This function can be defined to provide custom update for active particles.
  86139. * This function will be called instead of regular update (age, position, color, etc.).
  86140. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86141. */
  86142. updateFunction: (particles: Particle[]) => void;
  86143. private _emitterWorldMatrix;
  86144. /**
  86145. * This function can be defined to specify initial direction for every new particle.
  86146. * It by default use the emitterType defined function
  86147. */
  86148. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86149. /**
  86150. * This function can be defined to specify initial position for every new particle.
  86151. * It by default use the emitterType defined function
  86152. */
  86153. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86154. /**
  86155. * @hidden
  86156. */
  86157. _inheritedVelocityOffset: Vector3;
  86158. /**
  86159. * An event triggered when the system is disposed
  86160. */
  86161. onDisposeObservable: Observable<ParticleSystem>;
  86162. private _onDisposeObserver;
  86163. /**
  86164. * Sets a callback that will be triggered when the system is disposed
  86165. */
  86166. onDispose: () => void;
  86167. private _particles;
  86168. private _epsilon;
  86169. private _capacity;
  86170. private _stockParticles;
  86171. private _newPartsExcess;
  86172. private _vertexData;
  86173. private _vertexBuffer;
  86174. private _vertexBuffers;
  86175. private _spriteBuffer;
  86176. private _indexBuffer;
  86177. private _effect;
  86178. private _customEffect;
  86179. private _cachedDefines;
  86180. private _scaledColorStep;
  86181. private _colorDiff;
  86182. private _scaledDirection;
  86183. private _scaledGravity;
  86184. private _currentRenderId;
  86185. private _alive;
  86186. private _useInstancing;
  86187. private _started;
  86188. private _stopped;
  86189. private _actualFrame;
  86190. private _scaledUpdateSpeed;
  86191. private _vertexBufferSize;
  86192. /** @hidden */
  86193. _currentEmitRateGradient: Nullable<FactorGradient>;
  86194. /** @hidden */
  86195. _currentEmitRate1: number;
  86196. /** @hidden */
  86197. _currentEmitRate2: number;
  86198. /** @hidden */
  86199. _currentStartSizeGradient: Nullable<FactorGradient>;
  86200. /** @hidden */
  86201. _currentStartSize1: number;
  86202. /** @hidden */
  86203. _currentStartSize2: number;
  86204. private readonly _rawTextureWidth;
  86205. private _rampGradientsTexture;
  86206. private _useRampGradients;
  86207. /** Gets or sets a boolean indicating that ramp gradients must be used
  86208. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86209. */
  86210. useRampGradients: boolean;
  86211. /**
  86212. * 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.
  86213. * 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: [])
  86214. */
  86215. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86216. private _subEmitters;
  86217. /**
  86218. * @hidden
  86219. * If the particle systems emitter should be disposed when the particle system is disposed
  86220. */
  86221. _disposeEmitterOnDispose: boolean;
  86222. /**
  86223. * The current active Sub-systems, this property is used by the root particle system only.
  86224. */
  86225. activeSubSystems: Array<ParticleSystem>;
  86226. private _rootParticleSystem;
  86227. /**
  86228. * Gets the current list of active particles
  86229. */
  86230. readonly particles: Particle[];
  86231. /**
  86232. * Returns the string "ParticleSystem"
  86233. * @returns a string containing the class name
  86234. */
  86235. getClassName(): string;
  86236. /**
  86237. * Instantiates a particle system.
  86238. * 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.
  86239. * @param name The name of the particle system
  86240. * @param capacity The max number of particles alive at the same time
  86241. * @param scene The scene the particle system belongs to
  86242. * @param customEffect a custom effect used to change the way particles are rendered by default
  86243. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86244. * @param epsilon Offset used to render the particles
  86245. */
  86246. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86247. private _addFactorGradient;
  86248. private _removeFactorGradient;
  86249. /**
  86250. * Adds a new life time gradient
  86251. * @param gradient defines the gradient to use (between 0 and 1)
  86252. * @param factor defines the life time factor to affect to the specified gradient
  86253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86254. * @returns the current particle system
  86255. */
  86256. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86257. /**
  86258. * Remove a specific life time gradient
  86259. * @param gradient defines the gradient to remove
  86260. * @returns the current particle system
  86261. */
  86262. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86263. /**
  86264. * Adds a new size gradient
  86265. * @param gradient defines the gradient to use (between 0 and 1)
  86266. * @param factor defines the size factor to affect to the specified gradient
  86267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86268. * @returns the current particle system
  86269. */
  86270. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86271. /**
  86272. * Remove a specific size gradient
  86273. * @param gradient defines the gradient to remove
  86274. * @returns the current particle system
  86275. */
  86276. removeSizeGradient(gradient: number): IParticleSystem;
  86277. /**
  86278. * Adds a new color remap gradient
  86279. * @param gradient defines the gradient to use (between 0 and 1)
  86280. * @param min defines the color remap minimal range
  86281. * @param max defines the color remap maximal range
  86282. * @returns the current particle system
  86283. */
  86284. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86285. /**
  86286. * Remove a specific color remap gradient
  86287. * @param gradient defines the gradient to remove
  86288. * @returns the current particle system
  86289. */
  86290. removeColorRemapGradient(gradient: number): IParticleSystem;
  86291. /**
  86292. * Adds a new alpha remap gradient
  86293. * @param gradient defines the gradient to use (between 0 and 1)
  86294. * @param min defines the alpha remap minimal range
  86295. * @param max defines the alpha remap maximal range
  86296. * @returns the current particle system
  86297. */
  86298. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86299. /**
  86300. * Remove a specific alpha remap gradient
  86301. * @param gradient defines the gradient to remove
  86302. * @returns the current particle system
  86303. */
  86304. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86305. /**
  86306. * Adds a new angular speed gradient
  86307. * @param gradient defines the gradient to use (between 0 and 1)
  86308. * @param factor defines the angular speed to affect to the specified gradient
  86309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86310. * @returns the current particle system
  86311. */
  86312. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86313. /**
  86314. * Remove a specific angular speed gradient
  86315. * @param gradient defines the gradient to remove
  86316. * @returns the current particle system
  86317. */
  86318. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86319. /**
  86320. * Adds a new velocity gradient
  86321. * @param gradient defines the gradient to use (between 0 and 1)
  86322. * @param factor defines the velocity to affect to the specified gradient
  86323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86324. * @returns the current particle system
  86325. */
  86326. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86327. /**
  86328. * Remove a specific velocity gradient
  86329. * @param gradient defines the gradient to remove
  86330. * @returns the current particle system
  86331. */
  86332. removeVelocityGradient(gradient: number): IParticleSystem;
  86333. /**
  86334. * Adds a new limit velocity gradient
  86335. * @param gradient defines the gradient to use (between 0 and 1)
  86336. * @param factor defines the limit velocity value to affect to the specified gradient
  86337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86338. * @returns the current particle system
  86339. */
  86340. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86341. /**
  86342. * Remove a specific limit velocity gradient
  86343. * @param gradient defines the gradient to remove
  86344. * @returns the current particle system
  86345. */
  86346. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86347. /**
  86348. * Adds a new drag gradient
  86349. * @param gradient defines the gradient to use (between 0 and 1)
  86350. * @param factor defines the drag value to affect to the specified gradient
  86351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86352. * @returns the current particle system
  86353. */
  86354. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86355. /**
  86356. * Remove a specific drag gradient
  86357. * @param gradient defines the gradient to remove
  86358. * @returns the current particle system
  86359. */
  86360. removeDragGradient(gradient: number): IParticleSystem;
  86361. /**
  86362. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86363. * @param gradient defines the gradient to use (between 0 and 1)
  86364. * @param factor defines the emit rate value to affect to the specified gradient
  86365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86366. * @returns the current particle system
  86367. */
  86368. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86369. /**
  86370. * Remove a specific emit rate gradient
  86371. * @param gradient defines the gradient to remove
  86372. * @returns the current particle system
  86373. */
  86374. removeEmitRateGradient(gradient: number): IParticleSystem;
  86375. /**
  86376. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86377. * @param gradient defines the gradient to use (between 0 and 1)
  86378. * @param factor defines the start size value to affect to the specified gradient
  86379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86380. * @returns the current particle system
  86381. */
  86382. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86383. /**
  86384. * Remove a specific start size gradient
  86385. * @param gradient defines the gradient to remove
  86386. * @returns the current particle system
  86387. */
  86388. removeStartSizeGradient(gradient: number): IParticleSystem;
  86389. private _createRampGradientTexture;
  86390. /**
  86391. * Gets the current list of ramp gradients.
  86392. * You must use addRampGradient and removeRampGradient to udpate this list
  86393. * @returns the list of ramp gradients
  86394. */
  86395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86396. /**
  86397. * Adds a new ramp gradient used to remap particle colors
  86398. * @param gradient defines the gradient to use (between 0 and 1)
  86399. * @param color defines the color to affect to the specified gradient
  86400. * @returns the current particle system
  86401. */
  86402. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86403. /**
  86404. * Remove a specific ramp gradient
  86405. * @param gradient defines the gradient to remove
  86406. * @returns the current particle system
  86407. */
  86408. removeRampGradient(gradient: number): ParticleSystem;
  86409. /**
  86410. * Adds a new color gradient
  86411. * @param gradient defines the gradient to use (between 0 and 1)
  86412. * @param color1 defines the color to affect to the specified gradient
  86413. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86414. * @returns this particle system
  86415. */
  86416. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86417. /**
  86418. * Remove a specific color gradient
  86419. * @param gradient defines the gradient to remove
  86420. * @returns this particle system
  86421. */
  86422. removeColorGradient(gradient: number): IParticleSystem;
  86423. private _fetchR;
  86424. protected _reset(): void;
  86425. private _resetEffect;
  86426. private _createVertexBuffers;
  86427. private _createIndexBuffer;
  86428. /**
  86429. * Gets the maximum number of particles active at the same time.
  86430. * @returns The max number of active particles.
  86431. */
  86432. getCapacity(): number;
  86433. /**
  86434. * Gets whether there are still active particles in the system.
  86435. * @returns True if it is alive, otherwise false.
  86436. */
  86437. isAlive(): boolean;
  86438. /**
  86439. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86440. * @returns True if it has been started, otherwise false.
  86441. */
  86442. isStarted(): boolean;
  86443. private _prepareSubEmitterInternalArray;
  86444. /**
  86445. * Starts the particle system and begins to emit
  86446. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86447. */
  86448. start(delay?: number): void;
  86449. /**
  86450. * Stops the particle system.
  86451. * @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.
  86452. */
  86453. stop(stopSubEmitters?: boolean): void;
  86454. /**
  86455. * Remove all active particles
  86456. */
  86457. reset(): void;
  86458. /**
  86459. * @hidden (for internal use only)
  86460. */
  86461. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86462. /**
  86463. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86464. * Its lifetime will start back at 0.
  86465. */
  86466. recycleParticle: (particle: Particle) => void;
  86467. private _stopSubEmitters;
  86468. private _createParticle;
  86469. private _removeFromRoot;
  86470. private _emitFromParticle;
  86471. private _update;
  86472. /** @hidden */
  86473. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86474. /** @hidden */
  86475. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86476. /** @hidden */
  86477. private _getEffect;
  86478. /**
  86479. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86480. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86481. */
  86482. animate(preWarmOnly?: boolean): void;
  86483. private _appendParticleVertices;
  86484. /**
  86485. * Rebuilds the particle system.
  86486. */
  86487. rebuild(): void;
  86488. /**
  86489. * Is this system ready to be used/rendered
  86490. * @return true if the system is ready
  86491. */
  86492. isReady(): boolean;
  86493. private _render;
  86494. /**
  86495. * Renders the particle system in its current state.
  86496. * @returns the current number of particles
  86497. */
  86498. render(): number;
  86499. /**
  86500. * Disposes the particle system and free the associated resources
  86501. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86502. */
  86503. dispose(disposeTexture?: boolean): void;
  86504. /**
  86505. * Clones the particle system.
  86506. * @param name The name of the cloned object
  86507. * @param newEmitter The new emitter to use
  86508. * @returns the cloned particle system
  86509. */
  86510. clone(name: string, newEmitter: any): ParticleSystem;
  86511. /**
  86512. * Serializes the particle system to a JSON object.
  86513. * @returns the JSON object
  86514. */
  86515. serialize(): any;
  86516. /** @hidden */
  86517. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86518. /** @hidden */
  86519. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86520. /**
  86521. * Parses a JSON object to create a particle system.
  86522. * @param parsedParticleSystem The JSON object to parse
  86523. * @param scene The scene to create the particle system in
  86524. * @param rootUrl The root url to use to load external dependencies like texture
  86525. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86526. * @returns the Parsed particle system
  86527. */
  86528. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86529. }
  86530. }
  86531. declare module BABYLON {
  86532. /**
  86533. * A particle represents one of the element emitted by a particle system.
  86534. * This is mainly define by its coordinates, direction, velocity and age.
  86535. */
  86536. export class Particle {
  86537. /**
  86538. * The particle system the particle belongs to.
  86539. */
  86540. particleSystem: ParticleSystem;
  86541. private static _Count;
  86542. /**
  86543. * Unique ID of the particle
  86544. */
  86545. id: number;
  86546. /**
  86547. * The world position of the particle in the scene.
  86548. */
  86549. position: Vector3;
  86550. /**
  86551. * The world direction of the particle in the scene.
  86552. */
  86553. direction: Vector3;
  86554. /**
  86555. * The color of the particle.
  86556. */
  86557. color: Color4;
  86558. /**
  86559. * The color change of the particle per step.
  86560. */
  86561. colorStep: Color4;
  86562. /**
  86563. * Defines how long will the life of the particle be.
  86564. */
  86565. lifeTime: number;
  86566. /**
  86567. * The current age of the particle.
  86568. */
  86569. age: number;
  86570. /**
  86571. * The current size of the particle.
  86572. */
  86573. size: number;
  86574. /**
  86575. * The current scale of the particle.
  86576. */
  86577. scale: Vector2;
  86578. /**
  86579. * The current angle of the particle.
  86580. */
  86581. angle: number;
  86582. /**
  86583. * Defines how fast is the angle changing.
  86584. */
  86585. angularSpeed: number;
  86586. /**
  86587. * Defines the cell index used by the particle to be rendered from a sprite.
  86588. */
  86589. cellIndex: number;
  86590. /**
  86591. * The information required to support color remapping
  86592. */
  86593. remapData: Vector4;
  86594. /** @hidden */
  86595. _randomCellOffset?: number;
  86596. /** @hidden */
  86597. _initialDirection: Nullable<Vector3>;
  86598. /** @hidden */
  86599. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86600. /** @hidden */
  86601. _initialStartSpriteCellID: number;
  86602. /** @hidden */
  86603. _initialEndSpriteCellID: number;
  86604. /** @hidden */
  86605. _currentColorGradient: Nullable<ColorGradient>;
  86606. /** @hidden */
  86607. _currentColor1: Color4;
  86608. /** @hidden */
  86609. _currentColor2: Color4;
  86610. /** @hidden */
  86611. _currentSizeGradient: Nullable<FactorGradient>;
  86612. /** @hidden */
  86613. _currentSize1: number;
  86614. /** @hidden */
  86615. _currentSize2: number;
  86616. /** @hidden */
  86617. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86618. /** @hidden */
  86619. _currentAngularSpeed1: number;
  86620. /** @hidden */
  86621. _currentAngularSpeed2: number;
  86622. /** @hidden */
  86623. _currentVelocityGradient: Nullable<FactorGradient>;
  86624. /** @hidden */
  86625. _currentVelocity1: number;
  86626. /** @hidden */
  86627. _currentVelocity2: number;
  86628. /** @hidden */
  86629. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86630. /** @hidden */
  86631. _currentLimitVelocity1: number;
  86632. /** @hidden */
  86633. _currentLimitVelocity2: number;
  86634. /** @hidden */
  86635. _currentDragGradient: Nullable<FactorGradient>;
  86636. /** @hidden */
  86637. _currentDrag1: number;
  86638. /** @hidden */
  86639. _currentDrag2: number;
  86640. /** @hidden */
  86641. _randomNoiseCoordinates1: Vector3;
  86642. /** @hidden */
  86643. _randomNoiseCoordinates2: Vector3;
  86644. /**
  86645. * Creates a new instance Particle
  86646. * @param particleSystem the particle system the particle belongs to
  86647. */
  86648. constructor(
  86649. /**
  86650. * The particle system the particle belongs to.
  86651. */
  86652. particleSystem: ParticleSystem);
  86653. private updateCellInfoFromSystem;
  86654. /**
  86655. * Defines how the sprite cell index is updated for the particle
  86656. */
  86657. updateCellIndex(): void;
  86658. /** @hidden */
  86659. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86660. /** @hidden */
  86661. _inheritParticleInfoToSubEmitters(): void;
  86662. /** @hidden */
  86663. _reset(): void;
  86664. /**
  86665. * Copy the properties of particle to another one.
  86666. * @param other the particle to copy the information to.
  86667. */
  86668. copyTo(other: Particle): void;
  86669. }
  86670. }
  86671. declare module BABYLON {
  86672. /**
  86673. * Particle emitter represents a volume emitting particles.
  86674. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86675. */
  86676. export interface IParticleEmitterType {
  86677. /**
  86678. * Called by the particle System when the direction is computed for the created particle.
  86679. * @param worldMatrix is the world matrix of the particle system
  86680. * @param directionToUpdate is the direction vector to update with the result
  86681. * @param particle is the particle we are computed the direction for
  86682. */
  86683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86684. /**
  86685. * Called by the particle System when the position is computed for the created particle.
  86686. * @param worldMatrix is the world matrix of the particle system
  86687. * @param positionToUpdate is the position vector to update with the result
  86688. * @param particle is the particle we are computed the position for
  86689. */
  86690. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86691. /**
  86692. * Clones the current emitter and returns a copy of it
  86693. * @returns the new emitter
  86694. */
  86695. clone(): IParticleEmitterType;
  86696. /**
  86697. * Called by the GPUParticleSystem to setup the update shader
  86698. * @param effect defines the update shader
  86699. */
  86700. applyToShader(effect: Effect): void;
  86701. /**
  86702. * Returns a string to use to update the GPU particles update shader
  86703. * @returns the effect defines string
  86704. */
  86705. getEffectDefines(): string;
  86706. /**
  86707. * Returns a string representing the class name
  86708. * @returns a string containing the class name
  86709. */
  86710. getClassName(): string;
  86711. /**
  86712. * Serializes the particle system to a JSON object.
  86713. * @returns the JSON object
  86714. */
  86715. serialize(): any;
  86716. /**
  86717. * Parse properties from a JSON object
  86718. * @param serializationObject defines the JSON object
  86719. */
  86720. parse(serializationObject: any): void;
  86721. }
  86722. }
  86723. declare module BABYLON {
  86724. /**
  86725. * Particle emitter emitting particles from the inside of a box.
  86726. * It emits the particles randomly between 2 given directions.
  86727. */
  86728. export class BoxParticleEmitter implements IParticleEmitterType {
  86729. /**
  86730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86731. */
  86732. direction1: Vector3;
  86733. /**
  86734. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86735. */
  86736. direction2: Vector3;
  86737. /**
  86738. * 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.
  86739. */
  86740. minEmitBox: Vector3;
  86741. /**
  86742. * 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.
  86743. */
  86744. maxEmitBox: Vector3;
  86745. /**
  86746. * Creates a new instance BoxParticleEmitter
  86747. */
  86748. constructor();
  86749. /**
  86750. * Called by the particle System when the direction is computed for the created particle.
  86751. * @param worldMatrix is the world matrix of the particle system
  86752. * @param directionToUpdate is the direction vector to update with the result
  86753. * @param particle is the particle we are computed the direction for
  86754. */
  86755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86756. /**
  86757. * Called by the particle System when the position is computed for the created particle.
  86758. * @param worldMatrix is the world matrix of the particle system
  86759. * @param positionToUpdate is the position vector to update with the result
  86760. * @param particle is the particle we are computed the position for
  86761. */
  86762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86763. /**
  86764. * Clones the current emitter and returns a copy of it
  86765. * @returns the new emitter
  86766. */
  86767. clone(): BoxParticleEmitter;
  86768. /**
  86769. * Called by the GPUParticleSystem to setup the update shader
  86770. * @param effect defines the update shader
  86771. */
  86772. applyToShader(effect: Effect): void;
  86773. /**
  86774. * Returns a string to use to update the GPU particles update shader
  86775. * @returns a string containng the defines string
  86776. */
  86777. getEffectDefines(): string;
  86778. /**
  86779. * Returns the string "BoxParticleEmitter"
  86780. * @returns a string containing the class name
  86781. */
  86782. getClassName(): string;
  86783. /**
  86784. * Serializes the particle system to a JSON object.
  86785. * @returns the JSON object
  86786. */
  86787. serialize(): any;
  86788. /**
  86789. * Parse properties from a JSON object
  86790. * @param serializationObject defines the JSON object
  86791. */
  86792. parse(serializationObject: any): void;
  86793. }
  86794. }
  86795. declare module BABYLON {
  86796. /**
  86797. * Particle emitter emitting particles from the inside of a cone.
  86798. * It emits the particles alongside the cone volume from the base to the particle.
  86799. * The emission direction might be randomized.
  86800. */
  86801. export class ConeParticleEmitter implements IParticleEmitterType {
  86802. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86803. directionRandomizer: number;
  86804. private _radius;
  86805. private _angle;
  86806. private _height;
  86807. /**
  86808. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86809. */
  86810. radiusRange: number;
  86811. /**
  86812. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86813. */
  86814. heightRange: number;
  86815. /**
  86816. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86817. */
  86818. emitFromSpawnPointOnly: boolean;
  86819. /**
  86820. * Gets or sets the radius of the emission cone
  86821. */
  86822. radius: number;
  86823. /**
  86824. * Gets or sets the angle of the emission cone
  86825. */
  86826. angle: number;
  86827. private _buildHeight;
  86828. /**
  86829. * Creates a new instance ConeParticleEmitter
  86830. * @param radius the radius of the emission cone (1 by default)
  86831. * @param angle the cone base angle (PI by default)
  86832. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86833. */
  86834. constructor(radius?: number, angle?: number,
  86835. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86836. directionRandomizer?: number);
  86837. /**
  86838. * Called by the particle System when the direction is computed for the created particle.
  86839. * @param worldMatrix is the world matrix of the particle system
  86840. * @param directionToUpdate is the direction vector to update with the result
  86841. * @param particle is the particle we are computed the direction for
  86842. */
  86843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86844. /**
  86845. * Called by the particle System when the position is computed for the created particle.
  86846. * @param worldMatrix is the world matrix of the particle system
  86847. * @param positionToUpdate is the position vector to update with the result
  86848. * @param particle is the particle we are computed the position for
  86849. */
  86850. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86851. /**
  86852. * Clones the current emitter and returns a copy of it
  86853. * @returns the new emitter
  86854. */
  86855. clone(): ConeParticleEmitter;
  86856. /**
  86857. * Called by the GPUParticleSystem to setup the update shader
  86858. * @param effect defines the update shader
  86859. */
  86860. applyToShader(effect: Effect): void;
  86861. /**
  86862. * Returns a string to use to update the GPU particles update shader
  86863. * @returns a string containng the defines string
  86864. */
  86865. getEffectDefines(): string;
  86866. /**
  86867. * Returns the string "ConeParticleEmitter"
  86868. * @returns a string containing the class name
  86869. */
  86870. getClassName(): string;
  86871. /**
  86872. * Serializes the particle system to a JSON object.
  86873. * @returns the JSON object
  86874. */
  86875. serialize(): any;
  86876. /**
  86877. * Parse properties from a JSON object
  86878. * @param serializationObject defines the JSON object
  86879. */
  86880. parse(serializationObject: any): void;
  86881. }
  86882. }
  86883. declare module BABYLON {
  86884. /**
  86885. * Particle emitter emitting particles from the inside of a cylinder.
  86886. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86887. */
  86888. export class CylinderParticleEmitter implements IParticleEmitterType {
  86889. /**
  86890. * The radius of the emission cylinder.
  86891. */
  86892. radius: number;
  86893. /**
  86894. * The height of the emission cylinder.
  86895. */
  86896. height: number;
  86897. /**
  86898. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86899. */
  86900. radiusRange: number;
  86901. /**
  86902. * How much to randomize the particle direction [0-1].
  86903. */
  86904. directionRandomizer: number;
  86905. /**
  86906. * Creates a new instance CylinderParticleEmitter
  86907. * @param radius the radius of the emission cylinder (1 by default)
  86908. * @param height the height of the emission cylinder (1 by default)
  86909. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86910. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86911. */
  86912. constructor(
  86913. /**
  86914. * The radius of the emission cylinder.
  86915. */
  86916. radius?: number,
  86917. /**
  86918. * The height of the emission cylinder.
  86919. */
  86920. height?: number,
  86921. /**
  86922. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86923. */
  86924. radiusRange?: number,
  86925. /**
  86926. * How much to randomize the particle direction [0-1].
  86927. */
  86928. directionRandomizer?: number);
  86929. /**
  86930. * Called by the particle System when the direction is computed for the created particle.
  86931. * @param worldMatrix is the world matrix of the particle system
  86932. * @param directionToUpdate is the direction vector to update with the result
  86933. * @param particle is the particle we are computed the direction for
  86934. */
  86935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86936. /**
  86937. * Called by the particle System when the position is computed for the created particle.
  86938. * @param worldMatrix is the world matrix of the particle system
  86939. * @param positionToUpdate is the position vector to update with the result
  86940. * @param particle is the particle we are computed the position for
  86941. */
  86942. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86943. /**
  86944. * Clones the current emitter and returns a copy of it
  86945. * @returns the new emitter
  86946. */
  86947. clone(): CylinderParticleEmitter;
  86948. /**
  86949. * Called by the GPUParticleSystem to setup the update shader
  86950. * @param effect defines the update shader
  86951. */
  86952. applyToShader(effect: Effect): void;
  86953. /**
  86954. * Returns a string to use to update the GPU particles update shader
  86955. * @returns a string containng the defines string
  86956. */
  86957. getEffectDefines(): string;
  86958. /**
  86959. * Returns the string "CylinderParticleEmitter"
  86960. * @returns a string containing the class name
  86961. */
  86962. getClassName(): string;
  86963. /**
  86964. * Serializes the particle system to a JSON object.
  86965. * @returns the JSON object
  86966. */
  86967. serialize(): any;
  86968. /**
  86969. * Parse properties from a JSON object
  86970. * @param serializationObject defines the JSON object
  86971. */
  86972. parse(serializationObject: any): void;
  86973. }
  86974. /**
  86975. * Particle emitter emitting particles from the inside of a cylinder.
  86976. * It emits the particles randomly between two vectors.
  86977. */
  86978. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86979. /**
  86980. * The min limit of the emission direction.
  86981. */
  86982. direction1: Vector3;
  86983. /**
  86984. * The max limit of the emission direction.
  86985. */
  86986. direction2: Vector3;
  86987. /**
  86988. * Creates a new instance CylinderDirectedParticleEmitter
  86989. * @param radius the radius of the emission cylinder (1 by default)
  86990. * @param height the height of the emission cylinder (1 by default)
  86991. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86992. * @param direction1 the min limit of the emission direction (up vector by default)
  86993. * @param direction2 the max limit of the emission direction (up vector by default)
  86994. */
  86995. constructor(radius?: number, height?: number, radiusRange?: number,
  86996. /**
  86997. * The min limit of the emission direction.
  86998. */
  86999. direction1?: Vector3,
  87000. /**
  87001. * The max limit of the emission direction.
  87002. */
  87003. direction2?: Vector3);
  87004. /**
  87005. * Called by the particle System when the direction is computed for the created particle.
  87006. * @param worldMatrix is the world matrix of the particle system
  87007. * @param directionToUpdate is the direction vector to update with the result
  87008. * @param particle is the particle we are computed the direction for
  87009. */
  87010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87011. /**
  87012. * Clones the current emitter and returns a copy of it
  87013. * @returns the new emitter
  87014. */
  87015. clone(): CylinderDirectedParticleEmitter;
  87016. /**
  87017. * Called by the GPUParticleSystem to setup the update shader
  87018. * @param effect defines the update shader
  87019. */
  87020. applyToShader(effect: Effect): void;
  87021. /**
  87022. * Returns a string to use to update the GPU particles update shader
  87023. * @returns a string containng the defines string
  87024. */
  87025. getEffectDefines(): string;
  87026. /**
  87027. * Returns the string "CylinderDirectedParticleEmitter"
  87028. * @returns a string containing the class name
  87029. */
  87030. getClassName(): string;
  87031. /**
  87032. * Serializes the particle system to a JSON object.
  87033. * @returns the JSON object
  87034. */
  87035. serialize(): any;
  87036. /**
  87037. * Parse properties from a JSON object
  87038. * @param serializationObject defines the JSON object
  87039. */
  87040. parse(serializationObject: any): void;
  87041. }
  87042. }
  87043. declare module BABYLON {
  87044. /**
  87045. * Particle emitter emitting particles from the inside of a hemisphere.
  87046. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87047. */
  87048. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87049. /**
  87050. * The radius of the emission hemisphere.
  87051. */
  87052. radius: number;
  87053. /**
  87054. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87055. */
  87056. radiusRange: number;
  87057. /**
  87058. * How much to randomize the particle direction [0-1].
  87059. */
  87060. directionRandomizer: number;
  87061. /**
  87062. * Creates a new instance HemisphericParticleEmitter
  87063. * @param radius the radius of the emission hemisphere (1 by default)
  87064. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87065. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87066. */
  87067. constructor(
  87068. /**
  87069. * The radius of the emission hemisphere.
  87070. */
  87071. radius?: number,
  87072. /**
  87073. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87074. */
  87075. radiusRange?: number,
  87076. /**
  87077. * How much to randomize the particle direction [0-1].
  87078. */
  87079. directionRandomizer?: number);
  87080. /**
  87081. * Called by the particle System when the direction is computed for the created particle.
  87082. * @param worldMatrix is the world matrix of the particle system
  87083. * @param directionToUpdate is the direction vector to update with the result
  87084. * @param particle is the particle we are computed the direction for
  87085. */
  87086. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87087. /**
  87088. * Called by the particle System when the position is computed for the created particle.
  87089. * @param worldMatrix is the world matrix of the particle system
  87090. * @param positionToUpdate is the position vector to update with the result
  87091. * @param particle is the particle we are computed the position for
  87092. */
  87093. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87094. /**
  87095. * Clones the current emitter and returns a copy of it
  87096. * @returns the new emitter
  87097. */
  87098. clone(): HemisphericParticleEmitter;
  87099. /**
  87100. * Called by the GPUParticleSystem to setup the update shader
  87101. * @param effect defines the update shader
  87102. */
  87103. applyToShader(effect: Effect): void;
  87104. /**
  87105. * Returns a string to use to update the GPU particles update shader
  87106. * @returns a string containng the defines string
  87107. */
  87108. getEffectDefines(): string;
  87109. /**
  87110. * Returns the string "HemisphericParticleEmitter"
  87111. * @returns a string containing the class name
  87112. */
  87113. getClassName(): string;
  87114. /**
  87115. * Serializes the particle system to a JSON object.
  87116. * @returns the JSON object
  87117. */
  87118. serialize(): any;
  87119. /**
  87120. * Parse properties from a JSON object
  87121. * @param serializationObject defines the JSON object
  87122. */
  87123. parse(serializationObject: any): void;
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /**
  87128. * Particle emitter emitting particles from a point.
  87129. * It emits the particles randomly between 2 given directions.
  87130. */
  87131. export class PointParticleEmitter implements IParticleEmitterType {
  87132. /**
  87133. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87134. */
  87135. direction1: Vector3;
  87136. /**
  87137. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87138. */
  87139. direction2: Vector3;
  87140. /**
  87141. * Creates a new instance PointParticleEmitter
  87142. */
  87143. constructor();
  87144. /**
  87145. * Called by the particle System when the direction is computed for the created particle.
  87146. * @param worldMatrix is the world matrix of the particle system
  87147. * @param directionToUpdate is the direction vector to update with the result
  87148. * @param particle is the particle we are computed the direction for
  87149. */
  87150. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87151. /**
  87152. * Called by the particle System when the position is computed for the created particle.
  87153. * @param worldMatrix is the world matrix of the particle system
  87154. * @param positionToUpdate is the position vector to update with the result
  87155. * @param particle is the particle we are computed the position for
  87156. */
  87157. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87158. /**
  87159. * Clones the current emitter and returns a copy of it
  87160. * @returns the new emitter
  87161. */
  87162. clone(): PointParticleEmitter;
  87163. /**
  87164. * Called by the GPUParticleSystem to setup the update shader
  87165. * @param effect defines the update shader
  87166. */
  87167. applyToShader(effect: Effect): void;
  87168. /**
  87169. * Returns a string to use to update the GPU particles update shader
  87170. * @returns a string containng the defines string
  87171. */
  87172. getEffectDefines(): string;
  87173. /**
  87174. * Returns the string "PointParticleEmitter"
  87175. * @returns a string containing the class name
  87176. */
  87177. getClassName(): string;
  87178. /**
  87179. * Serializes the particle system to a JSON object.
  87180. * @returns the JSON object
  87181. */
  87182. serialize(): any;
  87183. /**
  87184. * Parse properties from a JSON object
  87185. * @param serializationObject defines the JSON object
  87186. */
  87187. parse(serializationObject: any): void;
  87188. }
  87189. }
  87190. declare module BABYLON {
  87191. /**
  87192. * Particle emitter emitting particles from the inside of a sphere.
  87193. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87194. */
  87195. export class SphereParticleEmitter implements IParticleEmitterType {
  87196. /**
  87197. * The radius of the emission sphere.
  87198. */
  87199. radius: number;
  87200. /**
  87201. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87202. */
  87203. radiusRange: number;
  87204. /**
  87205. * How much to randomize the particle direction [0-1].
  87206. */
  87207. directionRandomizer: number;
  87208. /**
  87209. * Creates a new instance SphereParticleEmitter
  87210. * @param radius the radius of the emission sphere (1 by default)
  87211. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87212. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87213. */
  87214. constructor(
  87215. /**
  87216. * The radius of the emission sphere.
  87217. */
  87218. radius?: number,
  87219. /**
  87220. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87221. */
  87222. radiusRange?: number,
  87223. /**
  87224. * How much to randomize the particle direction [0-1].
  87225. */
  87226. directionRandomizer?: number);
  87227. /**
  87228. * Called by the particle System when the direction is computed for the created particle.
  87229. * @param worldMatrix is the world matrix of the particle system
  87230. * @param directionToUpdate is the direction vector to update with the result
  87231. * @param particle is the particle we are computed the direction for
  87232. */
  87233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87234. /**
  87235. * Called by the particle System when the position is computed for the created particle.
  87236. * @param worldMatrix is the world matrix of the particle system
  87237. * @param positionToUpdate is the position vector to update with the result
  87238. * @param particle is the particle we are computed the position for
  87239. */
  87240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87241. /**
  87242. * Clones the current emitter and returns a copy of it
  87243. * @returns the new emitter
  87244. */
  87245. clone(): SphereParticleEmitter;
  87246. /**
  87247. * Called by the GPUParticleSystem to setup the update shader
  87248. * @param effect defines the update shader
  87249. */
  87250. applyToShader(effect: Effect): void;
  87251. /**
  87252. * Returns a string to use to update the GPU particles update shader
  87253. * @returns a string containng the defines string
  87254. */
  87255. getEffectDefines(): string;
  87256. /**
  87257. * Returns the string "SphereParticleEmitter"
  87258. * @returns a string containing the class name
  87259. */
  87260. getClassName(): string;
  87261. /**
  87262. * Serializes the particle system to a JSON object.
  87263. * @returns the JSON object
  87264. */
  87265. serialize(): any;
  87266. /**
  87267. * Parse properties from a JSON object
  87268. * @param serializationObject defines the JSON object
  87269. */
  87270. parse(serializationObject: any): void;
  87271. }
  87272. /**
  87273. * Particle emitter emitting particles from the inside of a sphere.
  87274. * It emits the particles randomly between two vectors.
  87275. */
  87276. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87277. /**
  87278. * The min limit of the emission direction.
  87279. */
  87280. direction1: Vector3;
  87281. /**
  87282. * The max limit of the emission direction.
  87283. */
  87284. direction2: Vector3;
  87285. /**
  87286. * Creates a new instance SphereDirectedParticleEmitter
  87287. * @param radius the radius of the emission sphere (1 by default)
  87288. * @param direction1 the min limit of the emission direction (up vector by default)
  87289. * @param direction2 the max limit of the emission direction (up vector by default)
  87290. */
  87291. constructor(radius?: number,
  87292. /**
  87293. * The min limit of the emission direction.
  87294. */
  87295. direction1?: Vector3,
  87296. /**
  87297. * The max limit of the emission direction.
  87298. */
  87299. direction2?: Vector3);
  87300. /**
  87301. * Called by the particle System when the direction is computed for the created particle.
  87302. * @param worldMatrix is the world matrix of the particle system
  87303. * @param directionToUpdate is the direction vector to update with the result
  87304. * @param particle is the particle we are computed the direction for
  87305. */
  87306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87307. /**
  87308. * Clones the current emitter and returns a copy of it
  87309. * @returns the new emitter
  87310. */
  87311. clone(): SphereDirectedParticleEmitter;
  87312. /**
  87313. * Called by the GPUParticleSystem to setup the update shader
  87314. * @param effect defines the update shader
  87315. */
  87316. applyToShader(effect: Effect): void;
  87317. /**
  87318. * Returns a string to use to update the GPU particles update shader
  87319. * @returns a string containng the defines string
  87320. */
  87321. getEffectDefines(): string;
  87322. /**
  87323. * Returns the string "SphereDirectedParticleEmitter"
  87324. * @returns a string containing the class name
  87325. */
  87326. getClassName(): string;
  87327. /**
  87328. * Serializes the particle system to a JSON object.
  87329. * @returns the JSON object
  87330. */
  87331. serialize(): any;
  87332. /**
  87333. * Parse properties from a JSON object
  87334. * @param serializationObject defines the JSON object
  87335. */
  87336. parse(serializationObject: any): void;
  87337. }
  87338. }
  87339. declare module BABYLON {
  87340. /**
  87341. * Interface representing a particle system in Babylon.js.
  87342. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87343. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87344. */
  87345. export interface IParticleSystem {
  87346. /**
  87347. * List of animations used by the particle system.
  87348. */
  87349. animations: Animation[];
  87350. /**
  87351. * The id of the Particle system.
  87352. */
  87353. id: string;
  87354. /**
  87355. * The name of the Particle system.
  87356. */
  87357. name: string;
  87358. /**
  87359. * The emitter represents the Mesh or position we are attaching the particle system to.
  87360. */
  87361. emitter: Nullable<AbstractMesh | Vector3>;
  87362. /**
  87363. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87364. */
  87365. isBillboardBased: boolean;
  87366. /**
  87367. * The rendering group used by the Particle system to chose when to render.
  87368. */
  87369. renderingGroupId: number;
  87370. /**
  87371. * The layer mask we are rendering the particles through.
  87372. */
  87373. layerMask: number;
  87374. /**
  87375. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87376. */
  87377. updateSpeed: number;
  87378. /**
  87379. * The amount of time the particle system is running (depends of the overall update speed).
  87380. */
  87381. targetStopDuration: number;
  87382. /**
  87383. * The texture used to render each particle. (this can be a spritesheet)
  87384. */
  87385. particleTexture: Nullable<Texture>;
  87386. /**
  87387. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87388. */
  87389. blendMode: number;
  87390. /**
  87391. * Minimum life time of emitting particles.
  87392. */
  87393. minLifeTime: number;
  87394. /**
  87395. * Maximum life time of emitting particles.
  87396. */
  87397. maxLifeTime: number;
  87398. /**
  87399. * Minimum Size of emitting particles.
  87400. */
  87401. minSize: number;
  87402. /**
  87403. * Maximum Size of emitting particles.
  87404. */
  87405. maxSize: number;
  87406. /**
  87407. * Minimum scale of emitting particles on X axis.
  87408. */
  87409. minScaleX: number;
  87410. /**
  87411. * Maximum scale of emitting particles on X axis.
  87412. */
  87413. maxScaleX: number;
  87414. /**
  87415. * Minimum scale of emitting particles on Y axis.
  87416. */
  87417. minScaleY: number;
  87418. /**
  87419. * Maximum scale of emitting particles on Y axis.
  87420. */
  87421. maxScaleY: number;
  87422. /**
  87423. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87424. */
  87425. color1: Color4;
  87426. /**
  87427. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87428. */
  87429. color2: Color4;
  87430. /**
  87431. * Color the particle will have at the end of its lifetime.
  87432. */
  87433. colorDead: Color4;
  87434. /**
  87435. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87436. */
  87437. emitRate: number;
  87438. /**
  87439. * You can use gravity if you want to give an orientation to your particles.
  87440. */
  87441. gravity: Vector3;
  87442. /**
  87443. * Minimum power of emitting particles.
  87444. */
  87445. minEmitPower: number;
  87446. /**
  87447. * Maximum power of emitting particles.
  87448. */
  87449. maxEmitPower: number;
  87450. /**
  87451. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87452. */
  87453. minAngularSpeed: number;
  87454. /**
  87455. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87456. */
  87457. maxAngularSpeed: number;
  87458. /**
  87459. * Gets or sets the minimal initial rotation in radians.
  87460. */
  87461. minInitialRotation: number;
  87462. /**
  87463. * Gets or sets the maximal initial rotation in radians.
  87464. */
  87465. maxInitialRotation: number;
  87466. /**
  87467. * The particle emitter type defines the emitter used by the particle system.
  87468. * It can be for example box, sphere, or cone...
  87469. */
  87470. particleEmitterType: Nullable<IParticleEmitterType>;
  87471. /**
  87472. * Defines the delay in milliseconds before starting the system (0 by default)
  87473. */
  87474. startDelay: number;
  87475. /**
  87476. * 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
  87477. */
  87478. preWarmCycles: number;
  87479. /**
  87480. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87481. */
  87482. preWarmStepOffset: number;
  87483. /**
  87484. * 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)
  87485. */
  87486. spriteCellChangeSpeed: number;
  87487. /**
  87488. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87489. */
  87490. startSpriteCellID: number;
  87491. /**
  87492. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87493. */
  87494. endSpriteCellID: number;
  87495. /**
  87496. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87497. */
  87498. spriteCellWidth: number;
  87499. /**
  87500. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87501. */
  87502. spriteCellHeight: number;
  87503. /**
  87504. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87505. */
  87506. spriteRandomStartCell: boolean;
  87507. /**
  87508. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87509. */
  87510. isAnimationSheetEnabled: boolean;
  87511. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87512. translationPivot: Vector2;
  87513. /**
  87514. * Gets or sets a texture used to add random noise to particle positions
  87515. */
  87516. noiseTexture: Nullable<BaseTexture>;
  87517. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87518. noiseStrength: Vector3;
  87519. /**
  87520. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87521. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87522. */
  87523. billboardMode: number;
  87524. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87525. limitVelocityDamping: number;
  87526. /**
  87527. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87528. */
  87529. beginAnimationOnStart: boolean;
  87530. /**
  87531. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87532. */
  87533. beginAnimationFrom: number;
  87534. /**
  87535. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87536. */
  87537. beginAnimationTo: number;
  87538. /**
  87539. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87540. */
  87541. beginAnimationLoop: boolean;
  87542. /**
  87543. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87544. */
  87545. disposeOnStop: boolean;
  87546. /**
  87547. * Gets the maximum number of particles active at the same time.
  87548. * @returns The max number of active particles.
  87549. */
  87550. getCapacity(): number;
  87551. /**
  87552. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87553. * @returns True if it has been started, otherwise false.
  87554. */
  87555. isStarted(): boolean;
  87556. /**
  87557. * Animates the particle system for this frame.
  87558. */
  87559. animate(): void;
  87560. /**
  87561. * Renders the particle system in its current state.
  87562. * @returns the current number of particles
  87563. */
  87564. render(): number;
  87565. /**
  87566. * Dispose the particle system and frees its associated resources.
  87567. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87568. */
  87569. dispose(disposeTexture?: boolean): void;
  87570. /**
  87571. * Clones the particle system.
  87572. * @param name The name of the cloned object
  87573. * @param newEmitter The new emitter to use
  87574. * @returns the cloned particle system
  87575. */
  87576. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87577. /**
  87578. * Serializes the particle system to a JSON object.
  87579. * @returns the JSON object
  87580. */
  87581. serialize(): any;
  87582. /**
  87583. * Rebuild the particle system
  87584. */
  87585. rebuild(): void;
  87586. /**
  87587. * Starts the particle system and begins to emit
  87588. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87589. */
  87590. start(delay?: number): void;
  87591. /**
  87592. * Stops the particle system.
  87593. */
  87594. stop(): void;
  87595. /**
  87596. * Remove all active particles
  87597. */
  87598. reset(): void;
  87599. /**
  87600. * Is this system ready to be used/rendered
  87601. * @return true if the system is ready
  87602. */
  87603. isReady(): boolean;
  87604. /**
  87605. * Adds a new color gradient
  87606. * @param gradient defines the gradient to use (between 0 and 1)
  87607. * @param color1 defines the color to affect to the specified gradient
  87608. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87609. * @returns the current particle system
  87610. */
  87611. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87612. /**
  87613. * Remove a specific color gradient
  87614. * @param gradient defines the gradient to remove
  87615. * @returns the current particle system
  87616. */
  87617. removeColorGradient(gradient: number): IParticleSystem;
  87618. /**
  87619. * Adds a new size gradient
  87620. * @param gradient defines the gradient to use (between 0 and 1)
  87621. * @param factor defines the size factor to affect to the specified gradient
  87622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87623. * @returns the current particle system
  87624. */
  87625. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87626. /**
  87627. * Remove a specific size gradient
  87628. * @param gradient defines the gradient to remove
  87629. * @returns the current particle system
  87630. */
  87631. removeSizeGradient(gradient: number): IParticleSystem;
  87632. /**
  87633. * Gets the current list of color gradients.
  87634. * You must use addColorGradient and removeColorGradient to udpate this list
  87635. * @returns the list of color gradients
  87636. */
  87637. getColorGradients(): Nullable<Array<ColorGradient>>;
  87638. /**
  87639. * Gets the current list of size gradients.
  87640. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87641. * @returns the list of size gradients
  87642. */
  87643. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87644. /**
  87645. * Gets the current list of angular speed gradients.
  87646. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87647. * @returns the list of angular speed gradients
  87648. */
  87649. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87650. /**
  87651. * Adds a new angular speed gradient
  87652. * @param gradient defines the gradient to use (between 0 and 1)
  87653. * @param factor defines the angular speed to affect to the specified gradient
  87654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87655. * @returns the current particle system
  87656. */
  87657. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87658. /**
  87659. * Remove a specific angular speed gradient
  87660. * @param gradient defines the gradient to remove
  87661. * @returns the current particle system
  87662. */
  87663. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87664. /**
  87665. * Gets the current list of velocity gradients.
  87666. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87667. * @returns the list of velocity gradients
  87668. */
  87669. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87670. /**
  87671. * Adds a new velocity gradient
  87672. * @param gradient defines the gradient to use (between 0 and 1)
  87673. * @param factor defines the velocity to affect to the specified gradient
  87674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87675. * @returns the current particle system
  87676. */
  87677. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87678. /**
  87679. * Remove a specific velocity gradient
  87680. * @param gradient defines the gradient to remove
  87681. * @returns the current particle system
  87682. */
  87683. removeVelocityGradient(gradient: number): IParticleSystem;
  87684. /**
  87685. * Gets the current list of limit velocity gradients.
  87686. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87687. * @returns the list of limit velocity gradients
  87688. */
  87689. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87690. /**
  87691. * Adds a new limit velocity gradient
  87692. * @param gradient defines the gradient to use (between 0 and 1)
  87693. * @param factor defines the limit velocity to affect to the specified gradient
  87694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87695. * @returns the current particle system
  87696. */
  87697. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87698. /**
  87699. * Remove a specific limit velocity gradient
  87700. * @param gradient defines the gradient to remove
  87701. * @returns the current particle system
  87702. */
  87703. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87704. /**
  87705. * Adds a new drag gradient
  87706. * @param gradient defines the gradient to use (between 0 and 1)
  87707. * @param factor defines the drag to affect to the specified gradient
  87708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87709. * @returns the current particle system
  87710. */
  87711. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87712. /**
  87713. * Remove a specific drag gradient
  87714. * @param gradient defines the gradient to remove
  87715. * @returns the current particle system
  87716. */
  87717. removeDragGradient(gradient: number): IParticleSystem;
  87718. /**
  87719. * Gets the current list of drag gradients.
  87720. * You must use addDragGradient and removeDragGradient to udpate this list
  87721. * @returns the list of drag gradients
  87722. */
  87723. getDragGradients(): Nullable<Array<FactorGradient>>;
  87724. /**
  87725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87726. * @param gradient defines the gradient to use (between 0 and 1)
  87727. * @param factor defines the emit rate to affect to the specified gradient
  87728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87729. * @returns the current particle system
  87730. */
  87731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87732. /**
  87733. * Remove a specific emit rate gradient
  87734. * @param gradient defines the gradient to remove
  87735. * @returns the current particle system
  87736. */
  87737. removeEmitRateGradient(gradient: number): IParticleSystem;
  87738. /**
  87739. * Gets the current list of emit rate gradients.
  87740. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87741. * @returns the list of emit rate gradients
  87742. */
  87743. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87744. /**
  87745. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87746. * @param gradient defines the gradient to use (between 0 and 1)
  87747. * @param factor defines the start size to affect to the specified gradient
  87748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87749. * @returns the current particle system
  87750. */
  87751. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87752. /**
  87753. * Remove a specific start size gradient
  87754. * @param gradient defines the gradient to remove
  87755. * @returns the current particle system
  87756. */
  87757. removeStartSizeGradient(gradient: number): IParticleSystem;
  87758. /**
  87759. * Gets the current list of start size gradients.
  87760. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87761. * @returns the list of start size gradients
  87762. */
  87763. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87764. /**
  87765. * Adds a new life time gradient
  87766. * @param gradient defines the gradient to use (between 0 and 1)
  87767. * @param factor defines the life time factor to affect to the specified gradient
  87768. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87769. * @returns the current particle system
  87770. */
  87771. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87772. /**
  87773. * Remove a specific life time gradient
  87774. * @param gradient defines the gradient to remove
  87775. * @returns the current particle system
  87776. */
  87777. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87778. /**
  87779. * Gets the current list of life time gradients.
  87780. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87781. * @returns the list of life time gradients
  87782. */
  87783. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87784. /**
  87785. * Gets the current list of color gradients.
  87786. * You must use addColorGradient and removeColorGradient to udpate this list
  87787. * @returns the list of color gradients
  87788. */
  87789. getColorGradients(): Nullable<Array<ColorGradient>>;
  87790. /**
  87791. * Adds a new ramp gradient used to remap particle colors
  87792. * @param gradient defines the gradient to use (between 0 and 1)
  87793. * @param color defines the color to affect to the specified gradient
  87794. * @returns the current particle system
  87795. */
  87796. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87797. /**
  87798. * Gets the current list of ramp gradients.
  87799. * You must use addRampGradient and removeRampGradient to udpate this list
  87800. * @returns the list of ramp gradients
  87801. */
  87802. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87803. /** Gets or sets a boolean indicating that ramp gradients must be used
  87804. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87805. */
  87806. useRampGradients: boolean;
  87807. /**
  87808. * Adds a new color remap gradient
  87809. * @param gradient defines the gradient to use (between 0 and 1)
  87810. * @param min defines the color remap minimal range
  87811. * @param max defines the color remap maximal range
  87812. * @returns the current particle system
  87813. */
  87814. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87815. /**
  87816. * Gets the current list of color remap gradients.
  87817. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87818. * @returns the list of color remap gradients
  87819. */
  87820. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87821. /**
  87822. * Adds a new alpha remap gradient
  87823. * @param gradient defines the gradient to use (between 0 and 1)
  87824. * @param min defines the alpha remap minimal range
  87825. * @param max defines the alpha remap maximal range
  87826. * @returns the current particle system
  87827. */
  87828. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87829. /**
  87830. * Gets the current list of alpha remap gradients.
  87831. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87832. * @returns the list of alpha remap gradients
  87833. */
  87834. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87835. /**
  87836. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87839. * @returns the emitter
  87840. */
  87841. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87842. /**
  87843. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87844. * @param radius The radius of the hemisphere to emit from
  87845. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87846. * @returns the emitter
  87847. */
  87848. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87849. /**
  87850. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87851. * @param radius The radius of the sphere to emit from
  87852. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87853. * @returns the emitter
  87854. */
  87855. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87856. /**
  87857. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87858. * @param radius The radius of the sphere to emit from
  87859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87861. * @returns the emitter
  87862. */
  87863. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87864. /**
  87865. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87866. * @param radius The radius of the emission cylinder
  87867. * @param height The height of the emission cylinder
  87868. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87869. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87870. * @returns the emitter
  87871. */
  87872. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87873. /**
  87874. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87875. * @param radius The radius of the cylinder to emit from
  87876. * @param height The height of the emission cylinder
  87877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87878. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87879. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87880. * @returns the emitter
  87881. */
  87882. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87883. /**
  87884. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87885. * @param radius The radius of the cone to emit from
  87886. * @param angle The base angle of the cone
  87887. * @returns the emitter
  87888. */
  87889. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87890. /**
  87891. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87892. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87893. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87894. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87895. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87896. * @returns the emitter
  87897. */
  87898. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87899. /**
  87900. * Get hosting scene
  87901. * @returns the scene
  87902. */
  87903. getScene(): Scene;
  87904. }
  87905. }
  87906. declare module BABYLON {
  87907. /**
  87908. * Creates an instance based on a source mesh.
  87909. */
  87910. export class InstancedMesh extends AbstractMesh {
  87911. private _sourceMesh;
  87912. private _currentLOD;
  87913. /** @hidden */
  87914. _indexInSourceMeshInstanceArray: number;
  87915. constructor(name: string, source: Mesh);
  87916. /**
  87917. * Returns the string "InstancedMesh".
  87918. */
  87919. getClassName(): string;
  87920. /** Gets the list of lights affecting that mesh */
  87921. readonly lightSources: Light[];
  87922. _resyncLightSources(): void;
  87923. _resyncLightSource(light: Light): void;
  87924. _removeLightSource(light: Light, dispose: boolean): void;
  87925. /**
  87926. * If the source mesh receives shadows
  87927. */
  87928. readonly receiveShadows: boolean;
  87929. /**
  87930. * The material of the source mesh
  87931. */
  87932. readonly material: Nullable<Material>;
  87933. /**
  87934. * Visibility of the source mesh
  87935. */
  87936. readonly visibility: number;
  87937. /**
  87938. * Skeleton of the source mesh
  87939. */
  87940. readonly skeleton: Nullable<Skeleton>;
  87941. /**
  87942. * Rendering ground id of the source mesh
  87943. */
  87944. renderingGroupId: number;
  87945. /**
  87946. * Returns the total number of vertices (integer).
  87947. */
  87948. getTotalVertices(): number;
  87949. /**
  87950. * Returns a positive integer : the total number of indices in this mesh geometry.
  87951. * @returns the numner of indices or zero if the mesh has no geometry.
  87952. */
  87953. getTotalIndices(): number;
  87954. /**
  87955. * The source mesh of the instance
  87956. */
  87957. readonly sourceMesh: Mesh;
  87958. /**
  87959. * Is this node ready to be used/rendered
  87960. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87961. * @return {boolean} is it ready
  87962. */
  87963. isReady(completeCheck?: boolean): boolean;
  87964. /**
  87965. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87966. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87967. * @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.
  87968. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87969. */
  87970. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87971. /**
  87972. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87973. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87974. * The `data` are either a numeric array either a Float32Array.
  87975. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87976. * 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).
  87977. * Note that a new underlying VertexBuffer object is created each call.
  87978. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87979. *
  87980. * Possible `kind` values :
  87981. * - VertexBuffer.PositionKind
  87982. * - VertexBuffer.UVKind
  87983. * - VertexBuffer.UV2Kind
  87984. * - VertexBuffer.UV3Kind
  87985. * - VertexBuffer.UV4Kind
  87986. * - VertexBuffer.UV5Kind
  87987. * - VertexBuffer.UV6Kind
  87988. * - VertexBuffer.ColorKind
  87989. * - VertexBuffer.MatricesIndicesKind
  87990. * - VertexBuffer.MatricesIndicesExtraKind
  87991. * - VertexBuffer.MatricesWeightsKind
  87992. * - VertexBuffer.MatricesWeightsExtraKind
  87993. *
  87994. * Returns the Mesh.
  87995. */
  87996. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87997. /**
  87998. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87999. * If the mesh has no geometry, it is simply returned as it is.
  88000. * The `data` are either a numeric array either a Float32Array.
  88001. * No new underlying VertexBuffer object is created.
  88002. * 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.
  88003. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88004. *
  88005. * Possible `kind` values :
  88006. * - VertexBuffer.PositionKind
  88007. * - VertexBuffer.UVKind
  88008. * - VertexBuffer.UV2Kind
  88009. * - VertexBuffer.UV3Kind
  88010. * - VertexBuffer.UV4Kind
  88011. * - VertexBuffer.UV5Kind
  88012. * - VertexBuffer.UV6Kind
  88013. * - VertexBuffer.ColorKind
  88014. * - VertexBuffer.MatricesIndicesKind
  88015. * - VertexBuffer.MatricesIndicesExtraKind
  88016. * - VertexBuffer.MatricesWeightsKind
  88017. * - VertexBuffer.MatricesWeightsExtraKind
  88018. *
  88019. * Returns the Mesh.
  88020. */
  88021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88022. /**
  88023. * Sets the mesh indices.
  88024. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88025. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88026. * This method creates a new index buffer each call.
  88027. * Returns the Mesh.
  88028. */
  88029. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88030. /**
  88031. * Boolean : True if the mesh owns the requested kind of data.
  88032. */
  88033. isVerticesDataPresent(kind: string): boolean;
  88034. /**
  88035. * Returns an array of indices (IndicesArray).
  88036. */
  88037. getIndices(): Nullable<IndicesArray>;
  88038. readonly _positions: Nullable<Vector3[]>;
  88039. /**
  88040. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88041. * This means the mesh underlying bounding box and sphere are recomputed.
  88042. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88043. * @returns the current mesh
  88044. */
  88045. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88046. /** @hidden */
  88047. _preActivate(): InstancedMesh;
  88048. /** @hidden */
  88049. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88050. /** @hidden */
  88051. _postActivate(): void;
  88052. getWorldMatrix(): Matrix;
  88053. readonly isAnInstance: boolean;
  88054. /**
  88055. * Returns the current associated LOD AbstractMesh.
  88056. */
  88057. getLOD(camera: Camera): AbstractMesh;
  88058. /** @hidden */
  88059. _syncSubMeshes(): InstancedMesh;
  88060. /** @hidden */
  88061. _generatePointsArray(): boolean;
  88062. /**
  88063. * Creates a new InstancedMesh from the current mesh.
  88064. * - name (string) : the cloned mesh name
  88065. * - newParent (optional Node) : the optional Node to parent the clone to.
  88066. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88067. *
  88068. * Returns the clone.
  88069. */
  88070. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88071. /**
  88072. * Disposes the InstancedMesh.
  88073. * Returns nothing.
  88074. */
  88075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88076. }
  88077. interface Mesh {
  88078. /**
  88079. * Register a custom buffer that will be instanced
  88080. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88081. * @param kind defines the buffer kind
  88082. * @param stride defines the stride in floats
  88083. */
  88084. registerInstancedBuffer(kind: string, stride: number): void;
  88085. /** @hidden */
  88086. _userInstancedBuffersStorage: {
  88087. data: {
  88088. [key: string]: Float32Array;
  88089. };
  88090. sizes: {
  88091. [key: string]: number;
  88092. };
  88093. vertexBuffers: {
  88094. [key: string]: Nullable<VertexBuffer>;
  88095. };
  88096. strides: {
  88097. [key: string]: number;
  88098. };
  88099. };
  88100. }
  88101. interface AbstractMesh {
  88102. /**
  88103. * Object used to store instanced buffers defined by user
  88104. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88105. */
  88106. instancedBuffers: {
  88107. [key: string]: any;
  88108. };
  88109. }
  88110. }
  88111. declare module BABYLON {
  88112. /**
  88113. * Defines the options associated with the creation of a shader material.
  88114. */
  88115. export interface IShaderMaterialOptions {
  88116. /**
  88117. * Does the material work in alpha blend mode
  88118. */
  88119. needAlphaBlending: boolean;
  88120. /**
  88121. * Does the material work in alpha test mode
  88122. */
  88123. needAlphaTesting: boolean;
  88124. /**
  88125. * The list of attribute names used in the shader
  88126. */
  88127. attributes: string[];
  88128. /**
  88129. * The list of unifrom names used in the shader
  88130. */
  88131. uniforms: string[];
  88132. /**
  88133. * The list of UBO names used in the shader
  88134. */
  88135. uniformBuffers: string[];
  88136. /**
  88137. * The list of sampler names used in the shader
  88138. */
  88139. samplers: string[];
  88140. /**
  88141. * The list of defines used in the shader
  88142. */
  88143. defines: string[];
  88144. }
  88145. /**
  88146. * 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.
  88147. *
  88148. * This returned material effects how the mesh will look based on the code in the shaders.
  88149. *
  88150. * @see http://doc.babylonjs.com/how_to/shader_material
  88151. */
  88152. export class ShaderMaterial extends Material {
  88153. private _shaderPath;
  88154. private _options;
  88155. private _textures;
  88156. private _textureArrays;
  88157. private _floats;
  88158. private _ints;
  88159. private _floatsArrays;
  88160. private _colors3;
  88161. private _colors3Arrays;
  88162. private _colors4;
  88163. private _colors4Arrays;
  88164. private _vectors2;
  88165. private _vectors3;
  88166. private _vectors4;
  88167. private _matrices;
  88168. private _matrixArrays;
  88169. private _matrices3x3;
  88170. private _matrices2x2;
  88171. private _vectors2Arrays;
  88172. private _vectors3Arrays;
  88173. private _vectors4Arrays;
  88174. private _cachedWorldViewMatrix;
  88175. private _cachedWorldViewProjectionMatrix;
  88176. private _renderId;
  88177. private _multiview;
  88178. /**
  88179. * Instantiate a new shader material.
  88180. * 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.
  88181. * This returned material effects how the mesh will look based on the code in the shaders.
  88182. * @see http://doc.babylonjs.com/how_to/shader_material
  88183. * @param name Define the name of the material in the scene
  88184. * @param scene Define the scene the material belongs to
  88185. * @param shaderPath Defines the route to the shader code in one of three ways:
  88186. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88187. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88188. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88189. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88190. * @param options Define the options used to create the shader
  88191. */
  88192. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88193. /**
  88194. * Gets the shader path used to define the shader code
  88195. * It can be modified to trigger a new compilation
  88196. */
  88197. /**
  88198. * Sets the shader path used to define the shader code
  88199. * It can be modified to trigger a new compilation
  88200. */
  88201. shaderPath: any;
  88202. /**
  88203. * Gets the options used to compile the shader.
  88204. * They can be modified to trigger a new compilation
  88205. */
  88206. readonly options: IShaderMaterialOptions;
  88207. /**
  88208. * Gets the current class name of the material e.g. "ShaderMaterial"
  88209. * Mainly use in serialization.
  88210. * @returns the class name
  88211. */
  88212. getClassName(): string;
  88213. /**
  88214. * Specifies if the material will require alpha blending
  88215. * @returns a boolean specifying if alpha blending is needed
  88216. */
  88217. needAlphaBlending(): boolean;
  88218. /**
  88219. * Specifies if this material should be rendered in alpha test mode
  88220. * @returns a boolean specifying if an alpha test is needed.
  88221. */
  88222. needAlphaTesting(): boolean;
  88223. private _checkUniform;
  88224. /**
  88225. * Set a texture in the shader.
  88226. * @param name Define the name of the uniform samplers as defined in the shader
  88227. * @param texture Define the texture to bind to this sampler
  88228. * @return the material itself allowing "fluent" like uniform updates
  88229. */
  88230. setTexture(name: string, texture: Texture): ShaderMaterial;
  88231. /**
  88232. * Set a texture array in the shader.
  88233. * @param name Define the name of the uniform sampler array as defined in the shader
  88234. * @param textures Define the list of textures to bind to this sampler
  88235. * @return the material itself allowing "fluent" like uniform updates
  88236. */
  88237. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88238. /**
  88239. * Set a float in the shader.
  88240. * @param name Define the name of the uniform as defined in the shader
  88241. * @param value Define the value to give to the uniform
  88242. * @return the material itself allowing "fluent" like uniform updates
  88243. */
  88244. setFloat(name: string, value: number): ShaderMaterial;
  88245. /**
  88246. * Set a int in the shader.
  88247. * @param name Define the name of the uniform as defined in the shader
  88248. * @param value Define the value to give to the uniform
  88249. * @return the material itself allowing "fluent" like uniform updates
  88250. */
  88251. setInt(name: string, value: number): ShaderMaterial;
  88252. /**
  88253. * Set an array of floats in the shader.
  88254. * @param name Define the name of the uniform as defined in the shader
  88255. * @param value Define the value to give to the uniform
  88256. * @return the material itself allowing "fluent" like uniform updates
  88257. */
  88258. setFloats(name: string, value: number[]): ShaderMaterial;
  88259. /**
  88260. * Set a vec3 in the shader from a Color3.
  88261. * @param name Define the name of the uniform as defined in the shader
  88262. * @param value Define the value to give to the uniform
  88263. * @return the material itself allowing "fluent" like uniform updates
  88264. */
  88265. setColor3(name: string, value: Color3): ShaderMaterial;
  88266. /**
  88267. * Set a vec3 array in the shader from a Color3 array.
  88268. * @param name Define the name of the uniform as defined in the shader
  88269. * @param value Define the value to give to the uniform
  88270. * @return the material itself allowing "fluent" like uniform updates
  88271. */
  88272. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88273. /**
  88274. * Set a vec4 in the shader from a Color4.
  88275. * @param name Define the name of the uniform as defined in the shader
  88276. * @param value Define the value to give to the uniform
  88277. * @return the material itself allowing "fluent" like uniform updates
  88278. */
  88279. setColor4(name: string, value: Color4): ShaderMaterial;
  88280. /**
  88281. * Set a vec4 array in the shader from a Color4 array.
  88282. * @param name Define the name of the uniform as defined in the shader
  88283. * @param value Define the value to give to the uniform
  88284. * @return the material itself allowing "fluent" like uniform updates
  88285. */
  88286. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88287. /**
  88288. * Set a vec2 in the shader from a Vector2.
  88289. * @param name Define the name of the uniform as defined in the shader
  88290. * @param value Define the value to give to the uniform
  88291. * @return the material itself allowing "fluent" like uniform updates
  88292. */
  88293. setVector2(name: string, value: Vector2): ShaderMaterial;
  88294. /**
  88295. * Set a vec3 in the shader from a Vector3.
  88296. * @param name Define the name of the uniform as defined in the shader
  88297. * @param value Define the value to give to the uniform
  88298. * @return the material itself allowing "fluent" like uniform updates
  88299. */
  88300. setVector3(name: string, value: Vector3): ShaderMaterial;
  88301. /**
  88302. * Set a vec4 in the shader from a Vector4.
  88303. * @param name Define the name of the uniform as defined in the shader
  88304. * @param value Define the value to give to the uniform
  88305. * @return the material itself allowing "fluent" like uniform updates
  88306. */
  88307. setVector4(name: string, value: Vector4): ShaderMaterial;
  88308. /**
  88309. * Set a mat4 in the shader from a Matrix.
  88310. * @param name Define the name of the uniform as defined in the shader
  88311. * @param value Define the value to give to the uniform
  88312. * @return the material itself allowing "fluent" like uniform updates
  88313. */
  88314. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88315. /**
  88316. * Set a float32Array in the shader from a matrix array.
  88317. * @param name Define the name of the uniform as defined in the shader
  88318. * @param value Define the value to give to the uniform
  88319. * @return the material itself allowing "fluent" like uniform updates
  88320. */
  88321. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88322. /**
  88323. * Set a mat3 in the shader from a Float32Array.
  88324. * @param name Define the name of the uniform as defined in the shader
  88325. * @param value Define the value to give to the uniform
  88326. * @return the material itself allowing "fluent" like uniform updates
  88327. */
  88328. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88329. /**
  88330. * Set a mat2 in the shader from a Float32Array.
  88331. * @param name Define the name of the uniform as defined in the shader
  88332. * @param value Define the value to give to the uniform
  88333. * @return the material itself allowing "fluent" like uniform updates
  88334. */
  88335. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88336. /**
  88337. * Set a vec2 array in the shader from a number array.
  88338. * @param name Define the name of the uniform as defined in the shader
  88339. * @param value Define the value to give to the uniform
  88340. * @return the material itself allowing "fluent" like uniform updates
  88341. */
  88342. setArray2(name: string, value: number[]): ShaderMaterial;
  88343. /**
  88344. * Set a vec3 array in the shader from a number array.
  88345. * @param name Define the name of the uniform as defined in the shader
  88346. * @param value Define the value to give to the uniform
  88347. * @return the material itself allowing "fluent" like uniform updates
  88348. */
  88349. setArray3(name: string, value: number[]): ShaderMaterial;
  88350. /**
  88351. * Set a vec4 array in the shader from a number array.
  88352. * @param name Define the name of the uniform as defined in the shader
  88353. * @param value Define the value to give to the uniform
  88354. * @return the material itself allowing "fluent" like uniform updates
  88355. */
  88356. setArray4(name: string, value: number[]): ShaderMaterial;
  88357. private _checkCache;
  88358. /**
  88359. * Specifies that the submesh is ready to be used
  88360. * @param mesh defines the mesh to check
  88361. * @param subMesh defines which submesh to check
  88362. * @param useInstances specifies that instances should be used
  88363. * @returns a boolean indicating that the submesh is ready or not
  88364. */
  88365. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88366. /**
  88367. * Checks if the material is ready to render the requested mesh
  88368. * @param mesh Define the mesh to render
  88369. * @param useInstances Define whether or not the material is used with instances
  88370. * @returns true if ready, otherwise false
  88371. */
  88372. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88373. /**
  88374. * Binds the world matrix to the material
  88375. * @param world defines the world transformation matrix
  88376. */
  88377. bindOnlyWorldMatrix(world: Matrix): void;
  88378. /**
  88379. * Binds the material to the mesh
  88380. * @param world defines the world transformation matrix
  88381. * @param mesh defines the mesh to bind the material to
  88382. */
  88383. bind(world: Matrix, mesh?: Mesh): void;
  88384. /**
  88385. * Gets the active textures from the material
  88386. * @returns an array of textures
  88387. */
  88388. getActiveTextures(): BaseTexture[];
  88389. /**
  88390. * Specifies if the material uses a texture
  88391. * @param texture defines the texture to check against the material
  88392. * @returns a boolean specifying if the material uses the texture
  88393. */
  88394. hasTexture(texture: BaseTexture): boolean;
  88395. /**
  88396. * Makes a duplicate of the material, and gives it a new name
  88397. * @param name defines the new name for the duplicated material
  88398. * @returns the cloned material
  88399. */
  88400. clone(name: string): ShaderMaterial;
  88401. /**
  88402. * Disposes the material
  88403. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88404. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88405. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88406. */
  88407. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88408. /**
  88409. * Serializes this material in a JSON representation
  88410. * @returns the serialized material object
  88411. */
  88412. serialize(): any;
  88413. /**
  88414. * Creates a shader material from parsed shader material data
  88415. * @param source defines the JSON represnetation of the material
  88416. * @param scene defines the hosting scene
  88417. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88418. * @returns a new material
  88419. */
  88420. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88421. }
  88422. }
  88423. declare module BABYLON {
  88424. /** @hidden */
  88425. export var colorPixelShader: {
  88426. name: string;
  88427. shader: string;
  88428. };
  88429. }
  88430. declare module BABYLON {
  88431. /** @hidden */
  88432. export var colorVertexShader: {
  88433. name: string;
  88434. shader: string;
  88435. };
  88436. }
  88437. declare module BABYLON {
  88438. /**
  88439. * Line mesh
  88440. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88441. */
  88442. export class LinesMesh extends Mesh {
  88443. /**
  88444. * If vertex color should be applied to the mesh
  88445. */
  88446. readonly useVertexColor?: boolean | undefined;
  88447. /**
  88448. * If vertex alpha should be applied to the mesh
  88449. */
  88450. readonly useVertexAlpha?: boolean | undefined;
  88451. /**
  88452. * Color of the line (Default: White)
  88453. */
  88454. color: Color3;
  88455. /**
  88456. * Alpha of the line (Default: 1)
  88457. */
  88458. alpha: number;
  88459. /**
  88460. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88461. * This margin is expressed in world space coordinates, so its value may vary.
  88462. * Default value is 0.1
  88463. */
  88464. intersectionThreshold: number;
  88465. private _colorShader;
  88466. private color4;
  88467. /**
  88468. * Creates a new LinesMesh
  88469. * @param name defines the name
  88470. * @param scene defines the hosting scene
  88471. * @param parent defines the parent mesh if any
  88472. * @param source defines the optional source LinesMesh used to clone data from
  88473. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88474. * When false, achieved by calling a clone(), also passing False.
  88475. * This will make creation of children, recursive.
  88476. * @param useVertexColor defines if this LinesMesh supports vertex color
  88477. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88478. */
  88479. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88480. /**
  88481. * If vertex color should be applied to the mesh
  88482. */
  88483. useVertexColor?: boolean | undefined,
  88484. /**
  88485. * If vertex alpha should be applied to the mesh
  88486. */
  88487. useVertexAlpha?: boolean | undefined);
  88488. private _addClipPlaneDefine;
  88489. private _removeClipPlaneDefine;
  88490. isReady(): boolean;
  88491. /**
  88492. * Returns the string "LineMesh"
  88493. */
  88494. getClassName(): string;
  88495. /**
  88496. * @hidden
  88497. */
  88498. /**
  88499. * @hidden
  88500. */
  88501. material: Material;
  88502. /**
  88503. * @hidden
  88504. */
  88505. readonly checkCollisions: boolean;
  88506. /** @hidden */
  88507. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88508. /** @hidden */
  88509. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88510. /**
  88511. * Disposes of the line mesh
  88512. * @param doNotRecurse If children should be disposed
  88513. */
  88514. dispose(doNotRecurse?: boolean): void;
  88515. /**
  88516. * Returns a new LineMesh object cloned from the current one.
  88517. */
  88518. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88519. /**
  88520. * Creates a new InstancedLinesMesh object from the mesh model.
  88521. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88522. * @param name defines the name of the new instance
  88523. * @returns a new InstancedLinesMesh
  88524. */
  88525. createInstance(name: string): InstancedLinesMesh;
  88526. }
  88527. /**
  88528. * Creates an instance based on a source LinesMesh
  88529. */
  88530. export class InstancedLinesMesh extends InstancedMesh {
  88531. /**
  88532. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88533. * This margin is expressed in world space coordinates, so its value may vary.
  88534. * Initilized with the intersectionThreshold value of the source LinesMesh
  88535. */
  88536. intersectionThreshold: number;
  88537. constructor(name: string, source: LinesMesh);
  88538. /**
  88539. * Returns the string "InstancedLinesMesh".
  88540. */
  88541. getClassName(): string;
  88542. }
  88543. }
  88544. declare module BABYLON {
  88545. /** @hidden */
  88546. export var linePixelShader: {
  88547. name: string;
  88548. shader: string;
  88549. };
  88550. }
  88551. declare module BABYLON {
  88552. /** @hidden */
  88553. export var lineVertexShader: {
  88554. name: string;
  88555. shader: string;
  88556. };
  88557. }
  88558. declare module BABYLON {
  88559. interface AbstractMesh {
  88560. /**
  88561. * Gets the edgesRenderer associated with the mesh
  88562. */
  88563. edgesRenderer: Nullable<EdgesRenderer>;
  88564. }
  88565. interface LinesMesh {
  88566. /**
  88567. * Enables the edge rendering mode on the mesh.
  88568. * This mode makes the mesh edges visible
  88569. * @param epsilon defines the maximal distance between two angles to detect a face
  88570. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88571. * @returns the currentAbstractMesh
  88572. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88573. */
  88574. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88575. }
  88576. interface InstancedLinesMesh {
  88577. /**
  88578. * Enables the edge rendering mode on the mesh.
  88579. * This mode makes the mesh edges visible
  88580. * @param epsilon defines the maximal distance between two angles to detect a face
  88581. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88582. * @returns the current InstancedLinesMesh
  88583. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88584. */
  88585. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88586. }
  88587. /**
  88588. * Defines the minimum contract an Edges renderer should follow.
  88589. */
  88590. export interface IEdgesRenderer extends IDisposable {
  88591. /**
  88592. * Gets or sets a boolean indicating if the edgesRenderer is active
  88593. */
  88594. isEnabled: boolean;
  88595. /**
  88596. * Renders the edges of the attached mesh,
  88597. */
  88598. render(): void;
  88599. /**
  88600. * Checks wether or not the edges renderer is ready to render.
  88601. * @return true if ready, otherwise false.
  88602. */
  88603. isReady(): boolean;
  88604. }
  88605. /**
  88606. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88607. */
  88608. export class EdgesRenderer implements IEdgesRenderer {
  88609. /**
  88610. * Define the size of the edges with an orthographic camera
  88611. */
  88612. edgesWidthScalerForOrthographic: number;
  88613. /**
  88614. * Define the size of the edges with a perspective camera
  88615. */
  88616. edgesWidthScalerForPerspective: number;
  88617. protected _source: AbstractMesh;
  88618. protected _linesPositions: number[];
  88619. protected _linesNormals: number[];
  88620. protected _linesIndices: number[];
  88621. protected _epsilon: number;
  88622. protected _indicesCount: number;
  88623. protected _lineShader: ShaderMaterial;
  88624. protected _ib: DataBuffer;
  88625. protected _buffers: {
  88626. [key: string]: Nullable<VertexBuffer>;
  88627. };
  88628. protected _checkVerticesInsteadOfIndices: boolean;
  88629. private _meshRebuildObserver;
  88630. private _meshDisposeObserver;
  88631. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88632. isEnabled: boolean;
  88633. /**
  88634. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88635. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88636. * @param source Mesh used to create edges
  88637. * @param epsilon sum of angles in adjacency to check for edge
  88638. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88639. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88640. */
  88641. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88642. protected _prepareRessources(): void;
  88643. /** @hidden */
  88644. _rebuild(): void;
  88645. /**
  88646. * Releases the required resources for the edges renderer
  88647. */
  88648. dispose(): void;
  88649. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88650. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88651. /**
  88652. * Checks if the pair of p0 and p1 is en edge
  88653. * @param faceIndex
  88654. * @param edge
  88655. * @param faceNormals
  88656. * @param p0
  88657. * @param p1
  88658. * @private
  88659. */
  88660. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88661. /**
  88662. * push line into the position, normal and index buffer
  88663. * @protected
  88664. */
  88665. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88666. /**
  88667. * Generates lines edges from adjacencjes
  88668. * @private
  88669. */
  88670. _generateEdgesLines(): void;
  88671. /**
  88672. * Checks wether or not the edges renderer is ready to render.
  88673. * @return true if ready, otherwise false.
  88674. */
  88675. isReady(): boolean;
  88676. /**
  88677. * Renders the edges of the attached mesh,
  88678. */
  88679. render(): void;
  88680. }
  88681. /**
  88682. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88683. */
  88684. export class LineEdgesRenderer extends EdgesRenderer {
  88685. /**
  88686. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88687. * @param source LineMesh used to generate edges
  88688. * @param epsilon not important (specified angle for edge detection)
  88689. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88690. */
  88691. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88692. /**
  88693. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88694. */
  88695. _generateEdgesLines(): void;
  88696. }
  88697. }
  88698. declare module BABYLON {
  88699. /**
  88700. * This represents the object necessary to create a rendering group.
  88701. * This is exclusively used and created by the rendering manager.
  88702. * To modify the behavior, you use the available helpers in your scene or meshes.
  88703. * @hidden
  88704. */
  88705. export class RenderingGroup {
  88706. index: number;
  88707. private static _zeroVector;
  88708. private _scene;
  88709. private _opaqueSubMeshes;
  88710. private _transparentSubMeshes;
  88711. private _alphaTestSubMeshes;
  88712. private _depthOnlySubMeshes;
  88713. private _particleSystems;
  88714. private _spriteManagers;
  88715. private _opaqueSortCompareFn;
  88716. private _alphaTestSortCompareFn;
  88717. private _transparentSortCompareFn;
  88718. private _renderOpaque;
  88719. private _renderAlphaTest;
  88720. private _renderTransparent;
  88721. /** @hidden */
  88722. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88723. onBeforeTransparentRendering: () => void;
  88724. /**
  88725. * Set the opaque sort comparison function.
  88726. * If null the sub meshes will be render in the order they were created
  88727. */
  88728. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88729. /**
  88730. * Set the alpha test sort comparison function.
  88731. * If null the sub meshes will be render in the order they were created
  88732. */
  88733. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88734. /**
  88735. * Set the transparent sort comparison function.
  88736. * If null the sub meshes will be render in the order they were created
  88737. */
  88738. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88739. /**
  88740. * Creates a new rendering group.
  88741. * @param index The rendering group index
  88742. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88743. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88744. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88745. */
  88746. 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>);
  88747. /**
  88748. * Render all the sub meshes contained in the group.
  88749. * @param customRenderFunction Used to override the default render behaviour of the group.
  88750. * @returns true if rendered some submeshes.
  88751. */
  88752. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88753. /**
  88754. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88755. * @param subMeshes The submeshes to render
  88756. */
  88757. private renderOpaqueSorted;
  88758. /**
  88759. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88760. * @param subMeshes The submeshes to render
  88761. */
  88762. private renderAlphaTestSorted;
  88763. /**
  88764. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88765. * @param subMeshes The submeshes to render
  88766. */
  88767. private renderTransparentSorted;
  88768. /**
  88769. * Renders the submeshes in a specified order.
  88770. * @param subMeshes The submeshes to sort before render
  88771. * @param sortCompareFn The comparison function use to sort
  88772. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88773. * @param transparent Specifies to activate blending if true
  88774. */
  88775. private static renderSorted;
  88776. /**
  88777. * Renders the submeshes in the order they were dispatched (no sort applied).
  88778. * @param subMeshes The submeshes to render
  88779. */
  88780. private static renderUnsorted;
  88781. /**
  88782. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88783. * are rendered back to front if in the same alpha index.
  88784. *
  88785. * @param a The first submesh
  88786. * @param b The second submesh
  88787. * @returns The result of the comparison
  88788. */
  88789. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88790. /**
  88791. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88792. * are rendered back to front.
  88793. *
  88794. * @param a The first submesh
  88795. * @param b The second submesh
  88796. * @returns The result of the comparison
  88797. */
  88798. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88799. /**
  88800. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88801. * are rendered front to back (prevent overdraw).
  88802. *
  88803. * @param a The first submesh
  88804. * @param b The second submesh
  88805. * @returns The result of the comparison
  88806. */
  88807. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88808. /**
  88809. * Resets the different lists of submeshes to prepare a new frame.
  88810. */
  88811. prepare(): void;
  88812. dispose(): void;
  88813. /**
  88814. * Inserts the submesh in its correct queue depending on its material.
  88815. * @param subMesh The submesh to dispatch
  88816. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88817. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88818. */
  88819. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88820. dispatchSprites(spriteManager: ISpriteManager): void;
  88821. dispatchParticles(particleSystem: IParticleSystem): void;
  88822. private _renderParticles;
  88823. private _renderSprites;
  88824. }
  88825. }
  88826. declare module BABYLON {
  88827. /**
  88828. * Interface describing the different options available in the rendering manager
  88829. * regarding Auto Clear between groups.
  88830. */
  88831. export interface IRenderingManagerAutoClearSetup {
  88832. /**
  88833. * Defines whether or not autoclear is enable.
  88834. */
  88835. autoClear: boolean;
  88836. /**
  88837. * Defines whether or not to autoclear the depth buffer.
  88838. */
  88839. depth: boolean;
  88840. /**
  88841. * Defines whether or not to autoclear the stencil buffer.
  88842. */
  88843. stencil: boolean;
  88844. }
  88845. /**
  88846. * This class is used by the onRenderingGroupObservable
  88847. */
  88848. export class RenderingGroupInfo {
  88849. /**
  88850. * The Scene that being rendered
  88851. */
  88852. scene: Scene;
  88853. /**
  88854. * The camera currently used for the rendering pass
  88855. */
  88856. camera: Nullable<Camera>;
  88857. /**
  88858. * The ID of the renderingGroup being processed
  88859. */
  88860. renderingGroupId: number;
  88861. }
  88862. /**
  88863. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88864. * It is enable to manage the different groups as well as the different necessary sort functions.
  88865. * This should not be used directly aside of the few static configurations
  88866. */
  88867. export class RenderingManager {
  88868. /**
  88869. * The max id used for rendering groups (not included)
  88870. */
  88871. static MAX_RENDERINGGROUPS: number;
  88872. /**
  88873. * The min id used for rendering groups (included)
  88874. */
  88875. static MIN_RENDERINGGROUPS: number;
  88876. /**
  88877. * Used to globally prevent autoclearing scenes.
  88878. */
  88879. static AUTOCLEAR: boolean;
  88880. /**
  88881. * @hidden
  88882. */
  88883. _useSceneAutoClearSetup: boolean;
  88884. private _scene;
  88885. private _renderingGroups;
  88886. private _depthStencilBufferAlreadyCleaned;
  88887. private _autoClearDepthStencil;
  88888. private _customOpaqueSortCompareFn;
  88889. private _customAlphaTestSortCompareFn;
  88890. private _customTransparentSortCompareFn;
  88891. private _renderingGroupInfo;
  88892. /**
  88893. * Instantiates a new rendering group for a particular scene
  88894. * @param scene Defines the scene the groups belongs to
  88895. */
  88896. constructor(scene: Scene);
  88897. private _clearDepthStencilBuffer;
  88898. /**
  88899. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88900. * @hidden
  88901. */
  88902. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88903. /**
  88904. * Resets the different information of the group to prepare a new frame
  88905. * @hidden
  88906. */
  88907. reset(): void;
  88908. /**
  88909. * Dispose and release the group and its associated resources.
  88910. * @hidden
  88911. */
  88912. dispose(): void;
  88913. /**
  88914. * Clear the info related to rendering groups preventing retention points during dispose.
  88915. */
  88916. freeRenderingGroups(): void;
  88917. private _prepareRenderingGroup;
  88918. /**
  88919. * Add a sprite manager to the rendering manager in order to render it this frame.
  88920. * @param spriteManager Define the sprite manager to render
  88921. */
  88922. dispatchSprites(spriteManager: ISpriteManager): void;
  88923. /**
  88924. * Add a particle system to the rendering manager in order to render it this frame.
  88925. * @param particleSystem Define the particle system to render
  88926. */
  88927. dispatchParticles(particleSystem: IParticleSystem): void;
  88928. /**
  88929. * Add a submesh to the manager in order to render it this frame
  88930. * @param subMesh The submesh to dispatch
  88931. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88932. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88933. */
  88934. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88935. /**
  88936. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88937. * This allowed control for front to back rendering or reversly depending of the special needs.
  88938. *
  88939. * @param renderingGroupId The rendering group id corresponding to its index
  88940. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88941. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88942. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88943. */
  88944. 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;
  88945. /**
  88946. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88947. *
  88948. * @param renderingGroupId The rendering group id corresponding to its index
  88949. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88950. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88951. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88952. */
  88953. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88954. /**
  88955. * Gets the current auto clear configuration for one rendering group of the rendering
  88956. * manager.
  88957. * @param index the rendering group index to get the information for
  88958. * @returns The auto clear setup for the requested rendering group
  88959. */
  88960. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88961. }
  88962. }
  88963. declare module BABYLON {
  88964. /**
  88965. * This Helps creating a texture that will be created from a camera in your scene.
  88966. * It is basically a dynamic texture that could be used to create special effects for instance.
  88967. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88968. */
  88969. export class RenderTargetTexture extends Texture {
  88970. isCube: boolean;
  88971. /**
  88972. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88973. */
  88974. static readonly REFRESHRATE_RENDER_ONCE: number;
  88975. /**
  88976. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88977. */
  88978. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88979. /**
  88980. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88981. * the central point of your effect and can save a lot of performances.
  88982. */
  88983. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88984. /**
  88985. * Use this predicate to dynamically define the list of mesh you want to render.
  88986. * If set, the renderList property will be overwritten.
  88987. */
  88988. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88989. private _renderList;
  88990. /**
  88991. * Use this list to define the list of mesh you want to render.
  88992. */
  88993. renderList: Nullable<Array<AbstractMesh>>;
  88994. private _hookArray;
  88995. /**
  88996. * Define if particles should be rendered in your texture.
  88997. */
  88998. renderParticles: boolean;
  88999. /**
  89000. * Define if sprites should be rendered in your texture.
  89001. */
  89002. renderSprites: boolean;
  89003. /**
  89004. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89005. */
  89006. coordinatesMode: number;
  89007. /**
  89008. * Define the camera used to render the texture.
  89009. */
  89010. activeCamera: Nullable<Camera>;
  89011. /**
  89012. * Override the render function of the texture with your own one.
  89013. */
  89014. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89015. /**
  89016. * Define if camera post processes should be use while rendering the texture.
  89017. */
  89018. useCameraPostProcesses: boolean;
  89019. /**
  89020. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89021. */
  89022. ignoreCameraViewport: boolean;
  89023. private _postProcessManager;
  89024. private _postProcesses;
  89025. private _resizeObserver;
  89026. /**
  89027. * An event triggered when the texture is unbind.
  89028. */
  89029. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89030. /**
  89031. * An event triggered when the texture is unbind.
  89032. */
  89033. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89034. private _onAfterUnbindObserver;
  89035. /**
  89036. * Set a after unbind callback in the texture.
  89037. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89038. */
  89039. onAfterUnbind: () => void;
  89040. /**
  89041. * An event triggered before rendering the texture
  89042. */
  89043. onBeforeRenderObservable: Observable<number>;
  89044. private _onBeforeRenderObserver;
  89045. /**
  89046. * Set a before render callback in the texture.
  89047. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89048. */
  89049. onBeforeRender: (faceIndex: number) => void;
  89050. /**
  89051. * An event triggered after rendering the texture
  89052. */
  89053. onAfterRenderObservable: Observable<number>;
  89054. private _onAfterRenderObserver;
  89055. /**
  89056. * Set a after render callback in the texture.
  89057. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89058. */
  89059. onAfterRender: (faceIndex: number) => void;
  89060. /**
  89061. * An event triggered after the texture clear
  89062. */
  89063. onClearObservable: Observable<Engine>;
  89064. private _onClearObserver;
  89065. /**
  89066. * Set a clear callback in the texture.
  89067. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89068. */
  89069. onClear: (Engine: Engine) => void;
  89070. /**
  89071. * An event triggered when the texture is resized.
  89072. */
  89073. onResizeObservable: Observable<RenderTargetTexture>;
  89074. /**
  89075. * Define the clear color of the Render Target if it should be different from the scene.
  89076. */
  89077. clearColor: Color4;
  89078. protected _size: number | {
  89079. width: number;
  89080. height: number;
  89081. };
  89082. protected _initialSizeParameter: number | {
  89083. width: number;
  89084. height: number;
  89085. } | {
  89086. ratio: number;
  89087. };
  89088. protected _sizeRatio: Nullable<number>;
  89089. /** @hidden */
  89090. _generateMipMaps: boolean;
  89091. protected _renderingManager: RenderingManager;
  89092. /** @hidden */
  89093. _waitingRenderList: string[];
  89094. protected _doNotChangeAspectRatio: boolean;
  89095. protected _currentRefreshId: number;
  89096. protected _refreshRate: number;
  89097. protected _textureMatrix: Matrix;
  89098. protected _samples: number;
  89099. protected _renderTargetOptions: RenderTargetCreationOptions;
  89100. /**
  89101. * Gets render target creation options that were used.
  89102. */
  89103. readonly renderTargetOptions: RenderTargetCreationOptions;
  89104. protected _engine: Engine;
  89105. protected _onRatioRescale(): void;
  89106. /**
  89107. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89108. * It must define where the camera used to render the texture is set
  89109. */
  89110. boundingBoxPosition: Vector3;
  89111. private _boundingBoxSize;
  89112. /**
  89113. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89114. * When defined, the cubemap will switch to local mode
  89115. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89116. * @example https://www.babylonjs-playground.com/#RNASML
  89117. */
  89118. boundingBoxSize: Vector3;
  89119. /**
  89120. * In case the RTT has been created with a depth texture, get the associated
  89121. * depth texture.
  89122. * Otherwise, return null.
  89123. */
  89124. depthStencilTexture: Nullable<InternalTexture>;
  89125. /**
  89126. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89127. * or used a shadow, depth texture...
  89128. * @param name The friendly name of the texture
  89129. * @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)
  89130. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89131. * @param generateMipMaps True if mip maps need to be generated after render.
  89132. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89133. * @param type The type of the buffer in the RTT (int, half float, float...)
  89134. * @param isCube True if a cube texture needs to be created
  89135. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89136. * @param generateDepthBuffer True to generate a depth buffer
  89137. * @param generateStencilBuffer True to generate a stencil buffer
  89138. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89139. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89140. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89141. */
  89142. constructor(name: string, size: number | {
  89143. width: number;
  89144. height: number;
  89145. } | {
  89146. ratio: number;
  89147. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89148. /**
  89149. * Creates a depth stencil texture.
  89150. * This is only available in WebGL 2 or with the depth texture extension available.
  89151. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89152. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89153. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89154. */
  89155. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89156. private _processSizeParameter;
  89157. /**
  89158. * Define the number of samples to use in case of MSAA.
  89159. * It defaults to one meaning no MSAA has been enabled.
  89160. */
  89161. samples: number;
  89162. /**
  89163. * Resets the refresh counter of the texture and start bak from scratch.
  89164. * Could be useful to regenerate the texture if it is setup to render only once.
  89165. */
  89166. resetRefreshCounter(): void;
  89167. /**
  89168. * Define the refresh rate of the texture or the rendering frequency.
  89169. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89170. */
  89171. refreshRate: number;
  89172. /**
  89173. * Adds a post process to the render target rendering passes.
  89174. * @param postProcess define the post process to add
  89175. */
  89176. addPostProcess(postProcess: PostProcess): void;
  89177. /**
  89178. * Clear all the post processes attached to the render target
  89179. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89180. */
  89181. clearPostProcesses(dispose?: boolean): void;
  89182. /**
  89183. * Remove one of the post process from the list of attached post processes to the texture
  89184. * @param postProcess define the post process to remove from the list
  89185. */
  89186. removePostProcess(postProcess: PostProcess): void;
  89187. /** @hidden */
  89188. _shouldRender(): boolean;
  89189. /**
  89190. * Gets the actual render size of the texture.
  89191. * @returns the width of the render size
  89192. */
  89193. getRenderSize(): number;
  89194. /**
  89195. * Gets the actual render width of the texture.
  89196. * @returns the width of the render size
  89197. */
  89198. getRenderWidth(): number;
  89199. /**
  89200. * Gets the actual render height of the texture.
  89201. * @returns the height of the render size
  89202. */
  89203. getRenderHeight(): number;
  89204. /**
  89205. * Get if the texture can be rescaled or not.
  89206. */
  89207. readonly canRescale: boolean;
  89208. /**
  89209. * Resize the texture using a ratio.
  89210. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89211. */
  89212. scale(ratio: number): void;
  89213. /**
  89214. * Get the texture reflection matrix used to rotate/transform the reflection.
  89215. * @returns the reflection matrix
  89216. */
  89217. getReflectionTextureMatrix(): Matrix;
  89218. /**
  89219. * Resize the texture to a new desired size.
  89220. * Be carrefull as it will recreate all the data in the new texture.
  89221. * @param size Define the new size. It can be:
  89222. * - a number for squared texture,
  89223. * - an object containing { width: number, height: number }
  89224. * - or an object containing a ratio { ratio: number }
  89225. */
  89226. resize(size: number | {
  89227. width: number;
  89228. height: number;
  89229. } | {
  89230. ratio: number;
  89231. }): void;
  89232. /**
  89233. * Renders all the objects from the render list into the texture.
  89234. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89235. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89236. */
  89237. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89238. private _bestReflectionRenderTargetDimension;
  89239. /**
  89240. * @hidden
  89241. * @param faceIndex face index to bind to if this is a cubetexture
  89242. */
  89243. _bindFrameBuffer(faceIndex?: number): void;
  89244. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89245. private renderToTarget;
  89246. /**
  89247. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89248. * This allowed control for front to back rendering or reversly depending of the special needs.
  89249. *
  89250. * @param renderingGroupId The rendering group id corresponding to its index
  89251. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89252. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89253. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89254. */
  89255. 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;
  89256. /**
  89257. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89258. *
  89259. * @param renderingGroupId The rendering group id corresponding to its index
  89260. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89261. */
  89262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89263. /**
  89264. * Clones the texture.
  89265. * @returns the cloned texture
  89266. */
  89267. clone(): RenderTargetTexture;
  89268. /**
  89269. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89270. * @returns The JSON representation of the texture
  89271. */
  89272. serialize(): any;
  89273. /**
  89274. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89275. */
  89276. disposeFramebufferObjects(): void;
  89277. /**
  89278. * Dispose the texture and release its associated resources.
  89279. */
  89280. dispose(): void;
  89281. /** @hidden */
  89282. _rebuild(): void;
  89283. /**
  89284. * Clear the info related to rendering groups preventing retention point in material dispose.
  89285. */
  89286. freeRenderingGroups(): void;
  89287. /**
  89288. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89289. * @returns the view count
  89290. */
  89291. getViewCount(): number;
  89292. }
  89293. }
  89294. declare module BABYLON {
  89295. /**
  89296. * Options for compiling materials.
  89297. */
  89298. export interface IMaterialCompilationOptions {
  89299. /**
  89300. * Defines whether clip planes are enabled.
  89301. */
  89302. clipPlane: boolean;
  89303. /**
  89304. * Defines whether instances are enabled.
  89305. */
  89306. useInstances: boolean;
  89307. }
  89308. /**
  89309. * Base class for the main features of a material in Babylon.js
  89310. */
  89311. export class Material implements IAnimatable {
  89312. /**
  89313. * Returns the triangle fill mode
  89314. */
  89315. static readonly TriangleFillMode: number;
  89316. /**
  89317. * Returns the wireframe mode
  89318. */
  89319. static readonly WireFrameFillMode: number;
  89320. /**
  89321. * Returns the point fill mode
  89322. */
  89323. static readonly PointFillMode: number;
  89324. /**
  89325. * Returns the point list draw mode
  89326. */
  89327. static readonly PointListDrawMode: number;
  89328. /**
  89329. * Returns the line list draw mode
  89330. */
  89331. static readonly LineListDrawMode: number;
  89332. /**
  89333. * Returns the line loop draw mode
  89334. */
  89335. static readonly LineLoopDrawMode: number;
  89336. /**
  89337. * Returns the line strip draw mode
  89338. */
  89339. static readonly LineStripDrawMode: number;
  89340. /**
  89341. * Returns the triangle strip draw mode
  89342. */
  89343. static readonly TriangleStripDrawMode: number;
  89344. /**
  89345. * Returns the triangle fan draw mode
  89346. */
  89347. static readonly TriangleFanDrawMode: number;
  89348. /**
  89349. * Stores the clock-wise side orientation
  89350. */
  89351. static readonly ClockWiseSideOrientation: number;
  89352. /**
  89353. * Stores the counter clock-wise side orientation
  89354. */
  89355. static readonly CounterClockWiseSideOrientation: number;
  89356. /**
  89357. * The dirty texture flag value
  89358. */
  89359. static readonly TextureDirtyFlag: number;
  89360. /**
  89361. * The dirty light flag value
  89362. */
  89363. static readonly LightDirtyFlag: number;
  89364. /**
  89365. * The dirty fresnel flag value
  89366. */
  89367. static readonly FresnelDirtyFlag: number;
  89368. /**
  89369. * The dirty attribute flag value
  89370. */
  89371. static readonly AttributesDirtyFlag: number;
  89372. /**
  89373. * The dirty misc flag value
  89374. */
  89375. static readonly MiscDirtyFlag: number;
  89376. /**
  89377. * The all dirty flag value
  89378. */
  89379. static readonly AllDirtyFlag: number;
  89380. /**
  89381. * The ID of the material
  89382. */
  89383. id: string;
  89384. /**
  89385. * Gets or sets the unique id of the material
  89386. */
  89387. uniqueId: number;
  89388. /**
  89389. * The name of the material
  89390. */
  89391. name: string;
  89392. /**
  89393. * Gets or sets user defined metadata
  89394. */
  89395. metadata: any;
  89396. /**
  89397. * For internal use only. Please do not use.
  89398. */
  89399. reservedDataStore: any;
  89400. /**
  89401. * Specifies if the ready state should be checked on each call
  89402. */
  89403. checkReadyOnEveryCall: boolean;
  89404. /**
  89405. * Specifies if the ready state should be checked once
  89406. */
  89407. checkReadyOnlyOnce: boolean;
  89408. /**
  89409. * The state of the material
  89410. */
  89411. state: string;
  89412. /**
  89413. * The alpha value of the material
  89414. */
  89415. protected _alpha: number;
  89416. /**
  89417. * List of inspectable custom properties (used by the Inspector)
  89418. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89419. */
  89420. inspectableCustomProperties: IInspectable[];
  89421. /**
  89422. * Sets the alpha value of the material
  89423. */
  89424. /**
  89425. * Gets the alpha value of the material
  89426. */
  89427. alpha: number;
  89428. /**
  89429. * Specifies if back face culling is enabled
  89430. */
  89431. protected _backFaceCulling: boolean;
  89432. /**
  89433. * Sets the back-face culling state
  89434. */
  89435. /**
  89436. * Gets the back-face culling state
  89437. */
  89438. backFaceCulling: boolean;
  89439. /**
  89440. * Stores the value for side orientation
  89441. */
  89442. sideOrientation: number;
  89443. /**
  89444. * Callback triggered when the material is compiled
  89445. */
  89446. onCompiled: Nullable<(effect: Effect) => void>;
  89447. /**
  89448. * Callback triggered when an error occurs
  89449. */
  89450. onError: Nullable<(effect: Effect, errors: string) => void>;
  89451. /**
  89452. * Callback triggered to get the render target textures
  89453. */
  89454. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89455. /**
  89456. * Gets a boolean indicating that current material needs to register RTT
  89457. */
  89458. readonly hasRenderTargetTextures: boolean;
  89459. /**
  89460. * Specifies if the material should be serialized
  89461. */
  89462. doNotSerialize: boolean;
  89463. /**
  89464. * @hidden
  89465. */
  89466. _storeEffectOnSubMeshes: boolean;
  89467. /**
  89468. * Stores the animations for the material
  89469. */
  89470. animations: Nullable<Array<Animation>>;
  89471. /**
  89472. * An event triggered when the material is disposed
  89473. */
  89474. onDisposeObservable: Observable<Material>;
  89475. /**
  89476. * An observer which watches for dispose events
  89477. */
  89478. private _onDisposeObserver;
  89479. private _onUnBindObservable;
  89480. /**
  89481. * Called during a dispose event
  89482. */
  89483. onDispose: () => void;
  89484. private _onBindObservable;
  89485. /**
  89486. * An event triggered when the material is bound
  89487. */
  89488. readonly onBindObservable: Observable<AbstractMesh>;
  89489. /**
  89490. * An observer which watches for bind events
  89491. */
  89492. private _onBindObserver;
  89493. /**
  89494. * Called during a bind event
  89495. */
  89496. onBind: (Mesh: AbstractMesh) => void;
  89497. /**
  89498. * An event triggered when the material is unbound
  89499. */
  89500. readonly onUnBindObservable: Observable<Material>;
  89501. /**
  89502. * Stores the value of the alpha mode
  89503. */
  89504. private _alphaMode;
  89505. /**
  89506. * Sets the value of the alpha mode.
  89507. *
  89508. * | Value | Type | Description |
  89509. * | --- | --- | --- |
  89510. * | 0 | ALPHA_DISABLE | |
  89511. * | 1 | ALPHA_ADD | |
  89512. * | 2 | ALPHA_COMBINE | |
  89513. * | 3 | ALPHA_SUBTRACT | |
  89514. * | 4 | ALPHA_MULTIPLY | |
  89515. * | 5 | ALPHA_MAXIMIZED | |
  89516. * | 6 | ALPHA_ONEONE | |
  89517. * | 7 | ALPHA_PREMULTIPLIED | |
  89518. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89519. * | 9 | ALPHA_INTERPOLATE | |
  89520. * | 10 | ALPHA_SCREENMODE | |
  89521. *
  89522. */
  89523. /**
  89524. * Gets the value of the alpha mode
  89525. */
  89526. alphaMode: number;
  89527. /**
  89528. * Stores the state of the need depth pre-pass value
  89529. */
  89530. private _needDepthPrePass;
  89531. /**
  89532. * Sets the need depth pre-pass value
  89533. */
  89534. /**
  89535. * Gets the depth pre-pass value
  89536. */
  89537. needDepthPrePass: boolean;
  89538. /**
  89539. * Specifies if depth writing should be disabled
  89540. */
  89541. disableDepthWrite: boolean;
  89542. /**
  89543. * Specifies if depth writing should be forced
  89544. */
  89545. forceDepthWrite: boolean;
  89546. /**
  89547. * Specifies the depth function that should be used. 0 means the default engine function
  89548. */
  89549. depthFunction: number;
  89550. /**
  89551. * Specifies if there should be a separate pass for culling
  89552. */
  89553. separateCullingPass: boolean;
  89554. /**
  89555. * Stores the state specifing if fog should be enabled
  89556. */
  89557. private _fogEnabled;
  89558. /**
  89559. * Sets the state for enabling fog
  89560. */
  89561. /**
  89562. * Gets the value of the fog enabled state
  89563. */
  89564. fogEnabled: boolean;
  89565. /**
  89566. * Stores the size of points
  89567. */
  89568. pointSize: number;
  89569. /**
  89570. * Stores the z offset value
  89571. */
  89572. zOffset: number;
  89573. /**
  89574. * Gets a value specifying if wireframe mode is enabled
  89575. */
  89576. /**
  89577. * Sets the state of wireframe mode
  89578. */
  89579. wireframe: boolean;
  89580. /**
  89581. * Gets the value specifying if point clouds are enabled
  89582. */
  89583. /**
  89584. * Sets the state of point cloud mode
  89585. */
  89586. pointsCloud: boolean;
  89587. /**
  89588. * Gets the material fill mode
  89589. */
  89590. /**
  89591. * Sets the material fill mode
  89592. */
  89593. fillMode: number;
  89594. /**
  89595. * @hidden
  89596. * Stores the effects for the material
  89597. */
  89598. _effect: Nullable<Effect>;
  89599. /**
  89600. * @hidden
  89601. * Specifies if the material was previously ready
  89602. */
  89603. _wasPreviouslyReady: boolean;
  89604. /**
  89605. * Specifies if uniform buffers should be used
  89606. */
  89607. private _useUBO;
  89608. /**
  89609. * Stores a reference to the scene
  89610. */
  89611. private _scene;
  89612. /**
  89613. * Stores the fill mode state
  89614. */
  89615. private _fillMode;
  89616. /**
  89617. * Specifies if the depth write state should be cached
  89618. */
  89619. private _cachedDepthWriteState;
  89620. /**
  89621. * Specifies if the depth function state should be cached
  89622. */
  89623. private _cachedDepthFunctionState;
  89624. /**
  89625. * Stores the uniform buffer
  89626. */
  89627. protected _uniformBuffer: UniformBuffer;
  89628. /** @hidden */
  89629. _indexInSceneMaterialArray: number;
  89630. /** @hidden */
  89631. meshMap: Nullable<{
  89632. [id: string]: AbstractMesh | undefined;
  89633. }>;
  89634. /**
  89635. * Creates a material instance
  89636. * @param name defines the name of the material
  89637. * @param scene defines the scene to reference
  89638. * @param doNotAdd specifies if the material should be added to the scene
  89639. */
  89640. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89641. /**
  89642. * Returns a string representation of the current material
  89643. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89644. * @returns a string with material information
  89645. */
  89646. toString(fullDetails?: boolean): string;
  89647. /**
  89648. * Gets the class name of the material
  89649. * @returns a string with the class name of the material
  89650. */
  89651. getClassName(): string;
  89652. /**
  89653. * Specifies if updates for the material been locked
  89654. */
  89655. readonly isFrozen: boolean;
  89656. /**
  89657. * Locks updates for the material
  89658. */
  89659. freeze(): void;
  89660. /**
  89661. * Unlocks updates for the material
  89662. */
  89663. unfreeze(): void;
  89664. /**
  89665. * Specifies if the material is ready to be used
  89666. * @param mesh defines the mesh to check
  89667. * @param useInstances specifies if instances should be used
  89668. * @returns a boolean indicating if the material is ready to be used
  89669. */
  89670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89671. /**
  89672. * Specifies that the submesh is ready to be used
  89673. * @param mesh defines the mesh to check
  89674. * @param subMesh defines which submesh to check
  89675. * @param useInstances specifies that instances should be used
  89676. * @returns a boolean indicating that the submesh is ready or not
  89677. */
  89678. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89679. /**
  89680. * Returns the material effect
  89681. * @returns the effect associated with the material
  89682. */
  89683. getEffect(): Nullable<Effect>;
  89684. /**
  89685. * Returns the current scene
  89686. * @returns a Scene
  89687. */
  89688. getScene(): Scene;
  89689. /**
  89690. * Specifies if the material will require alpha blending
  89691. * @returns a boolean specifying if alpha blending is needed
  89692. */
  89693. needAlphaBlending(): boolean;
  89694. /**
  89695. * Specifies if the mesh will require alpha blending
  89696. * @param mesh defines the mesh to check
  89697. * @returns a boolean specifying if alpha blending is needed for the mesh
  89698. */
  89699. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89700. /**
  89701. * Specifies if this material should be rendered in alpha test mode
  89702. * @returns a boolean specifying if an alpha test is needed.
  89703. */
  89704. needAlphaTesting(): boolean;
  89705. /**
  89706. * Gets the texture used for the alpha test
  89707. * @returns the texture to use for alpha testing
  89708. */
  89709. getAlphaTestTexture(): Nullable<BaseTexture>;
  89710. /**
  89711. * Marks the material to indicate that it needs to be re-calculated
  89712. */
  89713. markDirty(): void;
  89714. /** @hidden */
  89715. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89716. /**
  89717. * Binds the material to the mesh
  89718. * @param world defines the world transformation matrix
  89719. * @param mesh defines the mesh to bind the material to
  89720. */
  89721. bind(world: Matrix, mesh?: Mesh): void;
  89722. /**
  89723. * Binds the submesh to the material
  89724. * @param world defines the world transformation matrix
  89725. * @param mesh defines the mesh containing the submesh
  89726. * @param subMesh defines the submesh to bind the material to
  89727. */
  89728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89729. /**
  89730. * Binds the world matrix to the material
  89731. * @param world defines the world transformation matrix
  89732. */
  89733. bindOnlyWorldMatrix(world: Matrix): void;
  89734. /**
  89735. * Binds the scene's uniform buffer to the effect.
  89736. * @param effect defines the effect to bind to the scene uniform buffer
  89737. * @param sceneUbo defines the uniform buffer storing scene data
  89738. */
  89739. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89740. /**
  89741. * Binds the view matrix to the effect
  89742. * @param effect defines the effect to bind the view matrix to
  89743. */
  89744. bindView(effect: Effect): void;
  89745. /**
  89746. * Binds the view projection matrix to the effect
  89747. * @param effect defines the effect to bind the view projection matrix to
  89748. */
  89749. bindViewProjection(effect: Effect): void;
  89750. /**
  89751. * Specifies if material alpha testing should be turned on for the mesh
  89752. * @param mesh defines the mesh to check
  89753. */
  89754. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89755. /**
  89756. * Processes to execute after binding the material to a mesh
  89757. * @param mesh defines the rendered mesh
  89758. */
  89759. protected _afterBind(mesh?: Mesh): void;
  89760. /**
  89761. * Unbinds the material from the mesh
  89762. */
  89763. unbind(): void;
  89764. /**
  89765. * Gets the active textures from the material
  89766. * @returns an array of textures
  89767. */
  89768. getActiveTextures(): BaseTexture[];
  89769. /**
  89770. * Specifies if the material uses a texture
  89771. * @param texture defines the texture to check against the material
  89772. * @returns a boolean specifying if the material uses the texture
  89773. */
  89774. hasTexture(texture: BaseTexture): boolean;
  89775. /**
  89776. * Makes a duplicate of the material, and gives it a new name
  89777. * @param name defines the new name for the duplicated material
  89778. * @returns the cloned material
  89779. */
  89780. clone(name: string): Nullable<Material>;
  89781. /**
  89782. * Gets the meshes bound to the material
  89783. * @returns an array of meshes bound to the material
  89784. */
  89785. getBindedMeshes(): AbstractMesh[];
  89786. /**
  89787. * Force shader compilation
  89788. * @param mesh defines the mesh associated with this material
  89789. * @param onCompiled defines a function to execute once the material is compiled
  89790. * @param options defines the options to configure the compilation
  89791. * @param onError defines a function to execute if the material fails compiling
  89792. */
  89793. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89794. /**
  89795. * Force shader compilation
  89796. * @param mesh defines the mesh that will use this material
  89797. * @param options defines additional options for compiling the shaders
  89798. * @returns a promise that resolves when the compilation completes
  89799. */
  89800. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89801. private static readonly _AllDirtyCallBack;
  89802. private static readonly _ImageProcessingDirtyCallBack;
  89803. private static readonly _TextureDirtyCallBack;
  89804. private static readonly _FresnelDirtyCallBack;
  89805. private static readonly _MiscDirtyCallBack;
  89806. private static readonly _LightsDirtyCallBack;
  89807. private static readonly _AttributeDirtyCallBack;
  89808. private static _FresnelAndMiscDirtyCallBack;
  89809. private static _TextureAndMiscDirtyCallBack;
  89810. private static readonly _DirtyCallbackArray;
  89811. private static readonly _RunDirtyCallBacks;
  89812. /**
  89813. * Marks a define in the material to indicate that it needs to be re-computed
  89814. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89815. */
  89816. markAsDirty(flag: number): void;
  89817. /**
  89818. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89819. * @param func defines a function which checks material defines against the submeshes
  89820. */
  89821. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89822. /**
  89823. * Indicates that we need to re-calculated for all submeshes
  89824. */
  89825. protected _markAllSubMeshesAsAllDirty(): void;
  89826. /**
  89827. * Indicates that image processing needs to be re-calculated for all submeshes
  89828. */
  89829. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89830. /**
  89831. * Indicates that textures need to be re-calculated for all submeshes
  89832. */
  89833. protected _markAllSubMeshesAsTexturesDirty(): void;
  89834. /**
  89835. * Indicates that fresnel needs to be re-calculated for all submeshes
  89836. */
  89837. protected _markAllSubMeshesAsFresnelDirty(): void;
  89838. /**
  89839. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89840. */
  89841. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89842. /**
  89843. * Indicates that lights need to be re-calculated for all submeshes
  89844. */
  89845. protected _markAllSubMeshesAsLightsDirty(): void;
  89846. /**
  89847. * Indicates that attributes need to be re-calculated for all submeshes
  89848. */
  89849. protected _markAllSubMeshesAsAttributesDirty(): void;
  89850. /**
  89851. * Indicates that misc needs to be re-calculated for all submeshes
  89852. */
  89853. protected _markAllSubMeshesAsMiscDirty(): void;
  89854. /**
  89855. * Indicates that textures and misc need to be re-calculated for all submeshes
  89856. */
  89857. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89858. /**
  89859. * Disposes the material
  89860. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89861. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89862. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89863. */
  89864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89865. /** @hidden */
  89866. private releaseVertexArrayObject;
  89867. /**
  89868. * Serializes this material
  89869. * @returns the serialized material object
  89870. */
  89871. serialize(): any;
  89872. /**
  89873. * Creates a material from parsed material data
  89874. * @param parsedMaterial defines parsed material data
  89875. * @param scene defines the hosting scene
  89876. * @param rootUrl defines the root URL to use to load textures
  89877. * @returns a new material
  89878. */
  89879. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89880. }
  89881. }
  89882. declare module BABYLON {
  89883. /**
  89884. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89885. * separate meshes. This can be use to improve performances.
  89886. * @see http://doc.babylonjs.com/how_to/multi_materials
  89887. */
  89888. export class MultiMaterial extends Material {
  89889. private _subMaterials;
  89890. /**
  89891. * Gets or Sets the list of Materials used within the multi material.
  89892. * They need to be ordered according to the submeshes order in the associated mesh
  89893. */
  89894. subMaterials: Nullable<Material>[];
  89895. /**
  89896. * Function used to align with Node.getChildren()
  89897. * @returns the list of Materials used within the multi material
  89898. */
  89899. getChildren(): Nullable<Material>[];
  89900. /**
  89901. * Instantiates a new Multi Material
  89902. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89903. * separate meshes. This can be use to improve performances.
  89904. * @see http://doc.babylonjs.com/how_to/multi_materials
  89905. * @param name Define the name in the scene
  89906. * @param scene Define the scene the material belongs to
  89907. */
  89908. constructor(name: string, scene: Scene);
  89909. private _hookArray;
  89910. /**
  89911. * Get one of the submaterial by its index in the submaterials array
  89912. * @param index The index to look the sub material at
  89913. * @returns The Material if the index has been defined
  89914. */
  89915. getSubMaterial(index: number): Nullable<Material>;
  89916. /**
  89917. * Get the list of active textures for the whole sub materials list.
  89918. * @returns All the textures that will be used during the rendering
  89919. */
  89920. getActiveTextures(): BaseTexture[];
  89921. /**
  89922. * Gets the current class name of the material e.g. "MultiMaterial"
  89923. * Mainly use in serialization.
  89924. * @returns the class name
  89925. */
  89926. getClassName(): string;
  89927. /**
  89928. * Checks if the material is ready to render the requested sub mesh
  89929. * @param mesh Define the mesh the submesh belongs to
  89930. * @param subMesh Define the sub mesh to look readyness for
  89931. * @param useInstances Define whether or not the material is used with instances
  89932. * @returns true if ready, otherwise false
  89933. */
  89934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89935. /**
  89936. * Clones the current material and its related sub materials
  89937. * @param name Define the name of the newly cloned material
  89938. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89939. * @returns the cloned material
  89940. */
  89941. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89942. /**
  89943. * Serializes the materials into a JSON representation.
  89944. * @returns the JSON representation
  89945. */
  89946. serialize(): any;
  89947. /**
  89948. * Dispose the material and release its associated resources
  89949. * @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)
  89950. * @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)
  89951. * @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)
  89952. */
  89953. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89954. /**
  89955. * Creates a MultiMaterial from parsed MultiMaterial data.
  89956. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89957. * @param scene defines the hosting scene
  89958. * @returns a new MultiMaterial
  89959. */
  89960. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89961. }
  89962. }
  89963. declare module BABYLON {
  89964. /**
  89965. * Base class for submeshes
  89966. */
  89967. export class BaseSubMesh {
  89968. /** @hidden */
  89969. _materialDefines: Nullable<MaterialDefines>;
  89970. /** @hidden */
  89971. _materialEffect: Nullable<Effect>;
  89972. /**
  89973. * Gets material defines used by the effect associated to the sub mesh
  89974. */
  89975. /**
  89976. * Sets material defines used by the effect associated to the sub mesh
  89977. */
  89978. materialDefines: Nullable<MaterialDefines>;
  89979. /**
  89980. * Gets associated effect
  89981. */
  89982. readonly effect: Nullable<Effect>;
  89983. /**
  89984. * Sets associated effect (effect used to render this submesh)
  89985. * @param effect defines the effect to associate with
  89986. * @param defines defines the set of defines used to compile this effect
  89987. */
  89988. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89989. }
  89990. /**
  89991. * Defines a subdivision inside a mesh
  89992. */
  89993. export class SubMesh extends BaseSubMesh implements ICullable {
  89994. /** the material index to use */
  89995. materialIndex: number;
  89996. /** vertex index start */
  89997. verticesStart: number;
  89998. /** vertices count */
  89999. verticesCount: number;
  90000. /** index start */
  90001. indexStart: number;
  90002. /** indices count */
  90003. indexCount: number;
  90004. /** @hidden */
  90005. _linesIndexCount: number;
  90006. private _mesh;
  90007. private _renderingMesh;
  90008. private _boundingInfo;
  90009. private _linesIndexBuffer;
  90010. /** @hidden */
  90011. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90012. /** @hidden */
  90013. _trianglePlanes: Plane[];
  90014. /** @hidden */
  90015. _lastColliderTransformMatrix: Nullable<Matrix>;
  90016. /** @hidden */
  90017. _renderId: number;
  90018. /** @hidden */
  90019. _alphaIndex: number;
  90020. /** @hidden */
  90021. _distanceToCamera: number;
  90022. /** @hidden */
  90023. _id: number;
  90024. private _currentMaterial;
  90025. /**
  90026. * Add a new submesh to a mesh
  90027. * @param materialIndex defines the material index to use
  90028. * @param verticesStart defines vertex index start
  90029. * @param verticesCount defines vertices count
  90030. * @param indexStart defines index start
  90031. * @param indexCount defines indices count
  90032. * @param mesh defines the parent mesh
  90033. * @param renderingMesh defines an optional rendering mesh
  90034. * @param createBoundingBox defines if bounding box should be created for this submesh
  90035. * @returns the new submesh
  90036. */
  90037. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90038. /**
  90039. * Creates a new submesh
  90040. * @param materialIndex defines the material index to use
  90041. * @param verticesStart defines vertex index start
  90042. * @param verticesCount defines vertices count
  90043. * @param indexStart defines index start
  90044. * @param indexCount defines indices count
  90045. * @param mesh defines the parent mesh
  90046. * @param renderingMesh defines an optional rendering mesh
  90047. * @param createBoundingBox defines if bounding box should be created for this submesh
  90048. */
  90049. constructor(
  90050. /** the material index to use */
  90051. materialIndex: number,
  90052. /** vertex index start */
  90053. verticesStart: number,
  90054. /** vertices count */
  90055. verticesCount: number,
  90056. /** index start */
  90057. indexStart: number,
  90058. /** indices count */
  90059. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90060. /**
  90061. * Returns true if this submesh covers the entire parent mesh
  90062. * @ignorenaming
  90063. */
  90064. readonly IsGlobal: boolean;
  90065. /**
  90066. * Returns the submesh BoudingInfo object
  90067. * @returns current bounding info (or mesh's one if the submesh is global)
  90068. */
  90069. getBoundingInfo(): BoundingInfo;
  90070. /**
  90071. * Sets the submesh BoundingInfo
  90072. * @param boundingInfo defines the new bounding info to use
  90073. * @returns the SubMesh
  90074. */
  90075. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90076. /**
  90077. * Returns the mesh of the current submesh
  90078. * @return the parent mesh
  90079. */
  90080. getMesh(): AbstractMesh;
  90081. /**
  90082. * Returns the rendering mesh of the submesh
  90083. * @returns the rendering mesh (could be different from parent mesh)
  90084. */
  90085. getRenderingMesh(): Mesh;
  90086. /**
  90087. * Returns the submesh material
  90088. * @returns null or the current material
  90089. */
  90090. getMaterial(): Nullable<Material>;
  90091. /**
  90092. * Sets a new updated BoundingInfo object to the submesh
  90093. * @param data defines an optional position array to use to determine the bounding info
  90094. * @returns the SubMesh
  90095. */
  90096. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90097. /** @hidden */
  90098. _checkCollision(collider: Collider): boolean;
  90099. /**
  90100. * Updates the submesh BoundingInfo
  90101. * @param world defines the world matrix to use to update the bounding info
  90102. * @returns the submesh
  90103. */
  90104. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90105. /**
  90106. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90107. * @param frustumPlanes defines the frustum planes
  90108. * @returns true if the submesh is intersecting with the frustum
  90109. */
  90110. isInFrustum(frustumPlanes: Plane[]): boolean;
  90111. /**
  90112. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90113. * @param frustumPlanes defines the frustum planes
  90114. * @returns true if the submesh is inside the frustum
  90115. */
  90116. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90117. /**
  90118. * Renders the submesh
  90119. * @param enableAlphaMode defines if alpha needs to be used
  90120. * @returns the submesh
  90121. */
  90122. render(enableAlphaMode: boolean): SubMesh;
  90123. /**
  90124. * @hidden
  90125. */
  90126. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90127. /**
  90128. * Checks if the submesh intersects with a ray
  90129. * @param ray defines the ray to test
  90130. * @returns true is the passed ray intersects the submesh bounding box
  90131. */
  90132. canIntersects(ray: Ray): boolean;
  90133. /**
  90134. * Intersects current submesh with a ray
  90135. * @param ray defines the ray to test
  90136. * @param positions defines mesh's positions array
  90137. * @param indices defines mesh's indices array
  90138. * @param fastCheck defines if only bounding info should be used
  90139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90140. * @returns intersection info or null if no intersection
  90141. */
  90142. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90143. /** @hidden */
  90144. private _intersectLines;
  90145. /** @hidden */
  90146. private _intersectUnIndexedLines;
  90147. /** @hidden */
  90148. private _intersectTriangles;
  90149. /** @hidden */
  90150. private _intersectUnIndexedTriangles;
  90151. /** @hidden */
  90152. _rebuild(): void;
  90153. /**
  90154. * Creates a new submesh from the passed mesh
  90155. * @param newMesh defines the new hosting mesh
  90156. * @param newRenderingMesh defines an optional rendering mesh
  90157. * @returns the new submesh
  90158. */
  90159. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90160. /**
  90161. * Release associated resources
  90162. */
  90163. dispose(): void;
  90164. /**
  90165. * Gets the class name
  90166. * @returns the string "SubMesh".
  90167. */
  90168. getClassName(): string;
  90169. /**
  90170. * Creates a new submesh from indices data
  90171. * @param materialIndex the index of the main mesh material
  90172. * @param startIndex the index where to start the copy in the mesh indices array
  90173. * @param indexCount the number of indices to copy then from the startIndex
  90174. * @param mesh the main mesh to create the submesh from
  90175. * @param renderingMesh the optional rendering mesh
  90176. * @returns a new submesh
  90177. */
  90178. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90179. }
  90180. }
  90181. declare module BABYLON {
  90182. /**
  90183. * Class used to represent data loading progression
  90184. */
  90185. export class SceneLoaderFlags {
  90186. private static _ForceFullSceneLoadingForIncremental;
  90187. private static _ShowLoadingScreen;
  90188. private static _CleanBoneMatrixWeights;
  90189. private static _loggingLevel;
  90190. /**
  90191. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90192. */
  90193. static ForceFullSceneLoadingForIncremental: boolean;
  90194. /**
  90195. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90196. */
  90197. static ShowLoadingScreen: boolean;
  90198. /**
  90199. * Defines the current logging level (while loading the scene)
  90200. * @ignorenaming
  90201. */
  90202. static loggingLevel: number;
  90203. /**
  90204. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90205. */
  90206. static CleanBoneMatrixWeights: boolean;
  90207. }
  90208. }
  90209. declare module BABYLON {
  90210. /**
  90211. * Class used to store geometry data (vertex buffers + index buffer)
  90212. */
  90213. export class Geometry implements IGetSetVerticesData {
  90214. /**
  90215. * Gets or sets the ID of the geometry
  90216. */
  90217. id: string;
  90218. /**
  90219. * Gets or sets the unique ID of the geometry
  90220. */
  90221. uniqueId: number;
  90222. /**
  90223. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90224. */
  90225. delayLoadState: number;
  90226. /**
  90227. * Gets the file containing the data to load when running in delay load state
  90228. */
  90229. delayLoadingFile: Nullable<string>;
  90230. /**
  90231. * Callback called when the geometry is updated
  90232. */
  90233. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90234. private _scene;
  90235. private _engine;
  90236. private _meshes;
  90237. private _totalVertices;
  90238. /** @hidden */
  90239. _indices: IndicesArray;
  90240. /** @hidden */
  90241. _vertexBuffers: {
  90242. [key: string]: VertexBuffer;
  90243. };
  90244. private _isDisposed;
  90245. private _extend;
  90246. private _boundingBias;
  90247. /** @hidden */
  90248. _delayInfo: Array<string>;
  90249. private _indexBuffer;
  90250. private _indexBufferIsUpdatable;
  90251. /** @hidden */
  90252. _boundingInfo: Nullable<BoundingInfo>;
  90253. /** @hidden */
  90254. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90255. /** @hidden */
  90256. _softwareSkinningFrameId: number;
  90257. private _vertexArrayObjects;
  90258. private _updatable;
  90259. /** @hidden */
  90260. _positions: Nullable<Vector3[]>;
  90261. /**
  90262. * 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
  90263. */
  90264. /**
  90265. * 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
  90266. */
  90267. boundingBias: Vector2;
  90268. /**
  90269. * Static function used to attach a new empty geometry to a mesh
  90270. * @param mesh defines the mesh to attach the geometry to
  90271. * @returns the new Geometry
  90272. */
  90273. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90274. /**
  90275. * Creates a new geometry
  90276. * @param id defines the unique ID
  90277. * @param scene defines the hosting scene
  90278. * @param vertexData defines the VertexData used to get geometry data
  90279. * @param updatable defines if geometry must be updatable (false by default)
  90280. * @param mesh defines the mesh that will be associated with the geometry
  90281. */
  90282. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90283. /**
  90284. * Gets the current extend of the geometry
  90285. */
  90286. readonly extend: {
  90287. minimum: Vector3;
  90288. maximum: Vector3;
  90289. };
  90290. /**
  90291. * Gets the hosting scene
  90292. * @returns the hosting Scene
  90293. */
  90294. getScene(): Scene;
  90295. /**
  90296. * Gets the hosting engine
  90297. * @returns the hosting Engine
  90298. */
  90299. getEngine(): Engine;
  90300. /**
  90301. * Defines if the geometry is ready to use
  90302. * @returns true if the geometry is ready to be used
  90303. */
  90304. isReady(): boolean;
  90305. /**
  90306. * Gets a value indicating that the geometry should not be serialized
  90307. */
  90308. readonly doNotSerialize: boolean;
  90309. /** @hidden */
  90310. _rebuild(): void;
  90311. /**
  90312. * Affects all geometry data in one call
  90313. * @param vertexData defines the geometry data
  90314. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90315. */
  90316. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90317. /**
  90318. * Set specific vertex data
  90319. * @param kind defines the data kind (Position, normal, etc...)
  90320. * @param data defines the vertex data to use
  90321. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90322. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90323. */
  90324. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90325. /**
  90326. * Removes a specific vertex data
  90327. * @param kind defines the data kind (Position, normal, etc...)
  90328. */
  90329. removeVerticesData(kind: string): void;
  90330. /**
  90331. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90332. * @param buffer defines the vertex buffer to use
  90333. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90334. */
  90335. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90336. /**
  90337. * Update a specific vertex buffer
  90338. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90339. * It will do nothing if the buffer is not updatable
  90340. * @param kind defines the data kind (Position, normal, etc...)
  90341. * @param data defines the data to use
  90342. * @param offset defines the offset in the target buffer where to store the data
  90343. * @param useBytes set to true if the offset is in bytes
  90344. */
  90345. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90346. /**
  90347. * Update a specific vertex buffer
  90348. * This function will create a new buffer if the current one is not updatable
  90349. * @param kind defines the data kind (Position, normal, etc...)
  90350. * @param data defines the data to use
  90351. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90352. */
  90353. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90354. private _updateBoundingInfo;
  90355. /** @hidden */
  90356. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90357. /**
  90358. * Gets total number of vertices
  90359. * @returns the total number of vertices
  90360. */
  90361. getTotalVertices(): number;
  90362. /**
  90363. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90364. * @param kind defines the data kind (Position, normal, etc...)
  90365. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90366. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90367. * @returns a float array containing vertex data
  90368. */
  90369. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90370. /**
  90371. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90372. * @param kind defines the data kind (Position, normal, etc...)
  90373. * @returns true if the vertex buffer with the specified kind is updatable
  90374. */
  90375. isVertexBufferUpdatable(kind: string): boolean;
  90376. /**
  90377. * Gets a specific vertex buffer
  90378. * @param kind defines the data kind (Position, normal, etc...)
  90379. * @returns a VertexBuffer
  90380. */
  90381. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90382. /**
  90383. * Returns all vertex buffers
  90384. * @return an object holding all vertex buffers indexed by kind
  90385. */
  90386. getVertexBuffers(): Nullable<{
  90387. [key: string]: VertexBuffer;
  90388. }>;
  90389. /**
  90390. * Gets a boolean indicating if specific vertex buffer is present
  90391. * @param kind defines the data kind (Position, normal, etc...)
  90392. * @returns true if data is present
  90393. */
  90394. isVerticesDataPresent(kind: string): boolean;
  90395. /**
  90396. * Gets a list of all attached data kinds (Position, normal, etc...)
  90397. * @returns a list of string containing all kinds
  90398. */
  90399. getVerticesDataKinds(): string[];
  90400. /**
  90401. * Update index buffer
  90402. * @param indices defines the indices to store in the index buffer
  90403. * @param offset defines the offset in the target buffer where to store the data
  90404. * @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)
  90405. */
  90406. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90407. /**
  90408. * Creates a new index buffer
  90409. * @param indices defines the indices to store in the index buffer
  90410. * @param totalVertices defines the total number of vertices (could be null)
  90411. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90412. */
  90413. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90414. /**
  90415. * Return the total number of indices
  90416. * @returns the total number of indices
  90417. */
  90418. getTotalIndices(): number;
  90419. /**
  90420. * Gets the index buffer array
  90421. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90423. * @returns the index buffer array
  90424. */
  90425. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90426. /**
  90427. * Gets the index buffer
  90428. * @return the index buffer
  90429. */
  90430. getIndexBuffer(): Nullable<DataBuffer>;
  90431. /** @hidden */
  90432. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90433. /**
  90434. * Release the associated resources for a specific mesh
  90435. * @param mesh defines the source mesh
  90436. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90437. */
  90438. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90439. /**
  90440. * Apply current geometry to a given mesh
  90441. * @param mesh defines the mesh to apply geometry to
  90442. */
  90443. applyToMesh(mesh: Mesh): void;
  90444. private _updateExtend;
  90445. private _applyToMesh;
  90446. private notifyUpdate;
  90447. /**
  90448. * Load the geometry if it was flagged as delay loaded
  90449. * @param scene defines the hosting scene
  90450. * @param onLoaded defines a callback called when the geometry is loaded
  90451. */
  90452. load(scene: Scene, onLoaded?: () => void): void;
  90453. private _queueLoad;
  90454. /**
  90455. * Invert the geometry to move from a right handed system to a left handed one.
  90456. */
  90457. toLeftHanded(): void;
  90458. /** @hidden */
  90459. _resetPointsArrayCache(): void;
  90460. /** @hidden */
  90461. _generatePointsArray(): boolean;
  90462. /**
  90463. * Gets a value indicating if the geometry is disposed
  90464. * @returns true if the geometry was disposed
  90465. */
  90466. isDisposed(): boolean;
  90467. private _disposeVertexArrayObjects;
  90468. /**
  90469. * Free all associated resources
  90470. */
  90471. dispose(): void;
  90472. /**
  90473. * Clone the current geometry into a new geometry
  90474. * @param id defines the unique ID of the new geometry
  90475. * @returns a new geometry object
  90476. */
  90477. copy(id: string): Geometry;
  90478. /**
  90479. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90480. * @return a JSON representation of the current geometry data (without the vertices data)
  90481. */
  90482. serialize(): any;
  90483. private toNumberArray;
  90484. /**
  90485. * Serialize all vertices data into a JSON oject
  90486. * @returns a JSON representation of the current geometry data
  90487. */
  90488. serializeVerticeData(): any;
  90489. /**
  90490. * Extracts a clone of a mesh geometry
  90491. * @param mesh defines the source mesh
  90492. * @param id defines the unique ID of the new geometry object
  90493. * @returns the new geometry object
  90494. */
  90495. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90496. /**
  90497. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90498. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90499. * Be aware Math.random() could cause collisions, but:
  90500. * "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"
  90501. * @returns a string containing a new GUID
  90502. */
  90503. static RandomId(): string;
  90504. /** @hidden */
  90505. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90506. private static _CleanMatricesWeights;
  90507. /**
  90508. * Create a new geometry from persisted data (Using .babylon file format)
  90509. * @param parsedVertexData defines the persisted data
  90510. * @param scene defines the hosting scene
  90511. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90512. * @returns the new geometry object
  90513. */
  90514. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90515. }
  90516. }
  90517. declare module BABYLON {
  90518. /**
  90519. * Define an interface for all classes that will get and set the data on vertices
  90520. */
  90521. export interface IGetSetVerticesData {
  90522. /**
  90523. * Gets a boolean indicating if specific vertex data is present
  90524. * @param kind defines the vertex data kind to use
  90525. * @returns true is data kind is present
  90526. */
  90527. isVerticesDataPresent(kind: string): boolean;
  90528. /**
  90529. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90530. * @param kind defines the data kind (Position, normal, etc...)
  90531. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90532. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90533. * @returns a float array containing vertex data
  90534. */
  90535. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90536. /**
  90537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90538. * @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.
  90539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90540. * @returns the indices array or an empty array if the mesh has no geometry
  90541. */
  90542. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90543. /**
  90544. * Set specific vertex data
  90545. * @param kind defines the data kind (Position, normal, etc...)
  90546. * @param data defines the vertex data to use
  90547. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90548. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90549. */
  90550. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90551. /**
  90552. * Update a specific associated vertex buffer
  90553. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90554. * - VertexBuffer.PositionKind
  90555. * - VertexBuffer.UVKind
  90556. * - VertexBuffer.UV2Kind
  90557. * - VertexBuffer.UV3Kind
  90558. * - VertexBuffer.UV4Kind
  90559. * - VertexBuffer.UV5Kind
  90560. * - VertexBuffer.UV6Kind
  90561. * - VertexBuffer.ColorKind
  90562. * - VertexBuffer.MatricesIndicesKind
  90563. * - VertexBuffer.MatricesIndicesExtraKind
  90564. * - VertexBuffer.MatricesWeightsKind
  90565. * - VertexBuffer.MatricesWeightsExtraKind
  90566. * @param data defines the data source
  90567. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90568. * @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)
  90569. */
  90570. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90571. /**
  90572. * Creates a new index buffer
  90573. * @param indices defines the indices to store in the index buffer
  90574. * @param totalVertices defines the total number of vertices (could be null)
  90575. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90576. */
  90577. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90578. }
  90579. /**
  90580. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90581. */
  90582. export class VertexData {
  90583. /**
  90584. * Mesh side orientation : usually the external or front surface
  90585. */
  90586. static readonly FRONTSIDE: number;
  90587. /**
  90588. * Mesh side orientation : usually the internal or back surface
  90589. */
  90590. static readonly BACKSIDE: number;
  90591. /**
  90592. * Mesh side orientation : both internal and external or front and back surfaces
  90593. */
  90594. static readonly DOUBLESIDE: number;
  90595. /**
  90596. * Mesh side orientation : by default, `FRONTSIDE`
  90597. */
  90598. static readonly DEFAULTSIDE: number;
  90599. /**
  90600. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90601. */
  90602. positions: Nullable<FloatArray>;
  90603. /**
  90604. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90605. */
  90606. normals: Nullable<FloatArray>;
  90607. /**
  90608. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90609. */
  90610. tangents: Nullable<FloatArray>;
  90611. /**
  90612. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90613. */
  90614. uvs: Nullable<FloatArray>;
  90615. /**
  90616. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90617. */
  90618. uvs2: Nullable<FloatArray>;
  90619. /**
  90620. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90621. */
  90622. uvs3: Nullable<FloatArray>;
  90623. /**
  90624. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90625. */
  90626. uvs4: Nullable<FloatArray>;
  90627. /**
  90628. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90629. */
  90630. uvs5: Nullable<FloatArray>;
  90631. /**
  90632. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90633. */
  90634. uvs6: Nullable<FloatArray>;
  90635. /**
  90636. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90637. */
  90638. colors: Nullable<FloatArray>;
  90639. /**
  90640. * 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).
  90641. */
  90642. matricesIndices: Nullable<FloatArray>;
  90643. /**
  90644. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90645. */
  90646. matricesWeights: Nullable<FloatArray>;
  90647. /**
  90648. * An array extending the number of possible indices
  90649. */
  90650. matricesIndicesExtra: Nullable<FloatArray>;
  90651. /**
  90652. * An array extending the number of possible weights when the number of indices is extended
  90653. */
  90654. matricesWeightsExtra: Nullable<FloatArray>;
  90655. /**
  90656. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90657. */
  90658. indices: Nullable<IndicesArray>;
  90659. /**
  90660. * Uses the passed data array to set the set the values for the specified kind of data
  90661. * @param data a linear array of floating numbers
  90662. * @param kind the type of data that is being set, eg positions, colors etc
  90663. */
  90664. set(data: FloatArray, kind: string): void;
  90665. /**
  90666. * Associates the vertexData to the passed Mesh.
  90667. * Sets it as updatable or not (default `false`)
  90668. * @param mesh the mesh the vertexData is applied to
  90669. * @param updatable when used and having the value true allows new data to update the vertexData
  90670. * @returns the VertexData
  90671. */
  90672. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90673. /**
  90674. * Associates the vertexData to the passed Geometry.
  90675. * Sets it as updatable or not (default `false`)
  90676. * @param geometry the geometry the vertexData is applied to
  90677. * @param updatable when used and having the value true allows new data to update the vertexData
  90678. * @returns VertexData
  90679. */
  90680. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90681. /**
  90682. * Updates the associated mesh
  90683. * @param mesh the mesh to be updated
  90684. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90685. * @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
  90686. * @returns VertexData
  90687. */
  90688. updateMesh(mesh: Mesh): VertexData;
  90689. /**
  90690. * Updates the associated geometry
  90691. * @param geometry the geometry to be updated
  90692. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90693. * @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
  90694. * @returns VertexData.
  90695. */
  90696. updateGeometry(geometry: Geometry): VertexData;
  90697. private _applyTo;
  90698. private _update;
  90699. /**
  90700. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90701. * @param matrix the transforming matrix
  90702. * @returns the VertexData
  90703. */
  90704. transform(matrix: Matrix): VertexData;
  90705. /**
  90706. * Merges the passed VertexData into the current one
  90707. * @param other the VertexData to be merged into the current one
  90708. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90709. * @returns the modified VertexData
  90710. */
  90711. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90712. private _mergeElement;
  90713. private _validate;
  90714. /**
  90715. * Serializes the VertexData
  90716. * @returns a serialized object
  90717. */
  90718. serialize(): any;
  90719. /**
  90720. * Extracts the vertexData from a mesh
  90721. * @param mesh the mesh from which to extract the VertexData
  90722. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90723. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90724. * @returns the object VertexData associated to the passed mesh
  90725. */
  90726. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90727. /**
  90728. * Extracts the vertexData from the geometry
  90729. * @param geometry the geometry from which to extract the VertexData
  90730. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90731. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90732. * @returns the object VertexData associated to the passed mesh
  90733. */
  90734. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90735. private static _ExtractFrom;
  90736. /**
  90737. * Creates the VertexData for a Ribbon
  90738. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90739. * * pathArray array of paths, each of which an array of successive Vector3
  90740. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90741. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90742. * * 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
  90743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90744. * * 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)
  90745. * * 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)
  90746. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90747. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90748. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90749. * @returns the VertexData of the ribbon
  90750. */
  90751. static CreateRibbon(options: {
  90752. pathArray: Vector3[][];
  90753. closeArray?: boolean;
  90754. closePath?: boolean;
  90755. offset?: number;
  90756. sideOrientation?: number;
  90757. frontUVs?: Vector4;
  90758. backUVs?: Vector4;
  90759. invertUV?: boolean;
  90760. uvs?: Vector2[];
  90761. colors?: Color4[];
  90762. }): VertexData;
  90763. /**
  90764. * Creates the VertexData for a box
  90765. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90766. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90767. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90768. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90769. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90770. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90771. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90772. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90773. * * 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)
  90774. * * 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)
  90775. * @returns the VertexData of the box
  90776. */
  90777. static CreateBox(options: {
  90778. size?: number;
  90779. width?: number;
  90780. height?: number;
  90781. depth?: number;
  90782. faceUV?: Vector4[];
  90783. faceColors?: Color4[];
  90784. sideOrientation?: number;
  90785. frontUVs?: Vector4;
  90786. backUVs?: Vector4;
  90787. }): VertexData;
  90788. /**
  90789. * Creates the VertexData for a tiled box
  90790. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90791. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90792. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90793. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90795. * @returns the VertexData of the box
  90796. */
  90797. static CreateTiledBox(options: {
  90798. pattern?: number;
  90799. width?: number;
  90800. height?: number;
  90801. depth?: number;
  90802. tileSize?: number;
  90803. tileWidth?: number;
  90804. tileHeight?: number;
  90805. alignHorizontal?: number;
  90806. alignVertical?: number;
  90807. faceUV?: Vector4[];
  90808. faceColors?: Color4[];
  90809. sideOrientation?: number;
  90810. }): VertexData;
  90811. /**
  90812. * Creates the VertexData for a tiled plane
  90813. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90814. * * pattern a limited pattern arrangement depending on the number
  90815. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90816. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90817. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90819. * * 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)
  90820. * * 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)
  90821. * @returns the VertexData of the tiled plane
  90822. */
  90823. static CreateTiledPlane(options: {
  90824. pattern?: number;
  90825. tileSize?: number;
  90826. tileWidth?: number;
  90827. tileHeight?: number;
  90828. size?: number;
  90829. width?: number;
  90830. height?: number;
  90831. alignHorizontal?: number;
  90832. alignVertical?: number;
  90833. sideOrientation?: number;
  90834. frontUVs?: Vector4;
  90835. backUVs?: Vector4;
  90836. }): VertexData;
  90837. /**
  90838. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90839. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90840. * * segments sets the number of horizontal strips optional, default 32
  90841. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90842. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90843. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90844. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90845. * * 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
  90846. * * 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
  90847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90848. * * 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)
  90849. * * 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)
  90850. * @returns the VertexData of the ellipsoid
  90851. */
  90852. static CreateSphere(options: {
  90853. segments?: number;
  90854. diameter?: number;
  90855. diameterX?: number;
  90856. diameterY?: number;
  90857. diameterZ?: number;
  90858. arc?: number;
  90859. slice?: number;
  90860. sideOrientation?: number;
  90861. frontUVs?: Vector4;
  90862. backUVs?: Vector4;
  90863. }): VertexData;
  90864. /**
  90865. * Creates the VertexData for a cylinder, cone or prism
  90866. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90867. * * height sets the height (y direction) of the cylinder, optional, default 2
  90868. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90869. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90870. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90871. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90872. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90873. * * 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
  90874. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90875. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90876. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90877. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90879. * * 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)
  90880. * * 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)
  90881. * @returns the VertexData of the cylinder, cone or prism
  90882. */
  90883. static CreateCylinder(options: {
  90884. height?: number;
  90885. diameterTop?: number;
  90886. diameterBottom?: number;
  90887. diameter?: number;
  90888. tessellation?: number;
  90889. subdivisions?: number;
  90890. arc?: number;
  90891. faceColors?: Color4[];
  90892. faceUV?: Vector4[];
  90893. hasRings?: boolean;
  90894. enclose?: boolean;
  90895. sideOrientation?: number;
  90896. frontUVs?: Vector4;
  90897. backUVs?: Vector4;
  90898. }): VertexData;
  90899. /**
  90900. * Creates the VertexData for a torus
  90901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90902. * * diameter the diameter of the torus, optional default 1
  90903. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90904. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90906. * * 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)
  90907. * * 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)
  90908. * @returns the VertexData of the torus
  90909. */
  90910. static CreateTorus(options: {
  90911. diameter?: number;
  90912. thickness?: number;
  90913. tessellation?: number;
  90914. sideOrientation?: number;
  90915. frontUVs?: Vector4;
  90916. backUVs?: Vector4;
  90917. }): VertexData;
  90918. /**
  90919. * Creates the VertexData of the LineSystem
  90920. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90921. * - lines an array of lines, each line being an array of successive Vector3
  90922. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90923. * @returns the VertexData of the LineSystem
  90924. */
  90925. static CreateLineSystem(options: {
  90926. lines: Vector3[][];
  90927. colors?: Nullable<Color4[][]>;
  90928. }): VertexData;
  90929. /**
  90930. * Create the VertexData for a DashedLines
  90931. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90932. * - points an array successive Vector3
  90933. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90934. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90935. * - dashNb the intended total number of dashes, optional, default 200
  90936. * @returns the VertexData for the DashedLines
  90937. */
  90938. static CreateDashedLines(options: {
  90939. points: Vector3[];
  90940. dashSize?: number;
  90941. gapSize?: number;
  90942. dashNb?: number;
  90943. }): VertexData;
  90944. /**
  90945. * Creates the VertexData for a Ground
  90946. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90947. * - width the width (x direction) of the ground, optional, default 1
  90948. * - height the height (z direction) of the ground, optional, default 1
  90949. * - subdivisions the number of subdivisions per side, optional, default 1
  90950. * @returns the VertexData of the Ground
  90951. */
  90952. static CreateGround(options: {
  90953. width?: number;
  90954. height?: number;
  90955. subdivisions?: number;
  90956. subdivisionsX?: number;
  90957. subdivisionsY?: number;
  90958. }): VertexData;
  90959. /**
  90960. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90961. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90962. * * xmin the ground minimum X coordinate, optional, default -1
  90963. * * zmin the ground minimum Z coordinate, optional, default -1
  90964. * * xmax the ground maximum X coordinate, optional, default 1
  90965. * * zmax the ground maximum Z coordinate, optional, default 1
  90966. * * 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}
  90967. * * 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}
  90968. * @returns the VertexData of the TiledGround
  90969. */
  90970. static CreateTiledGround(options: {
  90971. xmin: number;
  90972. zmin: number;
  90973. xmax: number;
  90974. zmax: number;
  90975. subdivisions?: {
  90976. w: number;
  90977. h: number;
  90978. };
  90979. precision?: {
  90980. w: number;
  90981. h: number;
  90982. };
  90983. }): VertexData;
  90984. /**
  90985. * Creates the VertexData of the Ground designed from a heightmap
  90986. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90987. * * width the width (x direction) of the ground
  90988. * * height the height (z direction) of the ground
  90989. * * subdivisions the number of subdivisions per side
  90990. * * minHeight the minimum altitude on the ground, optional, default 0
  90991. * * maxHeight the maximum altitude on the ground, optional default 1
  90992. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90993. * * buffer the array holding the image color data
  90994. * * bufferWidth the width of image
  90995. * * bufferHeight the height of image
  90996. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90997. * @returns the VertexData of the Ground designed from a heightmap
  90998. */
  90999. static CreateGroundFromHeightMap(options: {
  91000. width: number;
  91001. height: number;
  91002. subdivisions: number;
  91003. minHeight: number;
  91004. maxHeight: number;
  91005. colorFilter: Color3;
  91006. buffer: Uint8Array;
  91007. bufferWidth: number;
  91008. bufferHeight: number;
  91009. alphaFilter: number;
  91010. }): VertexData;
  91011. /**
  91012. * Creates the VertexData for a Plane
  91013. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91014. * * size sets the width and height of the plane to the value of size, optional default 1
  91015. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91016. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91018. * * 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)
  91019. * * 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)
  91020. * @returns the VertexData of the box
  91021. */
  91022. static CreatePlane(options: {
  91023. size?: number;
  91024. width?: number;
  91025. height?: number;
  91026. sideOrientation?: number;
  91027. frontUVs?: Vector4;
  91028. backUVs?: Vector4;
  91029. }): VertexData;
  91030. /**
  91031. * Creates the VertexData of the Disc or regular Polygon
  91032. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91033. * * radius the radius of the disc, optional default 0.5
  91034. * * tessellation the number of polygon sides, optional, default 64
  91035. * * 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
  91036. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91037. * * 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)
  91038. * * 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)
  91039. * @returns the VertexData of the box
  91040. */
  91041. static CreateDisc(options: {
  91042. radius?: number;
  91043. tessellation?: number;
  91044. arc?: number;
  91045. sideOrientation?: number;
  91046. frontUVs?: Vector4;
  91047. backUVs?: Vector4;
  91048. }): VertexData;
  91049. /**
  91050. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91051. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91052. * @param polygon a mesh built from polygonTriangulation.build()
  91053. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91054. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91055. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91056. * @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)
  91057. * @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)
  91058. * @returns the VertexData of the Polygon
  91059. */
  91060. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91061. /**
  91062. * Creates the VertexData of the IcoSphere
  91063. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91064. * * radius the radius of the IcoSphere, optional default 1
  91065. * * radiusX allows stretching in the x direction, optional, default radius
  91066. * * radiusY allows stretching in the y direction, optional, default radius
  91067. * * radiusZ allows stretching in the z direction, optional, default radius
  91068. * * flat when true creates a flat shaded mesh, optional, default true
  91069. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  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 IcoSphere
  91074. */
  91075. static CreateIcoSphere(options: {
  91076. radius?: number;
  91077. radiusX?: number;
  91078. radiusY?: number;
  91079. radiusZ?: number;
  91080. flat?: boolean;
  91081. subdivisions?: number;
  91082. sideOrientation?: number;
  91083. frontUVs?: Vector4;
  91084. backUVs?: Vector4;
  91085. }): VertexData;
  91086. /**
  91087. * Creates the VertexData for a Polyhedron
  91088. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91089. * * type provided types are:
  91090. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91091. * * 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)
  91092. * * size the size of the IcoSphere, optional default 1
  91093. * * sizeX allows stretching in the x direction, optional, default size
  91094. * * sizeY allows stretching in the y direction, optional, default size
  91095. * * sizeZ allows stretching in the z direction, optional, default size
  91096. * * 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
  91097. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91098. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91099. * * flat when true creates a flat shaded mesh, optional, default true
  91100. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91101. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91102. * * 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)
  91103. * * 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)
  91104. * @returns the VertexData of the Polyhedron
  91105. */
  91106. static CreatePolyhedron(options: {
  91107. type?: number;
  91108. size?: number;
  91109. sizeX?: number;
  91110. sizeY?: number;
  91111. sizeZ?: number;
  91112. custom?: any;
  91113. faceUV?: Vector4[];
  91114. faceColors?: Color4[];
  91115. flat?: boolean;
  91116. sideOrientation?: number;
  91117. frontUVs?: Vector4;
  91118. backUVs?: Vector4;
  91119. }): VertexData;
  91120. /**
  91121. * Creates the VertexData for a TorusKnot
  91122. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91123. * * radius the radius of the torus knot, optional, default 2
  91124. * * tube the thickness of the tube, optional, default 0.5
  91125. * * radialSegments the number of sides on each tube segments, optional, default 32
  91126. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91127. * * p the number of windings around the z axis, optional, default 2
  91128. * * q the number of windings around the x axis, optional, default 3
  91129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91130. * * 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)
  91131. * * 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)
  91132. * @returns the VertexData of the Torus Knot
  91133. */
  91134. static CreateTorusKnot(options: {
  91135. radius?: number;
  91136. tube?: number;
  91137. radialSegments?: number;
  91138. tubularSegments?: number;
  91139. p?: number;
  91140. q?: number;
  91141. sideOrientation?: number;
  91142. frontUVs?: Vector4;
  91143. backUVs?: Vector4;
  91144. }): VertexData;
  91145. /**
  91146. * Compute normals for given positions and indices
  91147. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91148. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91149. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91150. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91151. * * facetNormals : optional array of facet normals (vector3)
  91152. * * facetPositions : optional array of facet positions (vector3)
  91153. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91154. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91155. * * bInfo : optional bounding info, required for facetPartitioning computation
  91156. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91157. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91158. * * useRightHandedSystem: optional boolean to for right handed system computation
  91159. * * depthSort : optional boolean to enable the facet depth sort computation
  91160. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91161. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91162. */
  91163. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91164. facetNormals?: any;
  91165. facetPositions?: any;
  91166. facetPartitioning?: any;
  91167. ratio?: number;
  91168. bInfo?: any;
  91169. bbSize?: Vector3;
  91170. subDiv?: any;
  91171. useRightHandedSystem?: boolean;
  91172. depthSort?: boolean;
  91173. distanceTo?: Vector3;
  91174. depthSortedFacets?: any;
  91175. }): void;
  91176. /** @hidden */
  91177. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91178. /**
  91179. * Applies VertexData created from the imported parameters to the geometry
  91180. * @param parsedVertexData the parsed data from an imported file
  91181. * @param geometry the geometry to apply the VertexData to
  91182. */
  91183. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91184. }
  91185. }
  91186. declare module BABYLON {
  91187. /**
  91188. * Defines a target to use with MorphTargetManager
  91189. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91190. */
  91191. export class MorphTarget implements IAnimatable {
  91192. /** defines the name of the target */
  91193. name: string;
  91194. /**
  91195. * Gets or sets the list of animations
  91196. */
  91197. animations: Animation[];
  91198. private _scene;
  91199. private _positions;
  91200. private _normals;
  91201. private _tangents;
  91202. private _uvs;
  91203. private _influence;
  91204. private _uniqueId;
  91205. /**
  91206. * Observable raised when the influence changes
  91207. */
  91208. onInfluenceChanged: Observable<boolean>;
  91209. /** @hidden */
  91210. _onDataLayoutChanged: Observable<void>;
  91211. /**
  91212. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91213. */
  91214. influence: number;
  91215. /**
  91216. * Gets or sets the id of the morph Target
  91217. */
  91218. id: string;
  91219. private _animationPropertiesOverride;
  91220. /**
  91221. * Gets or sets the animation properties override
  91222. */
  91223. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91224. /**
  91225. * Creates a new MorphTarget
  91226. * @param name defines the name of the target
  91227. * @param influence defines the influence to use
  91228. * @param scene defines the scene the morphtarget belongs to
  91229. */
  91230. constructor(
  91231. /** defines the name of the target */
  91232. name: string, influence?: number, scene?: Nullable<Scene>);
  91233. /**
  91234. * Gets the unique ID of this manager
  91235. */
  91236. readonly uniqueId: number;
  91237. /**
  91238. * Gets a boolean defining if the target contains position data
  91239. */
  91240. readonly hasPositions: boolean;
  91241. /**
  91242. * Gets a boolean defining if the target contains normal data
  91243. */
  91244. readonly hasNormals: boolean;
  91245. /**
  91246. * Gets a boolean defining if the target contains tangent data
  91247. */
  91248. readonly hasTangents: boolean;
  91249. /**
  91250. * Gets a boolean defining if the target contains texture coordinates data
  91251. */
  91252. readonly hasUVs: boolean;
  91253. /**
  91254. * Affects position data to this target
  91255. * @param data defines the position data to use
  91256. */
  91257. setPositions(data: Nullable<FloatArray>): void;
  91258. /**
  91259. * Gets the position data stored in this target
  91260. * @returns a FloatArray containing the position data (or null if not present)
  91261. */
  91262. getPositions(): Nullable<FloatArray>;
  91263. /**
  91264. * Affects normal data to this target
  91265. * @param data defines the normal data to use
  91266. */
  91267. setNormals(data: Nullable<FloatArray>): void;
  91268. /**
  91269. * Gets the normal data stored in this target
  91270. * @returns a FloatArray containing the normal data (or null if not present)
  91271. */
  91272. getNormals(): Nullable<FloatArray>;
  91273. /**
  91274. * Affects tangent data to this target
  91275. * @param data defines the tangent data to use
  91276. */
  91277. setTangents(data: Nullable<FloatArray>): void;
  91278. /**
  91279. * Gets the tangent data stored in this target
  91280. * @returns a FloatArray containing the tangent data (or null if not present)
  91281. */
  91282. getTangents(): Nullable<FloatArray>;
  91283. /**
  91284. * Affects texture coordinates data to this target
  91285. * @param data defines the texture coordinates data to use
  91286. */
  91287. setUVs(data: Nullable<FloatArray>): void;
  91288. /**
  91289. * Gets the texture coordinates data stored in this target
  91290. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91291. */
  91292. getUVs(): Nullable<FloatArray>;
  91293. /**
  91294. * Clone the current target
  91295. * @returns a new MorphTarget
  91296. */
  91297. clone(): MorphTarget;
  91298. /**
  91299. * Serializes the current target into a Serialization object
  91300. * @returns the serialized object
  91301. */
  91302. serialize(): any;
  91303. /**
  91304. * Returns the string "MorphTarget"
  91305. * @returns "MorphTarget"
  91306. */
  91307. getClassName(): string;
  91308. /**
  91309. * Creates a new target from serialized data
  91310. * @param serializationObject defines the serialized data to use
  91311. * @returns a new MorphTarget
  91312. */
  91313. static Parse(serializationObject: any): MorphTarget;
  91314. /**
  91315. * Creates a MorphTarget from mesh data
  91316. * @param mesh defines the source mesh
  91317. * @param name defines the name to use for the new target
  91318. * @param influence defines the influence to attach to the target
  91319. * @returns a new MorphTarget
  91320. */
  91321. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91322. }
  91323. }
  91324. declare module BABYLON {
  91325. /**
  91326. * This class is used to deform meshes using morphing between different targets
  91327. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91328. */
  91329. export class MorphTargetManager {
  91330. private _targets;
  91331. private _targetInfluenceChangedObservers;
  91332. private _targetDataLayoutChangedObservers;
  91333. private _activeTargets;
  91334. private _scene;
  91335. private _influences;
  91336. private _supportsNormals;
  91337. private _supportsTangents;
  91338. private _supportsUVs;
  91339. private _vertexCount;
  91340. private _uniqueId;
  91341. private _tempInfluences;
  91342. /**
  91343. * Gets or sets a boolean indicating if normals must be morphed
  91344. */
  91345. enableNormalMorphing: boolean;
  91346. /**
  91347. * Gets or sets a boolean indicating if tangents must be morphed
  91348. */
  91349. enableTangentMorphing: boolean;
  91350. /**
  91351. * Gets or sets a boolean indicating if UV must be morphed
  91352. */
  91353. enableUVMorphing: boolean;
  91354. /**
  91355. * Creates a new MorphTargetManager
  91356. * @param scene defines the current scene
  91357. */
  91358. constructor(scene?: Nullable<Scene>);
  91359. /**
  91360. * Gets the unique ID of this manager
  91361. */
  91362. readonly uniqueId: number;
  91363. /**
  91364. * Gets the number of vertices handled by this manager
  91365. */
  91366. readonly vertexCount: number;
  91367. /**
  91368. * Gets a boolean indicating if this manager supports morphing of normals
  91369. */
  91370. readonly supportsNormals: boolean;
  91371. /**
  91372. * Gets a boolean indicating if this manager supports morphing of tangents
  91373. */
  91374. readonly supportsTangents: boolean;
  91375. /**
  91376. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91377. */
  91378. readonly supportsUVs: boolean;
  91379. /**
  91380. * Gets the number of targets stored in this manager
  91381. */
  91382. readonly numTargets: number;
  91383. /**
  91384. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91385. */
  91386. readonly numInfluencers: number;
  91387. /**
  91388. * Gets the list of influences (one per target)
  91389. */
  91390. readonly influences: Float32Array;
  91391. /**
  91392. * Gets the active target at specified index. An active target is a target with an influence > 0
  91393. * @param index defines the index to check
  91394. * @returns the requested target
  91395. */
  91396. getActiveTarget(index: number): MorphTarget;
  91397. /**
  91398. * Gets the target at specified index
  91399. * @param index defines the index to check
  91400. * @returns the requested target
  91401. */
  91402. getTarget(index: number): MorphTarget;
  91403. /**
  91404. * Add a new target to this manager
  91405. * @param target defines the target to add
  91406. */
  91407. addTarget(target: MorphTarget): void;
  91408. /**
  91409. * Removes a target from the manager
  91410. * @param target defines the target to remove
  91411. */
  91412. removeTarget(target: MorphTarget): void;
  91413. /**
  91414. * Clone the current manager
  91415. * @returns a new MorphTargetManager
  91416. */
  91417. clone(): MorphTargetManager;
  91418. /**
  91419. * Serializes the current manager into a Serialization object
  91420. * @returns the serialized object
  91421. */
  91422. serialize(): any;
  91423. private _syncActiveTargets;
  91424. /**
  91425. * Syncrhonize the targets with all the meshes using this morph target manager
  91426. */
  91427. synchronize(): void;
  91428. /**
  91429. * Creates a new MorphTargetManager from serialized data
  91430. * @param serializationObject defines the serialized data
  91431. * @param scene defines the hosting scene
  91432. * @returns the new MorphTargetManager
  91433. */
  91434. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91435. }
  91436. }
  91437. declare module BABYLON {
  91438. /**
  91439. * Class used to represent a specific level of detail of a mesh
  91440. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91441. */
  91442. export class MeshLODLevel {
  91443. /** Defines the distance where this level should start being displayed */
  91444. distance: number;
  91445. /** Defines the mesh to use to render this level */
  91446. mesh: Nullable<Mesh>;
  91447. /**
  91448. * Creates a new LOD level
  91449. * @param distance defines the distance where this level should star being displayed
  91450. * @param mesh defines the mesh to use to render this level
  91451. */
  91452. constructor(
  91453. /** Defines the distance where this level should start being displayed */
  91454. distance: number,
  91455. /** Defines the mesh to use to render this level */
  91456. mesh: Nullable<Mesh>);
  91457. }
  91458. }
  91459. declare module BABYLON {
  91460. /**
  91461. * Mesh representing the gorund
  91462. */
  91463. export class GroundMesh extends Mesh {
  91464. /** If octree should be generated */
  91465. generateOctree: boolean;
  91466. private _heightQuads;
  91467. /** @hidden */
  91468. _subdivisionsX: number;
  91469. /** @hidden */
  91470. _subdivisionsY: number;
  91471. /** @hidden */
  91472. _width: number;
  91473. /** @hidden */
  91474. _height: number;
  91475. /** @hidden */
  91476. _minX: number;
  91477. /** @hidden */
  91478. _maxX: number;
  91479. /** @hidden */
  91480. _minZ: number;
  91481. /** @hidden */
  91482. _maxZ: number;
  91483. constructor(name: string, scene: Scene);
  91484. /**
  91485. * "GroundMesh"
  91486. * @returns "GroundMesh"
  91487. */
  91488. getClassName(): string;
  91489. /**
  91490. * The minimum of x and y subdivisions
  91491. */
  91492. readonly subdivisions: number;
  91493. /**
  91494. * X subdivisions
  91495. */
  91496. readonly subdivisionsX: number;
  91497. /**
  91498. * Y subdivisions
  91499. */
  91500. readonly subdivisionsY: number;
  91501. /**
  91502. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91503. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91504. * @param chunksCount the number of subdivisions for x and y
  91505. * @param octreeBlocksSize (Default: 32)
  91506. */
  91507. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91508. /**
  91509. * Returns a height (y) value in the Worl system :
  91510. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91511. * @param x x coordinate
  91512. * @param z z coordinate
  91513. * @returns the ground y position if (x, z) are outside the ground surface.
  91514. */
  91515. getHeightAtCoordinates(x: number, z: number): number;
  91516. /**
  91517. * Returns a normalized vector (Vector3) orthogonal to the ground
  91518. * at the ground coordinates (x, z) expressed in the World system.
  91519. * @param x x coordinate
  91520. * @param z z coordinate
  91521. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91522. */
  91523. getNormalAtCoordinates(x: number, z: number): Vector3;
  91524. /**
  91525. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  91526. * at the ground coordinates (x, z) expressed in the World system.
  91527. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  91528. * @param x x coordinate
  91529. * @param z z coordinate
  91530. * @param ref vector to store the result
  91531. * @returns the GroundMesh.
  91532. */
  91533. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  91534. /**
  91535. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  91536. * if the ground has been updated.
  91537. * This can be used in the render loop.
  91538. * @returns the GroundMesh.
  91539. */
  91540. updateCoordinateHeights(): GroundMesh;
  91541. private _getFacetAt;
  91542. private _initHeightQuads;
  91543. private _computeHeightQuads;
  91544. /**
  91545. * Serializes this ground mesh
  91546. * @param serializationObject object to write serialization to
  91547. */
  91548. serialize(serializationObject: any): void;
  91549. /**
  91550. * Parses a serialized ground mesh
  91551. * @param parsedMesh the serialized mesh
  91552. * @param scene the scene to create the ground mesh in
  91553. * @returns the created ground mesh
  91554. */
  91555. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91556. }
  91557. }
  91558. declare module BABYLON {
  91559. /**
  91560. * Interface for Physics-Joint data
  91561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91562. */
  91563. export interface PhysicsJointData {
  91564. /**
  91565. * The main pivot of the joint
  91566. */
  91567. mainPivot?: Vector3;
  91568. /**
  91569. * The connected pivot of the joint
  91570. */
  91571. connectedPivot?: Vector3;
  91572. /**
  91573. * The main axis of the joint
  91574. */
  91575. mainAxis?: Vector3;
  91576. /**
  91577. * The connected axis of the joint
  91578. */
  91579. connectedAxis?: Vector3;
  91580. /**
  91581. * The collision of the joint
  91582. */
  91583. collision?: boolean;
  91584. /**
  91585. * Native Oimo/Cannon/Energy data
  91586. */
  91587. nativeParams?: any;
  91588. }
  91589. /**
  91590. * This is a holder class for the physics joint created by the physics plugin
  91591. * It holds a set of functions to control the underlying joint
  91592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91593. */
  91594. export class PhysicsJoint {
  91595. /**
  91596. * The type of the physics joint
  91597. */
  91598. type: number;
  91599. /**
  91600. * The data for the physics joint
  91601. */
  91602. jointData: PhysicsJointData;
  91603. private _physicsJoint;
  91604. protected _physicsPlugin: IPhysicsEnginePlugin;
  91605. /**
  91606. * Initializes the physics joint
  91607. * @param type The type of the physics joint
  91608. * @param jointData The data for the physics joint
  91609. */
  91610. constructor(
  91611. /**
  91612. * The type of the physics joint
  91613. */
  91614. type: number,
  91615. /**
  91616. * The data for the physics joint
  91617. */
  91618. jointData: PhysicsJointData);
  91619. /**
  91620. * Gets the physics joint
  91621. */
  91622. /**
  91623. * Sets the physics joint
  91624. */
  91625. physicsJoint: any;
  91626. /**
  91627. * Sets the physics plugin
  91628. */
  91629. physicsPlugin: IPhysicsEnginePlugin;
  91630. /**
  91631. * Execute a function that is physics-plugin specific.
  91632. * @param {Function} func the function that will be executed.
  91633. * It accepts two parameters: the physics world and the physics joint
  91634. */
  91635. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91636. /**
  91637. * Distance-Joint type
  91638. */
  91639. static DistanceJoint: number;
  91640. /**
  91641. * Hinge-Joint type
  91642. */
  91643. static HingeJoint: number;
  91644. /**
  91645. * Ball-and-Socket joint type
  91646. */
  91647. static BallAndSocketJoint: number;
  91648. /**
  91649. * Wheel-Joint type
  91650. */
  91651. static WheelJoint: number;
  91652. /**
  91653. * Slider-Joint type
  91654. */
  91655. static SliderJoint: number;
  91656. /**
  91657. * Prismatic-Joint type
  91658. */
  91659. static PrismaticJoint: number;
  91660. /**
  91661. * Universal-Joint type
  91662. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91663. */
  91664. static UniversalJoint: number;
  91665. /**
  91666. * Hinge-Joint 2 type
  91667. */
  91668. static Hinge2Joint: number;
  91669. /**
  91670. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91671. */
  91672. static PointToPointJoint: number;
  91673. /**
  91674. * Spring-Joint type
  91675. */
  91676. static SpringJoint: number;
  91677. /**
  91678. * Lock-Joint type
  91679. */
  91680. static LockJoint: number;
  91681. }
  91682. /**
  91683. * A class representing a physics distance joint
  91684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91685. */
  91686. export class DistanceJoint extends PhysicsJoint {
  91687. /**
  91688. *
  91689. * @param jointData The data for the Distance-Joint
  91690. */
  91691. constructor(jointData: DistanceJointData);
  91692. /**
  91693. * Update the predefined distance.
  91694. * @param maxDistance The maximum preferred distance
  91695. * @param minDistance The minimum preferred distance
  91696. */
  91697. updateDistance(maxDistance: number, minDistance?: number): void;
  91698. }
  91699. /**
  91700. * Represents a Motor-Enabled Joint
  91701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91702. */
  91703. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91704. /**
  91705. * Initializes the Motor-Enabled Joint
  91706. * @param type The type of the joint
  91707. * @param jointData The physica joint data for the joint
  91708. */
  91709. constructor(type: number, jointData: PhysicsJointData);
  91710. /**
  91711. * Set the motor values.
  91712. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91713. * @param force the force to apply
  91714. * @param maxForce max force for this motor.
  91715. */
  91716. setMotor(force?: number, maxForce?: number): void;
  91717. /**
  91718. * Set the motor's limits.
  91719. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91720. * @param upperLimit The upper limit of the motor
  91721. * @param lowerLimit The lower limit of the motor
  91722. */
  91723. setLimit(upperLimit: number, lowerLimit?: number): void;
  91724. }
  91725. /**
  91726. * This class represents a single physics Hinge-Joint
  91727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91728. */
  91729. export class HingeJoint extends MotorEnabledJoint {
  91730. /**
  91731. * Initializes the Hinge-Joint
  91732. * @param jointData The joint data for the Hinge-Joint
  91733. */
  91734. constructor(jointData: PhysicsJointData);
  91735. /**
  91736. * Set the motor values.
  91737. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91738. * @param {number} force the force to apply
  91739. * @param {number} maxForce max force for this motor.
  91740. */
  91741. setMotor(force?: number, maxForce?: number): void;
  91742. /**
  91743. * Set the motor's limits.
  91744. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91745. * @param upperLimit The upper limit of the motor
  91746. * @param lowerLimit The lower limit of the motor
  91747. */
  91748. setLimit(upperLimit: number, lowerLimit?: number): void;
  91749. }
  91750. /**
  91751. * This class represents a dual hinge physics joint (same as wheel joint)
  91752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91753. */
  91754. export class Hinge2Joint extends MotorEnabledJoint {
  91755. /**
  91756. * Initializes the Hinge2-Joint
  91757. * @param jointData The joint data for the Hinge2-Joint
  91758. */
  91759. constructor(jointData: PhysicsJointData);
  91760. /**
  91761. * Set the motor values.
  91762. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91763. * @param {number} targetSpeed the speed the motor is to reach
  91764. * @param {number} maxForce max force for this motor.
  91765. * @param {motorIndex} the motor's index, 0 or 1.
  91766. */
  91767. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91768. /**
  91769. * Set the motor limits.
  91770. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91771. * @param {number} upperLimit the upper limit
  91772. * @param {number} lowerLimit lower limit
  91773. * @param {motorIndex} the motor's index, 0 or 1.
  91774. */
  91775. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91776. }
  91777. /**
  91778. * Interface for a motor enabled joint
  91779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91780. */
  91781. export interface IMotorEnabledJoint {
  91782. /**
  91783. * Physics joint
  91784. */
  91785. physicsJoint: any;
  91786. /**
  91787. * Sets the motor of the motor-enabled joint
  91788. * @param force The force of the motor
  91789. * @param maxForce The maximum force of the motor
  91790. * @param motorIndex The index of the motor
  91791. */
  91792. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91793. /**
  91794. * Sets the limit of the motor
  91795. * @param upperLimit The upper limit of the motor
  91796. * @param lowerLimit The lower limit of the motor
  91797. * @param motorIndex The index of the motor
  91798. */
  91799. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91800. }
  91801. /**
  91802. * Joint data for a Distance-Joint
  91803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91804. */
  91805. export interface DistanceJointData extends PhysicsJointData {
  91806. /**
  91807. * Max distance the 2 joint objects can be apart
  91808. */
  91809. maxDistance: number;
  91810. }
  91811. /**
  91812. * Joint data from a spring joint
  91813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91814. */
  91815. export interface SpringJointData extends PhysicsJointData {
  91816. /**
  91817. * Length of the spring
  91818. */
  91819. length: number;
  91820. /**
  91821. * Stiffness of the spring
  91822. */
  91823. stiffness: number;
  91824. /**
  91825. * Damping of the spring
  91826. */
  91827. damping: number;
  91828. /** this callback will be called when applying the force to the impostors. */
  91829. forceApplicationCallback: () => void;
  91830. }
  91831. }
  91832. declare module BABYLON {
  91833. /**
  91834. * Holds the data for the raycast result
  91835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91836. */
  91837. export class PhysicsRaycastResult {
  91838. private _hasHit;
  91839. private _hitDistance;
  91840. private _hitNormalWorld;
  91841. private _hitPointWorld;
  91842. private _rayFromWorld;
  91843. private _rayToWorld;
  91844. /**
  91845. * Gets if there was a hit
  91846. */
  91847. readonly hasHit: boolean;
  91848. /**
  91849. * Gets the distance from the hit
  91850. */
  91851. readonly hitDistance: number;
  91852. /**
  91853. * Gets the hit normal/direction in the world
  91854. */
  91855. readonly hitNormalWorld: Vector3;
  91856. /**
  91857. * Gets the hit point in the world
  91858. */
  91859. readonly hitPointWorld: Vector3;
  91860. /**
  91861. * Gets the ray "start point" of the ray in the world
  91862. */
  91863. readonly rayFromWorld: Vector3;
  91864. /**
  91865. * Gets the ray "end point" of the ray in the world
  91866. */
  91867. readonly rayToWorld: Vector3;
  91868. /**
  91869. * Sets the hit data (normal & point in world space)
  91870. * @param hitNormalWorld defines the normal in world space
  91871. * @param hitPointWorld defines the point in world space
  91872. */
  91873. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91874. /**
  91875. * Sets the distance from the start point to the hit point
  91876. * @param distance
  91877. */
  91878. setHitDistance(distance: number): void;
  91879. /**
  91880. * Calculates the distance manually
  91881. */
  91882. calculateHitDistance(): void;
  91883. /**
  91884. * Resets all the values to default
  91885. * @param from The from point on world space
  91886. * @param to The to point on world space
  91887. */
  91888. reset(from?: Vector3, to?: Vector3): void;
  91889. }
  91890. /**
  91891. * Interface for the size containing width and height
  91892. */
  91893. interface IXYZ {
  91894. /**
  91895. * X
  91896. */
  91897. x: number;
  91898. /**
  91899. * Y
  91900. */
  91901. y: number;
  91902. /**
  91903. * Z
  91904. */
  91905. z: number;
  91906. }
  91907. }
  91908. declare module BABYLON {
  91909. /**
  91910. * Interface used to describe a physics joint
  91911. */
  91912. export interface PhysicsImpostorJoint {
  91913. /** Defines the main impostor to which the joint is linked */
  91914. mainImpostor: PhysicsImpostor;
  91915. /** Defines the impostor that is connected to the main impostor using this joint */
  91916. connectedImpostor: PhysicsImpostor;
  91917. /** Defines the joint itself */
  91918. joint: PhysicsJoint;
  91919. }
  91920. /** @hidden */
  91921. export interface IPhysicsEnginePlugin {
  91922. world: any;
  91923. name: string;
  91924. setGravity(gravity: Vector3): void;
  91925. setTimeStep(timeStep: number): void;
  91926. getTimeStep(): number;
  91927. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91928. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91929. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91930. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91931. removePhysicsBody(impostor: PhysicsImpostor): void;
  91932. generateJoint(joint: PhysicsImpostorJoint): void;
  91933. removeJoint(joint: PhysicsImpostorJoint): void;
  91934. isSupported(): boolean;
  91935. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91936. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91937. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91938. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91939. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91940. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91941. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91942. getBodyMass(impostor: PhysicsImpostor): number;
  91943. getBodyFriction(impostor: PhysicsImpostor): number;
  91944. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91945. getBodyRestitution(impostor: PhysicsImpostor): number;
  91946. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91947. getBodyPressure?(impostor: PhysicsImpostor): number;
  91948. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91949. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91950. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91951. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91952. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91953. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91954. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91955. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91956. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91957. sleepBody(impostor: PhysicsImpostor): void;
  91958. wakeUpBody(impostor: PhysicsImpostor): void;
  91959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91960. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91961. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91962. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91963. getRadius(impostor: PhysicsImpostor): number;
  91964. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91965. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91966. dispose(): void;
  91967. }
  91968. /**
  91969. * Interface used to define a physics engine
  91970. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91971. */
  91972. export interface IPhysicsEngine {
  91973. /**
  91974. * Gets the gravity vector used by the simulation
  91975. */
  91976. gravity: Vector3;
  91977. /**
  91978. * Sets the gravity vector used by the simulation
  91979. * @param gravity defines the gravity vector to use
  91980. */
  91981. setGravity(gravity: Vector3): void;
  91982. /**
  91983. * Set the time step of the physics engine.
  91984. * Default is 1/60.
  91985. * To slow it down, enter 1/600 for example.
  91986. * To speed it up, 1/30
  91987. * @param newTimeStep the new timestep to apply to this world.
  91988. */
  91989. setTimeStep(newTimeStep: number): void;
  91990. /**
  91991. * Get the time step of the physics engine.
  91992. * @returns the current time step
  91993. */
  91994. getTimeStep(): number;
  91995. /**
  91996. * Set the sub time step of the physics engine.
  91997. * Default is 0 meaning there is no sub steps
  91998. * To increase physics resolution precision, set a small value (like 1 ms)
  91999. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92000. */
  92001. setSubTimeStep(subTimeStep: number): void;
  92002. /**
  92003. * Get the sub time step of the physics engine.
  92004. * @returns the current sub time step
  92005. */
  92006. getSubTimeStep(): number;
  92007. /**
  92008. * Release all resources
  92009. */
  92010. dispose(): void;
  92011. /**
  92012. * Gets the name of the current physics plugin
  92013. * @returns the name of the plugin
  92014. */
  92015. getPhysicsPluginName(): string;
  92016. /**
  92017. * Adding a new impostor for the impostor tracking.
  92018. * This will be done by the impostor itself.
  92019. * @param impostor the impostor to add
  92020. */
  92021. addImpostor(impostor: PhysicsImpostor): void;
  92022. /**
  92023. * Remove an impostor from the engine.
  92024. * This impostor and its mesh will not longer be updated by the physics engine.
  92025. * @param impostor the impostor to remove
  92026. */
  92027. removeImpostor(impostor: PhysicsImpostor): void;
  92028. /**
  92029. * Add a joint to the physics engine
  92030. * @param mainImpostor defines the main impostor to which the joint is added.
  92031. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92032. * @param joint defines the joint that will connect both impostors.
  92033. */
  92034. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92035. /**
  92036. * Removes a joint from the simulation
  92037. * @param mainImpostor defines the impostor used with the joint
  92038. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92039. * @param joint defines the joint to remove
  92040. */
  92041. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92042. /**
  92043. * Gets the current plugin used to run the simulation
  92044. * @returns current plugin
  92045. */
  92046. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92047. /**
  92048. * Gets the list of physic impostors
  92049. * @returns an array of PhysicsImpostor
  92050. */
  92051. getImpostors(): Array<PhysicsImpostor>;
  92052. /**
  92053. * Gets the impostor for a physics enabled object
  92054. * @param object defines the object impersonated by the impostor
  92055. * @returns the PhysicsImpostor or null if not found
  92056. */
  92057. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92058. /**
  92059. * Gets the impostor for a physics body object
  92060. * @param body defines physics body used by the impostor
  92061. * @returns the PhysicsImpostor or null if not found
  92062. */
  92063. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92064. /**
  92065. * Does a raycast in the physics world
  92066. * @param from when should the ray start?
  92067. * @param to when should the ray end?
  92068. * @returns PhysicsRaycastResult
  92069. */
  92070. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92071. /**
  92072. * Called by the scene. No need to call it.
  92073. * @param delta defines the timespam between frames
  92074. */
  92075. _step(delta: number): void;
  92076. }
  92077. }
  92078. declare module BABYLON {
  92079. /**
  92080. * The interface for the physics imposter parameters
  92081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92082. */
  92083. export interface PhysicsImpostorParameters {
  92084. /**
  92085. * The mass of the physics imposter
  92086. */
  92087. mass: number;
  92088. /**
  92089. * The friction of the physics imposter
  92090. */
  92091. friction?: number;
  92092. /**
  92093. * The coefficient of restitution of the physics imposter
  92094. */
  92095. restitution?: number;
  92096. /**
  92097. * The native options of the physics imposter
  92098. */
  92099. nativeOptions?: any;
  92100. /**
  92101. * Specifies if the parent should be ignored
  92102. */
  92103. ignoreParent?: boolean;
  92104. /**
  92105. * Specifies if bi-directional transformations should be disabled
  92106. */
  92107. disableBidirectionalTransformation?: boolean;
  92108. /**
  92109. * The pressure inside the physics imposter, soft object only
  92110. */
  92111. pressure?: number;
  92112. /**
  92113. * The stiffness the physics imposter, soft object only
  92114. */
  92115. stiffness?: number;
  92116. /**
  92117. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92118. */
  92119. velocityIterations?: number;
  92120. /**
  92121. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92122. */
  92123. positionIterations?: number;
  92124. /**
  92125. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92126. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92127. * Add to fix multiple points
  92128. */
  92129. fixedPoints?: number;
  92130. /**
  92131. * The collision margin around a soft object
  92132. */
  92133. margin?: number;
  92134. /**
  92135. * The collision margin around a soft object
  92136. */
  92137. damping?: number;
  92138. /**
  92139. * The path for a rope based on an extrusion
  92140. */
  92141. path?: any;
  92142. /**
  92143. * The shape of an extrusion used for a rope based on an extrusion
  92144. */
  92145. shape?: any;
  92146. }
  92147. /**
  92148. * Interface for a physics-enabled object
  92149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92150. */
  92151. export interface IPhysicsEnabledObject {
  92152. /**
  92153. * The position of the physics-enabled object
  92154. */
  92155. position: Vector3;
  92156. /**
  92157. * The rotation of the physics-enabled object
  92158. */
  92159. rotationQuaternion: Nullable<Quaternion>;
  92160. /**
  92161. * The scale of the physics-enabled object
  92162. */
  92163. scaling: Vector3;
  92164. /**
  92165. * The rotation of the physics-enabled object
  92166. */
  92167. rotation?: Vector3;
  92168. /**
  92169. * The parent of the physics-enabled object
  92170. */
  92171. parent?: any;
  92172. /**
  92173. * The bounding info of the physics-enabled object
  92174. * @returns The bounding info of the physics-enabled object
  92175. */
  92176. getBoundingInfo(): BoundingInfo;
  92177. /**
  92178. * Computes the world matrix
  92179. * @param force Specifies if the world matrix should be computed by force
  92180. * @returns A world matrix
  92181. */
  92182. computeWorldMatrix(force: boolean): Matrix;
  92183. /**
  92184. * Gets the world matrix
  92185. * @returns A world matrix
  92186. */
  92187. getWorldMatrix?(): Matrix;
  92188. /**
  92189. * Gets the child meshes
  92190. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92191. * @returns An array of abstract meshes
  92192. */
  92193. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92194. /**
  92195. * Gets the vertex data
  92196. * @param kind The type of vertex data
  92197. * @returns A nullable array of numbers, or a float32 array
  92198. */
  92199. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92200. /**
  92201. * Gets the indices from the mesh
  92202. * @returns A nullable array of index arrays
  92203. */
  92204. getIndices?(): Nullable<IndicesArray>;
  92205. /**
  92206. * Gets the scene from the mesh
  92207. * @returns the indices array or null
  92208. */
  92209. getScene?(): Scene;
  92210. /**
  92211. * Gets the absolute position from the mesh
  92212. * @returns the absolute position
  92213. */
  92214. getAbsolutePosition(): Vector3;
  92215. /**
  92216. * Gets the absolute pivot point from the mesh
  92217. * @returns the absolute pivot point
  92218. */
  92219. getAbsolutePivotPoint(): Vector3;
  92220. /**
  92221. * Rotates the mesh
  92222. * @param axis The axis of rotation
  92223. * @param amount The amount of rotation
  92224. * @param space The space of the rotation
  92225. * @returns The rotation transform node
  92226. */
  92227. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92228. /**
  92229. * Translates the mesh
  92230. * @param axis The axis of translation
  92231. * @param distance The distance of translation
  92232. * @param space The space of the translation
  92233. * @returns The transform node
  92234. */
  92235. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92236. /**
  92237. * Sets the absolute position of the mesh
  92238. * @param absolutePosition The absolute position of the mesh
  92239. * @returns The transform node
  92240. */
  92241. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92242. /**
  92243. * Gets the class name of the mesh
  92244. * @returns The class name
  92245. */
  92246. getClassName(): string;
  92247. }
  92248. /**
  92249. * Represents a physics imposter
  92250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92251. */
  92252. export class PhysicsImpostor {
  92253. /**
  92254. * The physics-enabled object used as the physics imposter
  92255. */
  92256. object: IPhysicsEnabledObject;
  92257. /**
  92258. * The type of the physics imposter
  92259. */
  92260. type: number;
  92261. private _options;
  92262. private _scene?;
  92263. /**
  92264. * The default object size of the imposter
  92265. */
  92266. static DEFAULT_OBJECT_SIZE: Vector3;
  92267. /**
  92268. * The identity quaternion of the imposter
  92269. */
  92270. static IDENTITY_QUATERNION: Quaternion;
  92271. /** @hidden */
  92272. _pluginData: any;
  92273. private _physicsEngine;
  92274. private _physicsBody;
  92275. private _bodyUpdateRequired;
  92276. private _onBeforePhysicsStepCallbacks;
  92277. private _onAfterPhysicsStepCallbacks;
  92278. /** @hidden */
  92279. _onPhysicsCollideCallbacks: Array<{
  92280. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92281. otherImpostors: Array<PhysicsImpostor>;
  92282. }>;
  92283. private _deltaPosition;
  92284. private _deltaRotation;
  92285. private _deltaRotationConjugated;
  92286. /** @hidden */
  92287. _isFromLine: boolean;
  92288. private _parent;
  92289. private _isDisposed;
  92290. private static _tmpVecs;
  92291. private static _tmpQuat;
  92292. /**
  92293. * Specifies if the physics imposter is disposed
  92294. */
  92295. readonly isDisposed: boolean;
  92296. /**
  92297. * Gets the mass of the physics imposter
  92298. */
  92299. mass: number;
  92300. /**
  92301. * Gets the coefficient of friction
  92302. */
  92303. /**
  92304. * Sets the coefficient of friction
  92305. */
  92306. friction: number;
  92307. /**
  92308. * Gets the coefficient of restitution
  92309. */
  92310. /**
  92311. * Sets the coefficient of restitution
  92312. */
  92313. restitution: number;
  92314. /**
  92315. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92316. */
  92317. /**
  92318. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92319. */
  92320. pressure: number;
  92321. /**
  92322. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92323. */
  92324. /**
  92325. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92326. */
  92327. stiffness: number;
  92328. /**
  92329. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92330. */
  92331. /**
  92332. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92333. */
  92334. velocityIterations: number;
  92335. /**
  92336. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92337. */
  92338. /**
  92339. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92340. */
  92341. positionIterations: number;
  92342. /**
  92343. * The unique id of the physics imposter
  92344. * set by the physics engine when adding this impostor to the array
  92345. */
  92346. uniqueId: number;
  92347. /**
  92348. * @hidden
  92349. */
  92350. soft: boolean;
  92351. /**
  92352. * @hidden
  92353. */
  92354. segments: number;
  92355. private _joints;
  92356. /**
  92357. * Initializes the physics imposter
  92358. * @param object The physics-enabled object used as the physics imposter
  92359. * @param type The type of the physics imposter
  92360. * @param _options The options for the physics imposter
  92361. * @param _scene The Babylon scene
  92362. */
  92363. constructor(
  92364. /**
  92365. * The physics-enabled object used as the physics imposter
  92366. */
  92367. object: IPhysicsEnabledObject,
  92368. /**
  92369. * The type of the physics imposter
  92370. */
  92371. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92372. /**
  92373. * This function will completly initialize this impostor.
  92374. * It will create a new body - but only if this mesh has no parent.
  92375. * If it has, this impostor will not be used other than to define the impostor
  92376. * of the child mesh.
  92377. * @hidden
  92378. */
  92379. _init(): void;
  92380. private _getPhysicsParent;
  92381. /**
  92382. * Should a new body be generated.
  92383. * @returns boolean specifying if body initialization is required
  92384. */
  92385. isBodyInitRequired(): boolean;
  92386. /**
  92387. * Sets the updated scaling
  92388. * @param updated Specifies if the scaling is updated
  92389. */
  92390. setScalingUpdated(): void;
  92391. /**
  92392. * Force a regeneration of this or the parent's impostor's body.
  92393. * Use under cautious - This will remove all joints already implemented.
  92394. */
  92395. forceUpdate(): void;
  92396. /**
  92397. * Gets the body that holds this impostor. Either its own, or its parent.
  92398. */
  92399. /**
  92400. * Set the physics body. Used mainly by the physics engine/plugin
  92401. */
  92402. physicsBody: any;
  92403. /**
  92404. * Get the parent of the physics imposter
  92405. * @returns Physics imposter or null
  92406. */
  92407. /**
  92408. * Sets the parent of the physics imposter
  92409. */
  92410. parent: Nullable<PhysicsImpostor>;
  92411. /**
  92412. * Resets the update flags
  92413. */
  92414. resetUpdateFlags(): void;
  92415. /**
  92416. * Gets the object extend size
  92417. * @returns the object extend size
  92418. */
  92419. getObjectExtendSize(): Vector3;
  92420. /**
  92421. * Gets the object center
  92422. * @returns The object center
  92423. */
  92424. getObjectCenter(): Vector3;
  92425. /**
  92426. * Get a specific parametes from the options parameter
  92427. * @param paramName The object parameter name
  92428. * @returns The object parameter
  92429. */
  92430. getParam(paramName: string): any;
  92431. /**
  92432. * Sets a specific parameter in the options given to the physics plugin
  92433. * @param paramName The parameter name
  92434. * @param value The value of the parameter
  92435. */
  92436. setParam(paramName: string, value: number): void;
  92437. /**
  92438. * Specifically change the body's mass option. Won't recreate the physics body object
  92439. * @param mass The mass of the physics imposter
  92440. */
  92441. setMass(mass: number): void;
  92442. /**
  92443. * Gets the linear velocity
  92444. * @returns linear velocity or null
  92445. */
  92446. getLinearVelocity(): Nullable<Vector3>;
  92447. /**
  92448. * Sets the linear velocity
  92449. * @param velocity linear velocity or null
  92450. */
  92451. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92452. /**
  92453. * Gets the angular velocity
  92454. * @returns angular velocity or null
  92455. */
  92456. getAngularVelocity(): Nullable<Vector3>;
  92457. /**
  92458. * Sets the angular velocity
  92459. * @param velocity The velocity or null
  92460. */
  92461. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92462. /**
  92463. * Execute a function with the physics plugin native code
  92464. * Provide a function the will have two variables - the world object and the physics body object
  92465. * @param func The function to execute with the physics plugin native code
  92466. */
  92467. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92468. /**
  92469. * Register a function that will be executed before the physics world is stepping forward
  92470. * @param func The function to execute before the physics world is stepped forward
  92471. */
  92472. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92473. /**
  92474. * Unregister a function that will be executed before the physics world is stepping forward
  92475. * @param func The function to execute before the physics world is stepped forward
  92476. */
  92477. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92478. /**
  92479. * Register a function that will be executed after the physics step
  92480. * @param func The function to execute after physics step
  92481. */
  92482. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92483. /**
  92484. * Unregisters a function that will be executed after the physics step
  92485. * @param func The function to execute after physics step
  92486. */
  92487. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92488. /**
  92489. * register a function that will be executed when this impostor collides against a different body
  92490. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92491. * @param func Callback that is executed on collision
  92492. */
  92493. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92494. /**
  92495. * Unregisters the physics imposter on contact
  92496. * @param collideAgainst The physics object to collide against
  92497. * @param func Callback to execute on collision
  92498. */
  92499. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92500. private _tmpQuat;
  92501. private _tmpQuat2;
  92502. /**
  92503. * Get the parent rotation
  92504. * @returns The parent rotation
  92505. */
  92506. getParentsRotation(): Quaternion;
  92507. /**
  92508. * this function is executed by the physics engine.
  92509. */
  92510. beforeStep: () => void;
  92511. /**
  92512. * this function is executed by the physics engine
  92513. */
  92514. afterStep: () => void;
  92515. /**
  92516. * Legacy collision detection event support
  92517. */
  92518. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92519. /**
  92520. * event and body object due to cannon's event-based architecture.
  92521. */
  92522. onCollide: (e: {
  92523. body: any;
  92524. }) => void;
  92525. /**
  92526. * Apply a force
  92527. * @param force The force to apply
  92528. * @param contactPoint The contact point for the force
  92529. * @returns The physics imposter
  92530. */
  92531. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92532. /**
  92533. * Apply an impulse
  92534. * @param force The impulse force
  92535. * @param contactPoint The contact point for the impulse force
  92536. * @returns The physics imposter
  92537. */
  92538. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  92539. /**
  92540. * A help function to create a joint
  92541. * @param otherImpostor A physics imposter used to create a joint
  92542. * @param jointType The type of joint
  92543. * @param jointData The data for the joint
  92544. * @returns The physics imposter
  92545. */
  92546. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  92547. /**
  92548. * Add a joint to this impostor with a different impostor
  92549. * @param otherImpostor A physics imposter used to add a joint
  92550. * @param joint The joint to add
  92551. * @returns The physics imposter
  92552. */
  92553. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92554. /**
  92555. * Add an anchor to a cloth impostor
  92556. * @param otherImpostor rigid impostor to anchor to
  92557. * @param width ratio across width from 0 to 1
  92558. * @param height ratio up height from 0 to 1
  92559. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92560. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92561. * @returns impostor the soft imposter
  92562. */
  92563. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92564. /**
  92565. * Add a hook to a rope impostor
  92566. * @param otherImpostor rigid impostor to anchor to
  92567. * @param length ratio across rope from 0 to 1
  92568. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92569. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92570. * @returns impostor the rope imposter
  92571. */
  92572. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92573. /**
  92574. * Will keep this body still, in a sleep mode.
  92575. * @returns the physics imposter
  92576. */
  92577. sleep(): PhysicsImpostor;
  92578. /**
  92579. * Wake the body up.
  92580. * @returns The physics imposter
  92581. */
  92582. wakeUp(): PhysicsImpostor;
  92583. /**
  92584. * Clones the physics imposter
  92585. * @param newObject The physics imposter clones to this physics-enabled object
  92586. * @returns A nullable physics imposter
  92587. */
  92588. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92589. /**
  92590. * Disposes the physics imposter
  92591. */
  92592. dispose(): void;
  92593. /**
  92594. * Sets the delta position
  92595. * @param position The delta position amount
  92596. */
  92597. setDeltaPosition(position: Vector3): void;
  92598. /**
  92599. * Sets the delta rotation
  92600. * @param rotation The delta rotation amount
  92601. */
  92602. setDeltaRotation(rotation: Quaternion): void;
  92603. /**
  92604. * Gets the box size of the physics imposter and stores the result in the input parameter
  92605. * @param result Stores the box size
  92606. * @returns The physics imposter
  92607. */
  92608. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92609. /**
  92610. * Gets the radius of the physics imposter
  92611. * @returns Radius of the physics imposter
  92612. */
  92613. getRadius(): number;
  92614. /**
  92615. * Sync a bone with this impostor
  92616. * @param bone The bone to sync to the impostor.
  92617. * @param boneMesh The mesh that the bone is influencing.
  92618. * @param jointPivot The pivot of the joint / bone in local space.
  92619. * @param distToJoint Optional distance from the impostor to the joint.
  92620. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92621. */
  92622. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92623. /**
  92624. * Sync impostor to a bone
  92625. * @param bone The bone that the impostor will be synced to.
  92626. * @param boneMesh The mesh that the bone is influencing.
  92627. * @param jointPivot The pivot of the joint / bone in local space.
  92628. * @param distToJoint Optional distance from the impostor to the joint.
  92629. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92630. * @param boneAxis Optional vector3 axis the bone is aligned with
  92631. */
  92632. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92633. /**
  92634. * No-Imposter type
  92635. */
  92636. static NoImpostor: number;
  92637. /**
  92638. * Sphere-Imposter type
  92639. */
  92640. static SphereImpostor: number;
  92641. /**
  92642. * Box-Imposter type
  92643. */
  92644. static BoxImpostor: number;
  92645. /**
  92646. * Plane-Imposter type
  92647. */
  92648. static PlaneImpostor: number;
  92649. /**
  92650. * Mesh-imposter type
  92651. */
  92652. static MeshImpostor: number;
  92653. /**
  92654. * Capsule-Impostor type (Ammo.js plugin only)
  92655. */
  92656. static CapsuleImpostor: number;
  92657. /**
  92658. * Cylinder-Imposter type
  92659. */
  92660. static CylinderImpostor: number;
  92661. /**
  92662. * Particle-Imposter type
  92663. */
  92664. static ParticleImpostor: number;
  92665. /**
  92666. * Heightmap-Imposter type
  92667. */
  92668. static HeightmapImpostor: number;
  92669. /**
  92670. * ConvexHull-Impostor type (Ammo.js plugin only)
  92671. */
  92672. static ConvexHullImpostor: number;
  92673. /**
  92674. * Custom-Imposter type (Ammo.js plugin only)
  92675. */
  92676. static CustomImpostor: number;
  92677. /**
  92678. * Rope-Imposter type
  92679. */
  92680. static RopeImpostor: number;
  92681. /**
  92682. * Cloth-Imposter type
  92683. */
  92684. static ClothImpostor: number;
  92685. /**
  92686. * Softbody-Imposter type
  92687. */
  92688. static SoftbodyImpostor: number;
  92689. }
  92690. }
  92691. declare module BABYLON {
  92692. /**
  92693. * @hidden
  92694. **/
  92695. export class _CreationDataStorage {
  92696. closePath?: boolean;
  92697. closeArray?: boolean;
  92698. idx: number[];
  92699. dashSize: number;
  92700. gapSize: number;
  92701. path3D: Path3D;
  92702. pathArray: Vector3[][];
  92703. arc: number;
  92704. radius: number;
  92705. cap: number;
  92706. tessellation: number;
  92707. }
  92708. /**
  92709. * @hidden
  92710. **/
  92711. class _InstanceDataStorage {
  92712. visibleInstances: any;
  92713. batchCache: _InstancesBatch;
  92714. instancesBufferSize: number;
  92715. instancesBuffer: Nullable<Buffer>;
  92716. instancesData: Float32Array;
  92717. overridenInstanceCount: number;
  92718. isFrozen: boolean;
  92719. previousBatch: Nullable<_InstancesBatch>;
  92720. hardwareInstancedRendering: boolean;
  92721. sideOrientation: number;
  92722. manualUpdate: boolean;
  92723. }
  92724. /**
  92725. * @hidden
  92726. **/
  92727. export class _InstancesBatch {
  92728. mustReturn: boolean;
  92729. visibleInstances: Nullable<InstancedMesh[]>[];
  92730. renderSelf: boolean[];
  92731. hardwareInstancedRendering: boolean[];
  92732. }
  92733. /**
  92734. * Class used to represent renderable models
  92735. */
  92736. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92737. /**
  92738. * Mesh side orientation : usually the external or front surface
  92739. */
  92740. static readonly FRONTSIDE: number;
  92741. /**
  92742. * Mesh side orientation : usually the internal or back surface
  92743. */
  92744. static readonly BACKSIDE: number;
  92745. /**
  92746. * Mesh side orientation : both internal and external or front and back surfaces
  92747. */
  92748. static readonly DOUBLESIDE: number;
  92749. /**
  92750. * Mesh side orientation : by default, `FRONTSIDE`
  92751. */
  92752. static readonly DEFAULTSIDE: number;
  92753. /**
  92754. * Mesh cap setting : no cap
  92755. */
  92756. static readonly NO_CAP: number;
  92757. /**
  92758. * Mesh cap setting : one cap at the beginning of the mesh
  92759. */
  92760. static readonly CAP_START: number;
  92761. /**
  92762. * Mesh cap setting : one cap at the end of the mesh
  92763. */
  92764. static readonly CAP_END: number;
  92765. /**
  92766. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92767. */
  92768. static readonly CAP_ALL: number;
  92769. /**
  92770. * Mesh pattern setting : no flip or rotate
  92771. */
  92772. static readonly NO_FLIP: number;
  92773. /**
  92774. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92775. */
  92776. static readonly FLIP_TILE: number;
  92777. /**
  92778. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92779. */
  92780. static readonly ROTATE_TILE: number;
  92781. /**
  92782. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92783. */
  92784. static readonly FLIP_ROW: number;
  92785. /**
  92786. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92787. */
  92788. static readonly ROTATE_ROW: number;
  92789. /**
  92790. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92791. */
  92792. static readonly FLIP_N_ROTATE_TILE: number;
  92793. /**
  92794. * Mesh pattern setting : rotate pattern and rotate
  92795. */
  92796. static readonly FLIP_N_ROTATE_ROW: number;
  92797. /**
  92798. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92799. */
  92800. static readonly CENTER: number;
  92801. /**
  92802. * Mesh tile positioning : part tiles on left
  92803. */
  92804. static readonly LEFT: number;
  92805. /**
  92806. * Mesh tile positioning : part tiles on right
  92807. */
  92808. static readonly RIGHT: number;
  92809. /**
  92810. * Mesh tile positioning : part tiles on top
  92811. */
  92812. static readonly TOP: number;
  92813. /**
  92814. * Mesh tile positioning : part tiles on bottom
  92815. */
  92816. static readonly BOTTOM: number;
  92817. /**
  92818. * Gets the default side orientation.
  92819. * @param orientation the orientation to value to attempt to get
  92820. * @returns the default orientation
  92821. * @hidden
  92822. */
  92823. static _GetDefaultSideOrientation(orientation?: number): number;
  92824. private _internalMeshDataInfo;
  92825. /**
  92826. * An event triggered before rendering the mesh
  92827. */
  92828. readonly onBeforeRenderObservable: Observable<Mesh>;
  92829. /**
  92830. * An event triggered before binding the mesh
  92831. */
  92832. readonly onBeforeBindObservable: Observable<Mesh>;
  92833. /**
  92834. * An event triggered after rendering the mesh
  92835. */
  92836. readonly onAfterRenderObservable: Observable<Mesh>;
  92837. /**
  92838. * An event triggered before drawing the mesh
  92839. */
  92840. readonly onBeforeDrawObservable: Observable<Mesh>;
  92841. private _onBeforeDrawObserver;
  92842. /**
  92843. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92844. */
  92845. onBeforeDraw: () => void;
  92846. readonly hasInstances: boolean;
  92847. /**
  92848. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92849. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92850. */
  92851. delayLoadState: number;
  92852. /**
  92853. * Gets the list of instances created from this mesh
  92854. * it is not supposed to be modified manually.
  92855. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92856. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92857. */
  92858. instances: InstancedMesh[];
  92859. /**
  92860. * Gets the file containing delay loading data for this mesh
  92861. */
  92862. delayLoadingFile: string;
  92863. /** @hidden */
  92864. _binaryInfo: any;
  92865. /**
  92866. * User defined function used to change how LOD level selection is done
  92867. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92868. */
  92869. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92870. /**
  92871. * Gets or sets the morph target manager
  92872. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92873. */
  92874. morphTargetManager: Nullable<MorphTargetManager>;
  92875. /** @hidden */
  92876. _creationDataStorage: Nullable<_CreationDataStorage>;
  92877. /** @hidden */
  92878. _geometry: Nullable<Geometry>;
  92879. /** @hidden */
  92880. _delayInfo: Array<string>;
  92881. /** @hidden */
  92882. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92883. /** @hidden */
  92884. _instanceDataStorage: _InstanceDataStorage;
  92885. private _effectiveMaterial;
  92886. /** @hidden */
  92887. _shouldGenerateFlatShading: boolean;
  92888. /** @hidden */
  92889. _originalBuilderSideOrientation: number;
  92890. /**
  92891. * Use this property to change the original side orientation defined at construction time
  92892. */
  92893. overrideMaterialSideOrientation: Nullable<number>;
  92894. /**
  92895. * Gets the source mesh (the one used to clone this one from)
  92896. */
  92897. readonly source: Nullable<Mesh>;
  92898. /**
  92899. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92900. */
  92901. isUnIndexed: boolean;
  92902. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92903. readonly worldMatrixInstancedBuffer: Float32Array;
  92904. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92905. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92906. /**
  92907. * @constructor
  92908. * @param name The value used by scene.getMeshByName() to do a lookup.
  92909. * @param scene The scene to add this mesh to.
  92910. * @param parent The parent of this mesh, if it has one
  92911. * @param source An optional Mesh from which geometry is shared, cloned.
  92912. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92913. * When false, achieved by calling a clone(), also passing False.
  92914. * This will make creation of children, recursive.
  92915. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92916. */
  92917. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92918. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92919. doNotInstantiate: boolean;
  92920. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92921. /**
  92922. * Gets the class name
  92923. * @returns the string "Mesh".
  92924. */
  92925. getClassName(): string;
  92926. /** @hidden */
  92927. readonly _isMesh: boolean;
  92928. /**
  92929. * Returns a description of this mesh
  92930. * @param fullDetails define if full details about this mesh must be used
  92931. * @returns a descriptive string representing this mesh
  92932. */
  92933. toString(fullDetails?: boolean): string;
  92934. /** @hidden */
  92935. _unBindEffect(): void;
  92936. /**
  92937. * Gets a boolean indicating if this mesh has LOD
  92938. */
  92939. readonly hasLODLevels: boolean;
  92940. /**
  92941. * Gets the list of MeshLODLevel associated with the current mesh
  92942. * @returns an array of MeshLODLevel
  92943. */
  92944. getLODLevels(): MeshLODLevel[];
  92945. private _sortLODLevels;
  92946. /**
  92947. * Add a mesh as LOD level triggered at the given distance.
  92948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92949. * @param distance The distance from the center of the object to show this level
  92950. * @param mesh The mesh to be added as LOD level (can be null)
  92951. * @return This mesh (for chaining)
  92952. */
  92953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92954. /**
  92955. * Returns the LOD level mesh at the passed distance or null if not found.
  92956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92957. * @param distance The distance from the center of the object to show this level
  92958. * @returns a Mesh or `null`
  92959. */
  92960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92961. /**
  92962. * Remove a mesh from the LOD array
  92963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92964. * @param mesh defines the mesh to be removed
  92965. * @return This mesh (for chaining)
  92966. */
  92967. removeLODLevel(mesh: Mesh): Mesh;
  92968. /**
  92969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92971. * @param camera defines the camera to use to compute distance
  92972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92973. * @return This mesh (for chaining)
  92974. */
  92975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92976. /**
  92977. * Gets the mesh internal Geometry object
  92978. */
  92979. readonly geometry: Nullable<Geometry>;
  92980. /**
  92981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92982. * @returns the total number of vertices
  92983. */
  92984. getTotalVertices(): number;
  92985. /**
  92986. * Returns the content of an associated vertex buffer
  92987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92988. * - VertexBuffer.PositionKind
  92989. * - VertexBuffer.UVKind
  92990. * - VertexBuffer.UV2Kind
  92991. * - VertexBuffer.UV3Kind
  92992. * - VertexBuffer.UV4Kind
  92993. * - VertexBuffer.UV5Kind
  92994. * - VertexBuffer.UV6Kind
  92995. * - VertexBuffer.ColorKind
  92996. * - VertexBuffer.MatricesIndicesKind
  92997. * - VertexBuffer.MatricesIndicesExtraKind
  92998. * - VertexBuffer.MatricesWeightsKind
  92999. * - VertexBuffer.MatricesWeightsExtraKind
  93000. * @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
  93001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93003. */
  93004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93005. /**
  93006. * Returns the mesh VertexBuffer object from the requested `kind`
  93007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93008. * - VertexBuffer.PositionKind
  93009. * - VertexBuffer.NormalKind
  93010. * - VertexBuffer.UVKind
  93011. * - VertexBuffer.UV2Kind
  93012. * - VertexBuffer.UV3Kind
  93013. * - VertexBuffer.UV4Kind
  93014. * - VertexBuffer.UV5Kind
  93015. * - VertexBuffer.UV6Kind
  93016. * - VertexBuffer.ColorKind
  93017. * - VertexBuffer.MatricesIndicesKind
  93018. * - VertexBuffer.MatricesIndicesExtraKind
  93019. * - VertexBuffer.MatricesWeightsKind
  93020. * - VertexBuffer.MatricesWeightsExtraKind
  93021. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93022. */
  93023. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93024. /**
  93025. * Tests if a specific vertex buffer is associated with this mesh
  93026. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93027. * - VertexBuffer.PositionKind
  93028. * - VertexBuffer.NormalKind
  93029. * - VertexBuffer.UVKind
  93030. * - VertexBuffer.UV2Kind
  93031. * - VertexBuffer.UV3Kind
  93032. * - VertexBuffer.UV4Kind
  93033. * - VertexBuffer.UV5Kind
  93034. * - VertexBuffer.UV6Kind
  93035. * - VertexBuffer.ColorKind
  93036. * - VertexBuffer.MatricesIndicesKind
  93037. * - VertexBuffer.MatricesIndicesExtraKind
  93038. * - VertexBuffer.MatricesWeightsKind
  93039. * - VertexBuffer.MatricesWeightsExtraKind
  93040. * @returns a boolean
  93041. */
  93042. isVerticesDataPresent(kind: string): boolean;
  93043. /**
  93044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93045. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93046. * - VertexBuffer.PositionKind
  93047. * - VertexBuffer.UVKind
  93048. * - VertexBuffer.UV2Kind
  93049. * - VertexBuffer.UV3Kind
  93050. * - VertexBuffer.UV4Kind
  93051. * - VertexBuffer.UV5Kind
  93052. * - VertexBuffer.UV6Kind
  93053. * - VertexBuffer.ColorKind
  93054. * - VertexBuffer.MatricesIndicesKind
  93055. * - VertexBuffer.MatricesIndicesExtraKind
  93056. * - VertexBuffer.MatricesWeightsKind
  93057. * - VertexBuffer.MatricesWeightsExtraKind
  93058. * @returns a boolean
  93059. */
  93060. isVertexBufferUpdatable(kind: string): boolean;
  93061. /**
  93062. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93064. * - VertexBuffer.PositionKind
  93065. * - VertexBuffer.NormalKind
  93066. * - VertexBuffer.UVKind
  93067. * - VertexBuffer.UV2Kind
  93068. * - VertexBuffer.UV3Kind
  93069. * - VertexBuffer.UV4Kind
  93070. * - VertexBuffer.UV5Kind
  93071. * - VertexBuffer.UV6Kind
  93072. * - VertexBuffer.ColorKind
  93073. * - VertexBuffer.MatricesIndicesKind
  93074. * - VertexBuffer.MatricesIndicesExtraKind
  93075. * - VertexBuffer.MatricesWeightsKind
  93076. * - VertexBuffer.MatricesWeightsExtraKind
  93077. * @returns an array of strings
  93078. */
  93079. getVerticesDataKinds(): string[];
  93080. /**
  93081. * Returns a positive integer : the total number of indices in this mesh geometry.
  93082. * @returns the numner of indices or zero if the mesh has no geometry.
  93083. */
  93084. getTotalIndices(): number;
  93085. /**
  93086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93087. * @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.
  93088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93089. * @returns the indices array or an empty array if the mesh has no geometry
  93090. */
  93091. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93092. readonly isBlocked: boolean;
  93093. /**
  93094. * Determine if the current mesh is ready to be rendered
  93095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93096. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93097. * @returns true if all associated assets are ready (material, textures, shaders)
  93098. */
  93099. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93100. /**
  93101. * 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.
  93102. */
  93103. readonly areNormalsFrozen: boolean;
  93104. /**
  93105. * 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.
  93106. * @returns the current mesh
  93107. */
  93108. freezeNormals(): Mesh;
  93109. /**
  93110. * 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
  93111. * @returns the current mesh
  93112. */
  93113. unfreezeNormals(): Mesh;
  93114. /**
  93115. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93116. */
  93117. overridenInstanceCount: number;
  93118. /** @hidden */
  93119. _preActivate(): Mesh;
  93120. /** @hidden */
  93121. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93122. /** @hidden */
  93123. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93124. /**
  93125. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93126. * This means the mesh underlying bounding box and sphere are recomputed.
  93127. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93128. * @returns the current mesh
  93129. */
  93130. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93131. /** @hidden */
  93132. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93133. /**
  93134. * This function will subdivide the mesh into multiple submeshes
  93135. * @param count defines the expected number of submeshes
  93136. */
  93137. subdivide(count: number): void;
  93138. /**
  93139. * Copy a FloatArray into a specific associated vertex buffer
  93140. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93141. * - VertexBuffer.PositionKind
  93142. * - VertexBuffer.UVKind
  93143. * - VertexBuffer.UV2Kind
  93144. * - VertexBuffer.UV3Kind
  93145. * - VertexBuffer.UV4Kind
  93146. * - VertexBuffer.UV5Kind
  93147. * - VertexBuffer.UV6Kind
  93148. * - VertexBuffer.ColorKind
  93149. * - VertexBuffer.MatricesIndicesKind
  93150. * - VertexBuffer.MatricesIndicesExtraKind
  93151. * - VertexBuffer.MatricesWeightsKind
  93152. * - VertexBuffer.MatricesWeightsExtraKind
  93153. * @param data defines the data source
  93154. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93155. * @param stride defines the data stride size (can be null)
  93156. * @returns the current mesh
  93157. */
  93158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93159. /**
  93160. * Delete a vertex buffer associated with this mesh
  93161. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93162. * - VertexBuffer.PositionKind
  93163. * - VertexBuffer.UVKind
  93164. * - VertexBuffer.UV2Kind
  93165. * - VertexBuffer.UV3Kind
  93166. * - VertexBuffer.UV4Kind
  93167. * - VertexBuffer.UV5Kind
  93168. * - VertexBuffer.UV6Kind
  93169. * - VertexBuffer.ColorKind
  93170. * - VertexBuffer.MatricesIndicesKind
  93171. * - VertexBuffer.MatricesIndicesExtraKind
  93172. * - VertexBuffer.MatricesWeightsKind
  93173. * - VertexBuffer.MatricesWeightsExtraKind
  93174. */
  93175. removeVerticesData(kind: string): void;
  93176. /**
  93177. * Flags an associated vertex buffer as updatable
  93178. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93179. * - VertexBuffer.PositionKind
  93180. * - VertexBuffer.UVKind
  93181. * - VertexBuffer.UV2Kind
  93182. * - VertexBuffer.UV3Kind
  93183. * - VertexBuffer.UV4Kind
  93184. * - VertexBuffer.UV5Kind
  93185. * - VertexBuffer.UV6Kind
  93186. * - VertexBuffer.ColorKind
  93187. * - VertexBuffer.MatricesIndicesKind
  93188. * - VertexBuffer.MatricesIndicesExtraKind
  93189. * - VertexBuffer.MatricesWeightsKind
  93190. * - VertexBuffer.MatricesWeightsExtraKind
  93191. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93192. */
  93193. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93194. /**
  93195. * Sets the mesh global Vertex Buffer
  93196. * @param buffer defines the buffer to use
  93197. * @returns the current mesh
  93198. */
  93199. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93200. /**
  93201. * Update a specific associated vertex buffer
  93202. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93203. * - VertexBuffer.PositionKind
  93204. * - VertexBuffer.UVKind
  93205. * - VertexBuffer.UV2Kind
  93206. * - VertexBuffer.UV3Kind
  93207. * - VertexBuffer.UV4Kind
  93208. * - VertexBuffer.UV5Kind
  93209. * - VertexBuffer.UV6Kind
  93210. * - VertexBuffer.ColorKind
  93211. * - VertexBuffer.MatricesIndicesKind
  93212. * - VertexBuffer.MatricesIndicesExtraKind
  93213. * - VertexBuffer.MatricesWeightsKind
  93214. * - VertexBuffer.MatricesWeightsExtraKind
  93215. * @param data defines the data source
  93216. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93217. * @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)
  93218. * @returns the current mesh
  93219. */
  93220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93221. /**
  93222. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93223. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93224. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93225. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93226. * @returns the current mesh
  93227. */
  93228. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93229. /**
  93230. * Creates a un-shared specific occurence of the geometry for the mesh.
  93231. * @returns the current mesh
  93232. */
  93233. makeGeometryUnique(): Mesh;
  93234. /**
  93235. * Set the index buffer of this mesh
  93236. * @param indices defines the source data
  93237. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93238. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93239. * @returns the current mesh
  93240. */
  93241. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93242. /**
  93243. * Update the current index buffer
  93244. * @param indices defines the source data
  93245. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93246. * @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)
  93247. * @returns the current mesh
  93248. */
  93249. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93250. /**
  93251. * Invert the geometry to move from a right handed system to a left handed one.
  93252. * @returns the current mesh
  93253. */
  93254. toLeftHanded(): Mesh;
  93255. /** @hidden */
  93256. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93257. /** @hidden */
  93258. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93259. /**
  93260. * Registers for this mesh a javascript function called just before the rendering process
  93261. * @param func defines the function to call before rendering this mesh
  93262. * @returns the current mesh
  93263. */
  93264. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93265. /**
  93266. * Disposes a previously registered javascript function called before the rendering
  93267. * @param func defines the function to remove
  93268. * @returns the current mesh
  93269. */
  93270. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93271. /**
  93272. * Registers for this mesh a javascript function called just after the rendering is complete
  93273. * @param func defines the function to call after rendering this mesh
  93274. * @returns the current mesh
  93275. */
  93276. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93277. /**
  93278. * Disposes a previously registered javascript function called after the rendering.
  93279. * @param func defines the function to remove
  93280. * @returns the current mesh
  93281. */
  93282. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93283. /** @hidden */
  93284. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93285. /** @hidden */
  93286. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93287. /** @hidden */
  93288. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93289. /** @hidden */
  93290. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93291. /** @hidden */
  93292. _rebuild(): void;
  93293. /** @hidden */
  93294. _freeze(): void;
  93295. /** @hidden */
  93296. _unFreeze(): void;
  93297. /**
  93298. * 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
  93299. * @param subMesh defines the subMesh to render
  93300. * @param enableAlphaMode defines if alpha mode can be changed
  93301. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93302. * @returns the current mesh
  93303. */
  93304. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93305. private _onBeforeDraw;
  93306. /**
  93307. * Renormalize the mesh and patch it up if there are no weights
  93308. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93309. * However in the case of zero weights then we set just a single influence to 1.
  93310. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93311. */
  93312. cleanMatrixWeights(): void;
  93313. private normalizeSkinFourWeights;
  93314. private normalizeSkinWeightsAndExtra;
  93315. /**
  93316. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93317. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93318. * the user know there was an issue with importing the mesh
  93319. * @returns a validation object with skinned, valid and report string
  93320. */
  93321. validateSkinning(): {
  93322. skinned: boolean;
  93323. valid: boolean;
  93324. report: string;
  93325. };
  93326. /** @hidden */
  93327. _checkDelayState(): Mesh;
  93328. private _queueLoad;
  93329. /**
  93330. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93331. * A mesh is in the frustum if its bounding box intersects the frustum
  93332. * @param frustumPlanes defines the frustum to test
  93333. * @returns true if the mesh is in the frustum planes
  93334. */
  93335. isInFrustum(frustumPlanes: Plane[]): boolean;
  93336. /**
  93337. * Sets the mesh material by the material or multiMaterial `id` property
  93338. * @param id is a string identifying the material or the multiMaterial
  93339. * @returns the current mesh
  93340. */
  93341. setMaterialByID(id: string): Mesh;
  93342. /**
  93343. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93344. * @returns an array of IAnimatable
  93345. */
  93346. getAnimatables(): IAnimatable[];
  93347. /**
  93348. * Modifies the mesh geometry according to the passed transformation matrix.
  93349. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93350. * The mesh normals are modified using the same transformation.
  93351. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93352. * @param transform defines the transform matrix to use
  93353. * @see http://doc.babylonjs.com/resources/baking_transformations
  93354. * @returns the current mesh
  93355. */
  93356. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93357. /**
  93358. * Modifies the mesh geometry according to its own current World Matrix.
  93359. * The mesh World Matrix is then reset.
  93360. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93361. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93362. * @see http://doc.babylonjs.com/resources/baking_transformations
  93363. * @returns the current mesh
  93364. */
  93365. bakeCurrentTransformIntoVertices(): Mesh;
  93366. /** @hidden */
  93367. readonly _positions: Nullable<Vector3[]>;
  93368. /** @hidden */
  93369. _resetPointsArrayCache(): Mesh;
  93370. /** @hidden */
  93371. _generatePointsArray(): boolean;
  93372. /**
  93373. * Returns a new Mesh object generated from the current mesh properties.
  93374. * This method must not get confused with createInstance()
  93375. * @param name is a string, the name given to the new mesh
  93376. * @param newParent can be any Node object (default `null`)
  93377. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93378. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93379. * @returns a new mesh
  93380. */
  93381. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93382. /**
  93383. * Releases resources associated with this mesh.
  93384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93386. */
  93387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93388. /** @hidden */
  93389. _disposeInstanceSpecificData(): void;
  93390. /**
  93391. * Modifies the mesh geometry according to a displacement map.
  93392. * 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.
  93393. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93394. * @param url is a string, the URL from the image file is to be downloaded.
  93395. * @param minHeight is the lower limit of the displacement.
  93396. * @param maxHeight is the upper limit of the displacement.
  93397. * @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.
  93398. * @param uvOffset is an optional vector2 used to offset UV.
  93399. * @param uvScale is an optional vector2 used to scale UV.
  93400. * @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.
  93401. * @returns the Mesh.
  93402. */
  93403. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93404. /**
  93405. * Modifies the mesh geometry according to a displacementMap buffer.
  93406. * 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.
  93407. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93408. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93409. * @param heightMapWidth is the width of the buffer image.
  93410. * @param heightMapHeight is the height of the buffer image.
  93411. * @param minHeight is the lower limit of the displacement.
  93412. * @param maxHeight is the upper limit of the displacement.
  93413. * @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.
  93414. * @param uvOffset is an optional vector2 used to offset UV.
  93415. * @param uvScale is an optional vector2 used to scale UV.
  93416. * @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.
  93417. * @returns the Mesh.
  93418. */
  93419. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93420. /**
  93421. * Modify the mesh to get a flat shading rendering.
  93422. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93423. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93424. * @returns current mesh
  93425. */
  93426. convertToFlatShadedMesh(): Mesh;
  93427. /**
  93428. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93429. * In other words, more vertices, no more indices and a single bigger VBO.
  93430. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93431. * @returns current mesh
  93432. */
  93433. convertToUnIndexedMesh(): Mesh;
  93434. /**
  93435. * Inverses facet orientations.
  93436. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93437. * @param flipNormals will also inverts the normals
  93438. * @returns current mesh
  93439. */
  93440. flipFaces(flipNormals?: boolean): Mesh;
  93441. /**
  93442. * Increase the number of facets and hence vertices in a mesh
  93443. * Vertex normals are interpolated from existing vertex normals
  93444. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93445. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93446. */
  93447. increaseVertices(numberPerEdge: number): void;
  93448. /**
  93449. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93450. * This will undo any application of covertToFlatShadedMesh
  93451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93452. */
  93453. forceSharedVertices(): void;
  93454. /** @hidden */
  93455. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93456. /** @hidden */
  93457. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93458. /**
  93459. * Creates a new InstancedMesh object from the mesh model.
  93460. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93461. * @param name defines the name of the new instance
  93462. * @returns a new InstancedMesh
  93463. */
  93464. createInstance(name: string): InstancedMesh;
  93465. /**
  93466. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93467. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93468. * @returns the current mesh
  93469. */
  93470. synchronizeInstances(): Mesh;
  93471. /**
  93472. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93473. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93474. * This should be used together with the simplification to avoid disappearing triangles.
  93475. * @param successCallback an optional success callback to be called after the optimization finished.
  93476. * @returns the current mesh
  93477. */
  93478. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93479. /**
  93480. * Serialize current mesh
  93481. * @param serializationObject defines the object which will receive the serialization data
  93482. */
  93483. serialize(serializationObject: any): void;
  93484. /** @hidden */
  93485. _syncGeometryWithMorphTargetManager(): void;
  93486. /** @hidden */
  93487. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93488. /**
  93489. * Returns a new Mesh object parsed from the source provided.
  93490. * @param parsedMesh is the source
  93491. * @param scene defines the hosting scene
  93492. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93493. * @returns a new Mesh
  93494. */
  93495. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93496. /**
  93497. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93498. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93499. * @param name defines the name of the mesh to create
  93500. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93501. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93502. * @param closePath creates a seam between the first and the last points of each path of the path array
  93503. * @param offset is taken in account only if the `pathArray` is containing a single path
  93504. * @param scene defines the hosting scene
  93505. * @param updatable defines if the mesh must be flagged as updatable
  93506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93507. * @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)
  93508. * @returns a new Mesh
  93509. */
  93510. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93511. /**
  93512. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93513. * @param name defines the name of the mesh to create
  93514. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93515. * @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
  93516. * @param scene defines the hosting scene
  93517. * @param updatable defines if the mesh must be flagged as updatable
  93518. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93519. * @returns a new Mesh
  93520. */
  93521. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93522. /**
  93523. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  93524. * @param name defines the name of the mesh to create
  93525. * @param size sets the size (float) of each box side (default 1)
  93526. * @param scene defines the hosting scene
  93527. * @param updatable defines if the mesh must be flagged as updatable
  93528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93529. * @returns a new Mesh
  93530. */
  93531. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93532. /**
  93533. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  93534. * @param name defines the name of the mesh to create
  93535. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93536. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93537. * @param scene defines the hosting scene
  93538. * @param updatable defines if the mesh must be flagged as updatable
  93539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93540. * @returns a new Mesh
  93541. */
  93542. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93543. /**
  93544. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  93545. * @param name defines the name of the mesh to create
  93546. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  93547. * @param diameter sets the diameter size (float) of the sphere (default 1)
  93548. * @param scene defines the hosting scene
  93549. * @returns a new Mesh
  93550. */
  93551. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  93552. /**
  93553. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93554. * @param name defines the name of the mesh to create
  93555. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93556. * @param diameterTop set the top cap diameter (floats, default 1)
  93557. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93558. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93559. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93560. * @param scene defines the hosting scene
  93561. * @param updatable defines if the mesh must be flagged as updatable
  93562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93563. * @returns a new Mesh
  93564. */
  93565. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93566. /**
  93567. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93568. * @param name defines the name of the mesh to create
  93569. * @param diameter sets the diameter size (float) of the torus (default 1)
  93570. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93571. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93572. * @param scene defines the hosting scene
  93573. * @param updatable defines if the mesh must be flagged as updatable
  93574. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93575. * @returns a new Mesh
  93576. */
  93577. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93578. /**
  93579. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93580. * @param name defines the name of the mesh to create
  93581. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93582. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93583. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93584. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93585. * @param p the number of windings on X axis (positive integers, default 2)
  93586. * @param q the number of windings on Y axis (positive integers, default 3)
  93587. * @param scene defines the hosting scene
  93588. * @param updatable defines if the mesh must be flagged as updatable
  93589. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93590. * @returns a new Mesh
  93591. */
  93592. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93593. /**
  93594. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93595. * @param name defines the name of the mesh to create
  93596. * @param points is an array successive Vector3
  93597. * @param scene defines the hosting scene
  93598. * @param updatable defines if the mesh must be flagged as updatable
  93599. * @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).
  93600. * @returns a new Mesh
  93601. */
  93602. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93603. /**
  93604. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93605. * @param name defines the name of the mesh to create
  93606. * @param points is an array successive Vector3
  93607. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93608. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93609. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93610. * @param scene defines the hosting scene
  93611. * @param updatable defines if the mesh must be flagged as updatable
  93612. * @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)
  93613. * @returns a new Mesh
  93614. */
  93615. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93616. /**
  93617. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93618. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93619. * 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.
  93620. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93621. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93622. * Remember you can only change the shape positions, not their number when updating a polygon.
  93623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93624. * @param name defines the name of the mesh to create
  93625. * @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
  93626. * @param scene defines the hosting scene
  93627. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93628. * @param updatable defines if the mesh must be flagged as updatable
  93629. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93630. * @param earcutInjection can be used to inject your own earcut reference
  93631. * @returns a new Mesh
  93632. */
  93633. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93634. /**
  93635. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93636. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93637. * @param name defines the name of the mesh to create
  93638. * @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
  93639. * @param depth defines the height of extrusion
  93640. * @param scene defines the hosting scene
  93641. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93642. * @param updatable defines if the mesh must be flagged as updatable
  93643. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93644. * @param earcutInjection can be used to inject your own earcut reference
  93645. * @returns a new Mesh
  93646. */
  93647. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93648. /**
  93649. * Creates an extruded shape mesh.
  93650. * 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
  93651. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93652. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93653. * @param name defines the name of the mesh to create
  93654. * @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
  93655. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93656. * @param scale is the value to scale the shape
  93657. * @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
  93658. * @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
  93659. * @param scene defines the hosting scene
  93660. * @param updatable defines if the mesh must be flagged as updatable
  93661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93662. * @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)
  93663. * @returns a new Mesh
  93664. */
  93665. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93666. /**
  93667. * Creates an custom extruded shape mesh.
  93668. * The custom extrusion is a parametric shape.
  93669. * It has no predefined shape. Its final shape will depend on the input parameters.
  93670. * Please consider using the same method from the MeshBuilder class instead
  93671. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93672. * @param name defines the name of the mesh to create
  93673. * @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
  93674. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93675. * @param scaleFunction is a custom Javascript function called on each path point
  93676. * @param rotationFunction is a custom Javascript function called on each path point
  93677. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93678. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93679. * @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
  93680. * @param scene defines the hosting scene
  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 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)
  93684. * @returns a new Mesh
  93685. */
  93686. 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;
  93687. /**
  93688. * Creates lathe mesh.
  93689. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93690. * Please consider using the same method from the MeshBuilder class instead
  93691. * @param name defines the name of the mesh to create
  93692. * @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
  93693. * @param radius is the radius value of the lathe
  93694. * @param tessellation is the side number of the lathe.
  93695. * @param scene defines the hosting scene
  93696. * @param updatable defines if the mesh must be flagged as updatable
  93697. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93698. * @returns a new Mesh
  93699. */
  93700. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93701. /**
  93702. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93703. * @param name defines the name of the mesh to create
  93704. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93705. * @param scene defines the hosting scene
  93706. * @param updatable defines if the mesh must be flagged as updatable
  93707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93708. * @returns a new Mesh
  93709. */
  93710. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93711. /**
  93712. * Creates a ground mesh.
  93713. * Please consider using the same method from the MeshBuilder class instead
  93714. * @param name defines the name of the mesh to create
  93715. * @param width set the width of the ground
  93716. * @param height set the height of the ground
  93717. * @param subdivisions sets the number of subdivisions per side
  93718. * @param scene defines the hosting scene
  93719. * @param updatable defines if the mesh must be flagged as updatable
  93720. * @returns a new Mesh
  93721. */
  93722. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93723. /**
  93724. * Creates a tiled ground mesh.
  93725. * Please consider using the same method from the MeshBuilder class instead
  93726. * @param name defines the name of the mesh to create
  93727. * @param xmin set the ground minimum X coordinate
  93728. * @param zmin set the ground minimum Y coordinate
  93729. * @param xmax set the ground maximum X coordinate
  93730. * @param zmax set the ground maximum Z coordinate
  93731. * @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
  93732. * @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
  93733. * @param scene defines the hosting scene
  93734. * @param updatable defines if the mesh must be flagged as updatable
  93735. * @returns a new Mesh
  93736. */
  93737. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93738. w: number;
  93739. h: number;
  93740. }, precision: {
  93741. w: number;
  93742. h: number;
  93743. }, scene: Scene, updatable?: boolean): Mesh;
  93744. /**
  93745. * Creates a ground mesh from a height map.
  93746. * Please consider using the same method from the MeshBuilder class instead
  93747. * @see http://doc.babylonjs.com/babylon101/height_map
  93748. * @param name defines the name of the mesh to create
  93749. * @param url sets the URL of the height map image resource
  93750. * @param width set the ground width size
  93751. * @param height set the ground height size
  93752. * @param subdivisions sets the number of subdivision per side
  93753. * @param minHeight is the minimum altitude on the ground
  93754. * @param maxHeight is the maximum altitude on the ground
  93755. * @param scene defines the hosting scene
  93756. * @param updatable defines if the mesh must be flagged as updatable
  93757. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93758. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93759. * @returns a new Mesh
  93760. */
  93761. 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;
  93762. /**
  93763. * Creates a tube mesh.
  93764. * The tube is a parametric shape.
  93765. * It has no predefined shape. Its final shape will depend on the input parameters.
  93766. * Please consider using the same method from the MeshBuilder class instead
  93767. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93768. * @param name defines the name of the mesh to create
  93769. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93770. * @param radius sets the tube radius size
  93771. * @param tessellation is the number of sides on the tubular surface
  93772. * @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
  93773. * @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
  93774. * @param scene defines the hosting scene
  93775. * @param updatable defines if the mesh must be flagged as updatable
  93776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93777. * @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)
  93778. * @returns a new Mesh
  93779. */
  93780. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93781. (i: number, distance: number): number;
  93782. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93783. /**
  93784. * Creates a polyhedron mesh.
  93785. * Please consider using the same method from the MeshBuilder class instead.
  93786. * * 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
  93787. * * The parameter `size` (positive float, default 1) sets the polygon size
  93788. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93789. * * 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`
  93790. * * 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
  93791. * * 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)`)
  93792. * * 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
  93793. * * 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
  93794. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93795. * * If you create a double-sided mesh, you can choose what parts of 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
  93796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93797. * @param name defines the name of the mesh to create
  93798. * @param options defines the options used to create the mesh
  93799. * @param scene defines the hosting scene
  93800. * @returns a new Mesh
  93801. */
  93802. static CreatePolyhedron(name: string, options: {
  93803. type?: number;
  93804. size?: number;
  93805. sizeX?: number;
  93806. sizeY?: number;
  93807. sizeZ?: number;
  93808. custom?: any;
  93809. faceUV?: Vector4[];
  93810. faceColors?: Color4[];
  93811. updatable?: boolean;
  93812. sideOrientation?: number;
  93813. }, scene: Scene): Mesh;
  93814. /**
  93815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93817. * * 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`)
  93818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93819. * * 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
  93820. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93821. * * If you create a double-sided mesh, you can choose what parts of 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
  93822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93823. * @param name defines the name of the mesh
  93824. * @param options defines the options used to create the mesh
  93825. * @param scene defines the hosting scene
  93826. * @returns a new Mesh
  93827. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93828. */
  93829. static CreateIcoSphere(name: string, options: {
  93830. radius?: number;
  93831. flat?: boolean;
  93832. subdivisions?: number;
  93833. sideOrientation?: number;
  93834. updatable?: boolean;
  93835. }, scene: Scene): Mesh;
  93836. /**
  93837. * Creates a decal mesh.
  93838. * Please consider using the same method from the MeshBuilder class instead.
  93839. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93840. * @param name defines the name of the mesh
  93841. * @param sourceMesh defines the mesh receiving the decal
  93842. * @param position sets the position of the decal in world coordinates
  93843. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93844. * @param size sets the decal scaling
  93845. * @param angle sets the angle to rotate the decal
  93846. * @returns a new Mesh
  93847. */
  93848. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93849. /**
  93850. * Prepare internal position array for software CPU skinning
  93851. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93852. */
  93853. setPositionsForCPUSkinning(): Float32Array;
  93854. /**
  93855. * Prepare internal normal array for software CPU skinning
  93856. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93857. */
  93858. setNormalsForCPUSkinning(): Float32Array;
  93859. /**
  93860. * Updates the vertex buffer by applying transformation from the bones
  93861. * @param skeleton defines the skeleton to apply to current mesh
  93862. * @returns the current mesh
  93863. */
  93864. applySkeleton(skeleton: Skeleton): Mesh;
  93865. /**
  93866. * 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
  93867. * @param meshes defines the list of meshes to scan
  93868. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93869. */
  93870. static MinMax(meshes: AbstractMesh[]): {
  93871. min: Vector3;
  93872. max: Vector3;
  93873. };
  93874. /**
  93875. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93876. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93877. * @returns a vector3
  93878. */
  93879. static Center(meshesOrMinMaxVector: {
  93880. min: Vector3;
  93881. max: Vector3;
  93882. } | AbstractMesh[]): Vector3;
  93883. /**
  93884. * Merge the array of meshes into a single mesh for performance reasons.
  93885. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93886. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93887. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93888. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93889. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93890. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93891. * @returns a new mesh
  93892. */
  93893. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93894. /** @hidden */
  93895. addInstance(instance: InstancedMesh): void;
  93896. /** @hidden */
  93897. removeInstance(instance: InstancedMesh): void;
  93898. }
  93899. }
  93900. declare module BABYLON {
  93901. /**
  93902. * This is the base class of all the camera used in the application.
  93903. * @see http://doc.babylonjs.com/features/cameras
  93904. */
  93905. export class Camera extends Node {
  93906. /** @hidden */
  93907. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93908. /**
  93909. * This is the default projection mode used by the cameras.
  93910. * It helps recreating a feeling of perspective and better appreciate depth.
  93911. * This is the best way to simulate real life cameras.
  93912. */
  93913. static readonly PERSPECTIVE_CAMERA: number;
  93914. /**
  93915. * This helps creating camera with an orthographic mode.
  93916. * 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.
  93917. */
  93918. static readonly ORTHOGRAPHIC_CAMERA: number;
  93919. /**
  93920. * This is the default FOV mode for perspective cameras.
  93921. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93922. */
  93923. static readonly FOVMODE_VERTICAL_FIXED: number;
  93924. /**
  93925. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93926. */
  93927. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93928. /**
  93929. * This specifies ther is no need for a camera rig.
  93930. * Basically only one eye is rendered corresponding to the camera.
  93931. */
  93932. static readonly RIG_MODE_NONE: number;
  93933. /**
  93934. * Simulates a camera Rig with one blue eye and one red eye.
  93935. * This can be use with 3d blue and red glasses.
  93936. */
  93937. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93938. /**
  93939. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93940. */
  93941. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93942. /**
  93943. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93944. */
  93945. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93946. /**
  93947. * Defines that both eyes of the camera will be rendered over under each other.
  93948. */
  93949. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93950. /**
  93951. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93952. */
  93953. static readonly RIG_MODE_VR: number;
  93954. /**
  93955. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93956. */
  93957. static readonly RIG_MODE_WEBVR: number;
  93958. /**
  93959. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93960. */
  93961. static readonly RIG_MODE_CUSTOM: number;
  93962. /**
  93963. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93964. */
  93965. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93966. /**
  93967. * Define the input manager associated with the camera.
  93968. */
  93969. inputs: CameraInputsManager<Camera>;
  93970. /** @hidden */
  93971. _position: Vector3;
  93972. /**
  93973. * Define the current local position of the camera in the scene
  93974. */
  93975. position: Vector3;
  93976. /**
  93977. * The vector the camera should consider as up.
  93978. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93979. */
  93980. upVector: Vector3;
  93981. /**
  93982. * Define the current limit on the left side for an orthographic camera
  93983. * In scene unit
  93984. */
  93985. orthoLeft: Nullable<number>;
  93986. /**
  93987. * Define the current limit on the right side for an orthographic camera
  93988. * In scene unit
  93989. */
  93990. orthoRight: Nullable<number>;
  93991. /**
  93992. * Define the current limit on the bottom side for an orthographic camera
  93993. * In scene unit
  93994. */
  93995. orthoBottom: Nullable<number>;
  93996. /**
  93997. * Define the current limit on the top side for an orthographic camera
  93998. * In scene unit
  93999. */
  94000. orthoTop: Nullable<number>;
  94001. /**
  94002. * Field Of View is set in Radians. (default is 0.8)
  94003. */
  94004. fov: number;
  94005. /**
  94006. * Define the minimum distance the camera can see from.
  94007. * This is important to note that the depth buffer are not infinite and the closer it starts
  94008. * the more your scene might encounter depth fighting issue.
  94009. */
  94010. minZ: number;
  94011. /**
  94012. * Define the maximum distance the camera can see to.
  94013. * This is important to note that the depth buffer are not infinite and the further it end
  94014. * the more your scene might encounter depth fighting issue.
  94015. */
  94016. maxZ: number;
  94017. /**
  94018. * Define the default inertia of the camera.
  94019. * This helps giving a smooth feeling to the camera movement.
  94020. */
  94021. inertia: number;
  94022. /**
  94023. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94024. */
  94025. mode: number;
  94026. /**
  94027. * Define wether the camera is intermediate.
  94028. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94029. */
  94030. isIntermediate: boolean;
  94031. /**
  94032. * Define the viewport of the camera.
  94033. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94034. */
  94035. viewport: Viewport;
  94036. /**
  94037. * Restricts the camera to viewing objects with the same layerMask.
  94038. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94039. */
  94040. layerMask: number;
  94041. /**
  94042. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94043. */
  94044. fovMode: number;
  94045. /**
  94046. * Rig mode of the camera.
  94047. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94048. * This is normally controlled byt the camera themselves as internal use.
  94049. */
  94050. cameraRigMode: number;
  94051. /**
  94052. * Defines the distance between both "eyes" in case of a RIG
  94053. */
  94054. interaxialDistance: number;
  94055. /**
  94056. * Defines if stereoscopic rendering is done side by side or over under.
  94057. */
  94058. isStereoscopicSideBySide: boolean;
  94059. /**
  94060. * 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
  94061. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94062. * else in the scene. (Eg. security camera)
  94063. *
  94064. * 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)
  94065. */
  94066. customRenderTargets: RenderTargetTexture[];
  94067. /**
  94068. * When set, the camera will render to this render target instead of the default canvas
  94069. *
  94070. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94071. */
  94072. outputRenderTarget: Nullable<RenderTargetTexture>;
  94073. /**
  94074. * Observable triggered when the camera view matrix has changed.
  94075. */
  94076. onViewMatrixChangedObservable: Observable<Camera>;
  94077. /**
  94078. * Observable triggered when the camera Projection matrix has changed.
  94079. */
  94080. onProjectionMatrixChangedObservable: Observable<Camera>;
  94081. /**
  94082. * Observable triggered when the inputs have been processed.
  94083. */
  94084. onAfterCheckInputsObservable: Observable<Camera>;
  94085. /**
  94086. * Observable triggered when reset has been called and applied to the camera.
  94087. */
  94088. onRestoreStateObservable: Observable<Camera>;
  94089. /** @hidden */
  94090. _cameraRigParams: any;
  94091. /** @hidden */
  94092. _rigCameras: Camera[];
  94093. /** @hidden */
  94094. _rigPostProcess: Nullable<PostProcess>;
  94095. protected _webvrViewMatrix: Matrix;
  94096. /** @hidden */
  94097. _skipRendering: boolean;
  94098. /** @hidden */
  94099. _projectionMatrix: Matrix;
  94100. /** @hidden */
  94101. _postProcesses: Nullable<PostProcess>[];
  94102. /** @hidden */
  94103. _activeMeshes: SmartArray<AbstractMesh>;
  94104. protected _globalPosition: Vector3;
  94105. /** @hidden */
  94106. _computedViewMatrix: Matrix;
  94107. private _doNotComputeProjectionMatrix;
  94108. private _transformMatrix;
  94109. private _frustumPlanes;
  94110. private _refreshFrustumPlanes;
  94111. private _storedFov;
  94112. private _stateStored;
  94113. /**
  94114. * Instantiates a new camera object.
  94115. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94116. * @see http://doc.babylonjs.com/features/cameras
  94117. * @param name Defines the name of the camera in the scene
  94118. * @param position Defines the position of the camera
  94119. * @param scene Defines the scene the camera belongs too
  94120. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94121. */
  94122. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94123. /**
  94124. * Store current camera state (fov, position, etc..)
  94125. * @returns the camera
  94126. */
  94127. storeState(): Camera;
  94128. /**
  94129. * Restores the camera state values if it has been stored. You must call storeState() first
  94130. */
  94131. protected _restoreStateValues(): boolean;
  94132. /**
  94133. * Restored camera state. You must call storeState() first.
  94134. * @returns true if restored and false otherwise
  94135. */
  94136. restoreState(): boolean;
  94137. /**
  94138. * Gets the class name of the camera.
  94139. * @returns the class name
  94140. */
  94141. getClassName(): string;
  94142. /** @hidden */
  94143. readonly _isCamera: boolean;
  94144. /**
  94145. * Gets a string representation of the camera useful for debug purpose.
  94146. * @param fullDetails Defines that a more verboe level of logging is required
  94147. * @returns the string representation
  94148. */
  94149. toString(fullDetails?: boolean): string;
  94150. /**
  94151. * Gets the current world space position of the camera.
  94152. */
  94153. readonly globalPosition: Vector3;
  94154. /**
  94155. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94156. * @returns the active meshe list
  94157. */
  94158. getActiveMeshes(): SmartArray<AbstractMesh>;
  94159. /**
  94160. * Check wether a mesh is part of the current active mesh list of the camera
  94161. * @param mesh Defines the mesh to check
  94162. * @returns true if active, false otherwise
  94163. */
  94164. isActiveMesh(mesh: Mesh): boolean;
  94165. /**
  94166. * Is this camera ready to be used/rendered
  94167. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94168. * @return true if the camera is ready
  94169. */
  94170. isReady(completeCheck?: boolean): boolean;
  94171. /** @hidden */
  94172. _initCache(): void;
  94173. /** @hidden */
  94174. _updateCache(ignoreParentClass?: boolean): void;
  94175. /** @hidden */
  94176. _isSynchronized(): boolean;
  94177. /** @hidden */
  94178. _isSynchronizedViewMatrix(): boolean;
  94179. /** @hidden */
  94180. _isSynchronizedProjectionMatrix(): boolean;
  94181. /**
  94182. * Attach the input controls to a specific dom element to get the input from.
  94183. * @param element Defines the element the controls should be listened from
  94184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94185. */
  94186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94187. /**
  94188. * Detach the current controls from the specified dom element.
  94189. * @param element Defines the element to stop listening the inputs from
  94190. */
  94191. detachControl(element: HTMLElement): void;
  94192. /**
  94193. * Update the camera state according to the different inputs gathered during the frame.
  94194. */
  94195. update(): void;
  94196. /** @hidden */
  94197. _checkInputs(): void;
  94198. /** @hidden */
  94199. readonly rigCameras: Camera[];
  94200. /**
  94201. * Gets the post process used by the rig cameras
  94202. */
  94203. readonly rigPostProcess: Nullable<PostProcess>;
  94204. /**
  94205. * Internal, gets the first post proces.
  94206. * @returns the first post process to be run on this camera.
  94207. */
  94208. _getFirstPostProcess(): Nullable<PostProcess>;
  94209. private _cascadePostProcessesToRigCams;
  94210. /**
  94211. * Attach a post process to the camera.
  94212. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94213. * @param postProcess The post process to attach to the camera
  94214. * @param insertAt The position of the post process in case several of them are in use in the scene
  94215. * @returns the position the post process has been inserted at
  94216. */
  94217. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94218. /**
  94219. * Detach a post process to the camera.
  94220. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94221. * @param postProcess The post process to detach from the camera
  94222. */
  94223. detachPostProcess(postProcess: PostProcess): void;
  94224. /**
  94225. * Gets the current world matrix of the camera
  94226. */
  94227. getWorldMatrix(): Matrix;
  94228. /** @hidden */
  94229. _getViewMatrix(): Matrix;
  94230. /**
  94231. * Gets the current view matrix of the camera.
  94232. * @param force forces the camera to recompute the matrix without looking at the cached state
  94233. * @returns the view matrix
  94234. */
  94235. getViewMatrix(force?: boolean): Matrix;
  94236. /**
  94237. * Freeze the projection matrix.
  94238. * It will prevent the cache check of the camera projection compute and can speed up perf
  94239. * if no parameter of the camera are meant to change
  94240. * @param projection Defines manually a projection if necessary
  94241. */
  94242. freezeProjectionMatrix(projection?: Matrix): void;
  94243. /**
  94244. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94245. */
  94246. unfreezeProjectionMatrix(): void;
  94247. /**
  94248. * Gets the current projection matrix of the camera.
  94249. * @param force forces the camera to recompute the matrix without looking at the cached state
  94250. * @returns the projection matrix
  94251. */
  94252. getProjectionMatrix(force?: boolean): Matrix;
  94253. /**
  94254. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94255. * @returns a Matrix
  94256. */
  94257. getTransformationMatrix(): Matrix;
  94258. private _updateFrustumPlanes;
  94259. /**
  94260. * Checks if a cullable object (mesh...) is in the camera frustum
  94261. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94262. * @param target The object to check
  94263. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94264. * @returns true if the object is in frustum otherwise false
  94265. */
  94266. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94267. /**
  94268. * Checks if a cullable object (mesh...) is in the camera frustum
  94269. * Unlike isInFrustum this cheks the full bounding box
  94270. * @param target The object to check
  94271. * @returns true if the object is in frustum otherwise false
  94272. */
  94273. isCompletelyInFrustum(target: ICullable): boolean;
  94274. /**
  94275. * Gets a ray in the forward direction from the camera.
  94276. * @param length Defines the length of the ray to create
  94277. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94278. * @param origin Defines the start point of the ray which defaults to the camera position
  94279. * @returns the forward ray
  94280. */
  94281. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94282. /**
  94283. * Releases resources associated with this node.
  94284. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94285. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94286. */
  94287. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94288. /** @hidden */
  94289. _isLeftCamera: boolean;
  94290. /**
  94291. * Gets the left camera of a rig setup in case of Rigged Camera
  94292. */
  94293. readonly isLeftCamera: boolean;
  94294. /** @hidden */
  94295. _isRightCamera: boolean;
  94296. /**
  94297. * Gets the right camera of a rig setup in case of Rigged Camera
  94298. */
  94299. readonly isRightCamera: boolean;
  94300. /**
  94301. * Gets the left camera of a rig setup in case of Rigged Camera
  94302. */
  94303. readonly leftCamera: Nullable<FreeCamera>;
  94304. /**
  94305. * Gets the right camera of a rig setup in case of Rigged Camera
  94306. */
  94307. readonly rightCamera: Nullable<FreeCamera>;
  94308. /**
  94309. * Gets the left camera target of a rig setup in case of Rigged Camera
  94310. * @returns the target position
  94311. */
  94312. getLeftTarget(): Nullable<Vector3>;
  94313. /**
  94314. * Gets the right camera target of a rig setup in case of Rigged Camera
  94315. * @returns the target position
  94316. */
  94317. getRightTarget(): Nullable<Vector3>;
  94318. /**
  94319. * @hidden
  94320. */
  94321. setCameraRigMode(mode: number, rigParams: any): void;
  94322. /** @hidden */
  94323. static _setStereoscopicRigMode(camera: Camera): void;
  94324. /** @hidden */
  94325. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94326. /** @hidden */
  94327. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94328. /** @hidden */
  94329. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94330. /** @hidden */
  94331. _getVRProjectionMatrix(): Matrix;
  94332. protected _updateCameraRotationMatrix(): void;
  94333. protected _updateWebVRCameraRotationMatrix(): void;
  94334. /**
  94335. * This function MUST be overwritten by the different WebVR cameras available.
  94336. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94337. * @hidden
  94338. */
  94339. _getWebVRProjectionMatrix(): Matrix;
  94340. /**
  94341. * This function MUST be overwritten by the different WebVR cameras available.
  94342. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94343. * @hidden
  94344. */
  94345. _getWebVRViewMatrix(): Matrix;
  94346. /** @hidden */
  94347. setCameraRigParameter(name: string, value: any): void;
  94348. /**
  94349. * needs to be overridden by children so sub has required properties to be copied
  94350. * @hidden
  94351. */
  94352. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94353. /**
  94354. * May need to be overridden by children
  94355. * @hidden
  94356. */
  94357. _updateRigCameras(): void;
  94358. /** @hidden */
  94359. _setupInputs(): void;
  94360. /**
  94361. * Serialiaze the camera setup to a json represention
  94362. * @returns the JSON representation
  94363. */
  94364. serialize(): any;
  94365. /**
  94366. * Clones the current camera.
  94367. * @param name The cloned camera name
  94368. * @returns the cloned camera
  94369. */
  94370. clone(name: string): Camera;
  94371. /**
  94372. * Gets the direction of the camera relative to a given local axis.
  94373. * @param localAxis Defines the reference axis to provide a relative direction.
  94374. * @return the direction
  94375. */
  94376. getDirection(localAxis: Vector3): Vector3;
  94377. /**
  94378. * Returns the current camera absolute rotation
  94379. */
  94380. readonly absoluteRotation: Quaternion;
  94381. /**
  94382. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94383. * @param localAxis Defines the reference axis to provide a relative direction.
  94384. * @param result Defines the vector to store the result in
  94385. */
  94386. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94387. /**
  94388. * Gets a camera constructor for a given camera type
  94389. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94390. * @param name The name of the camera the result will be able to instantiate
  94391. * @param scene The scene the result will construct the camera in
  94392. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94393. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94394. * @returns a factory method to construc the camera
  94395. */
  94396. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94397. /**
  94398. * Compute the world matrix of the camera.
  94399. * @returns the camera world matrix
  94400. */
  94401. computeWorldMatrix(): Matrix;
  94402. /**
  94403. * Parse a JSON and creates the camera from the parsed information
  94404. * @param parsedCamera The JSON to parse
  94405. * @param scene The scene to instantiate the camera in
  94406. * @returns the newly constructed camera
  94407. */
  94408. static Parse(parsedCamera: any, scene: Scene): Camera;
  94409. }
  94410. }
  94411. declare module BABYLON {
  94412. /**
  94413. * Class containing static functions to help procedurally build meshes
  94414. */
  94415. export class DiscBuilder {
  94416. /**
  94417. * Creates a plane polygonal mesh. By default, this is a disc
  94418. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94419. * * 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
  94420. * * 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
  94421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94424. * @param name defines the name of the mesh
  94425. * @param options defines the options used to create the mesh
  94426. * @param scene defines the hosting scene
  94427. * @returns the plane polygonal mesh
  94428. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94429. */
  94430. static CreateDisc(name: string, options: {
  94431. radius?: number;
  94432. tessellation?: number;
  94433. arc?: number;
  94434. updatable?: boolean;
  94435. sideOrientation?: number;
  94436. frontUVs?: Vector4;
  94437. backUVs?: Vector4;
  94438. }, scene?: Nullable<Scene>): Mesh;
  94439. }
  94440. }
  94441. declare module BABYLON {
  94442. /**
  94443. * This represents all the required information to add a fresnel effect on a material:
  94444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94445. */
  94446. export class FresnelParameters {
  94447. private _isEnabled;
  94448. /**
  94449. * Define if the fresnel effect is enable or not.
  94450. */
  94451. isEnabled: boolean;
  94452. /**
  94453. * Define the color used on edges (grazing angle)
  94454. */
  94455. leftColor: Color3;
  94456. /**
  94457. * Define the color used on center
  94458. */
  94459. rightColor: Color3;
  94460. /**
  94461. * Define bias applied to computed fresnel term
  94462. */
  94463. bias: number;
  94464. /**
  94465. * Defined the power exponent applied to fresnel term
  94466. */
  94467. power: number;
  94468. /**
  94469. * Clones the current fresnel and its valuues
  94470. * @returns a clone fresnel configuration
  94471. */
  94472. clone(): FresnelParameters;
  94473. /**
  94474. * Serializes the current fresnel parameters to a JSON representation.
  94475. * @return the JSON serialization
  94476. */
  94477. serialize(): any;
  94478. /**
  94479. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94480. * @param parsedFresnelParameters Define the JSON representation
  94481. * @returns the parsed parameters
  94482. */
  94483. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94484. }
  94485. }
  94486. declare module BABYLON {
  94487. /**
  94488. * Base class of materials working in push mode in babylon JS
  94489. * @hidden
  94490. */
  94491. export class PushMaterial extends Material {
  94492. protected _activeEffect: Effect;
  94493. protected _normalMatrix: Matrix;
  94494. /**
  94495. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94496. * This means that the material can keep using a previous shader while a new one is being compiled.
  94497. * This is mostly used when shader parallel compilation is supported (true by default)
  94498. */
  94499. allowShaderHotSwapping: boolean;
  94500. constructor(name: string, scene: Scene);
  94501. getEffect(): Effect;
  94502. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94503. /**
  94504. * Binds the given world matrix to the active effect
  94505. *
  94506. * @param world the matrix to bind
  94507. */
  94508. bindOnlyWorldMatrix(world: Matrix): void;
  94509. /**
  94510. * Binds the given normal matrix to the active effect
  94511. *
  94512. * @param normalMatrix the matrix to bind
  94513. */
  94514. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94515. bind(world: Matrix, mesh?: Mesh): void;
  94516. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94517. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94518. }
  94519. }
  94520. declare module BABYLON {
  94521. /**
  94522. * This groups all the flags used to control the materials channel.
  94523. */
  94524. export class MaterialFlags {
  94525. private static _DiffuseTextureEnabled;
  94526. /**
  94527. * Are diffuse textures enabled in the application.
  94528. */
  94529. static DiffuseTextureEnabled: boolean;
  94530. private static _AmbientTextureEnabled;
  94531. /**
  94532. * Are ambient textures enabled in the application.
  94533. */
  94534. static AmbientTextureEnabled: boolean;
  94535. private static _OpacityTextureEnabled;
  94536. /**
  94537. * Are opacity textures enabled in the application.
  94538. */
  94539. static OpacityTextureEnabled: boolean;
  94540. private static _ReflectionTextureEnabled;
  94541. /**
  94542. * Are reflection textures enabled in the application.
  94543. */
  94544. static ReflectionTextureEnabled: boolean;
  94545. private static _EmissiveTextureEnabled;
  94546. /**
  94547. * Are emissive textures enabled in the application.
  94548. */
  94549. static EmissiveTextureEnabled: boolean;
  94550. private static _SpecularTextureEnabled;
  94551. /**
  94552. * Are specular textures enabled in the application.
  94553. */
  94554. static SpecularTextureEnabled: boolean;
  94555. private static _BumpTextureEnabled;
  94556. /**
  94557. * Are bump textures enabled in the application.
  94558. */
  94559. static BumpTextureEnabled: boolean;
  94560. private static _LightmapTextureEnabled;
  94561. /**
  94562. * Are lightmap textures enabled in the application.
  94563. */
  94564. static LightmapTextureEnabled: boolean;
  94565. private static _RefractionTextureEnabled;
  94566. /**
  94567. * Are refraction textures enabled in the application.
  94568. */
  94569. static RefractionTextureEnabled: boolean;
  94570. private static _ColorGradingTextureEnabled;
  94571. /**
  94572. * Are color grading textures enabled in the application.
  94573. */
  94574. static ColorGradingTextureEnabled: boolean;
  94575. private static _FresnelEnabled;
  94576. /**
  94577. * Are fresnels enabled in the application.
  94578. */
  94579. static FresnelEnabled: boolean;
  94580. private static _ClearCoatTextureEnabled;
  94581. /**
  94582. * Are clear coat textures enabled in the application.
  94583. */
  94584. static ClearCoatTextureEnabled: boolean;
  94585. private static _ClearCoatBumpTextureEnabled;
  94586. /**
  94587. * Are clear coat bump textures enabled in the application.
  94588. */
  94589. static ClearCoatBumpTextureEnabled: boolean;
  94590. private static _ClearCoatTintTextureEnabled;
  94591. /**
  94592. * Are clear coat tint textures enabled in the application.
  94593. */
  94594. static ClearCoatTintTextureEnabled: boolean;
  94595. private static _SheenTextureEnabled;
  94596. /**
  94597. * Are sheen textures enabled in the application.
  94598. */
  94599. static SheenTextureEnabled: boolean;
  94600. private static _AnisotropicTextureEnabled;
  94601. /**
  94602. * Are anisotropic textures enabled in the application.
  94603. */
  94604. static AnisotropicTextureEnabled: boolean;
  94605. private static _ThicknessTextureEnabled;
  94606. /**
  94607. * Are thickness textures enabled in the application.
  94608. */
  94609. static ThicknessTextureEnabled: boolean;
  94610. }
  94611. }
  94612. declare module BABYLON {
  94613. /** @hidden */
  94614. export var defaultFragmentDeclaration: {
  94615. name: string;
  94616. shader: string;
  94617. };
  94618. }
  94619. declare module BABYLON {
  94620. /** @hidden */
  94621. export var defaultUboDeclaration: {
  94622. name: string;
  94623. shader: string;
  94624. };
  94625. }
  94626. declare module BABYLON {
  94627. /** @hidden */
  94628. export var lightFragmentDeclaration: {
  94629. name: string;
  94630. shader: string;
  94631. };
  94632. }
  94633. declare module BABYLON {
  94634. /** @hidden */
  94635. export var lightUboDeclaration: {
  94636. name: string;
  94637. shader: string;
  94638. };
  94639. }
  94640. declare module BABYLON {
  94641. /** @hidden */
  94642. export var lightsFragmentFunctions: {
  94643. name: string;
  94644. shader: string;
  94645. };
  94646. }
  94647. declare module BABYLON {
  94648. /** @hidden */
  94649. export var shadowsFragmentFunctions: {
  94650. name: string;
  94651. shader: string;
  94652. };
  94653. }
  94654. declare module BABYLON {
  94655. /** @hidden */
  94656. export var fresnelFunction: {
  94657. name: string;
  94658. shader: string;
  94659. };
  94660. }
  94661. declare module BABYLON {
  94662. /** @hidden */
  94663. export var reflectionFunction: {
  94664. name: string;
  94665. shader: string;
  94666. };
  94667. }
  94668. declare module BABYLON {
  94669. /** @hidden */
  94670. export var bumpFragmentFunctions: {
  94671. name: string;
  94672. shader: string;
  94673. };
  94674. }
  94675. declare module BABYLON {
  94676. /** @hidden */
  94677. export var logDepthDeclaration: {
  94678. name: string;
  94679. shader: string;
  94680. };
  94681. }
  94682. declare module BABYLON {
  94683. /** @hidden */
  94684. export var bumpFragment: {
  94685. name: string;
  94686. shader: string;
  94687. };
  94688. }
  94689. declare module BABYLON {
  94690. /** @hidden */
  94691. export var depthPrePass: {
  94692. name: string;
  94693. shader: string;
  94694. };
  94695. }
  94696. declare module BABYLON {
  94697. /** @hidden */
  94698. export var lightFragment: {
  94699. name: string;
  94700. shader: string;
  94701. };
  94702. }
  94703. declare module BABYLON {
  94704. /** @hidden */
  94705. export var logDepthFragment: {
  94706. name: string;
  94707. shader: string;
  94708. };
  94709. }
  94710. declare module BABYLON {
  94711. /** @hidden */
  94712. export var defaultPixelShader: {
  94713. name: string;
  94714. shader: string;
  94715. };
  94716. }
  94717. declare module BABYLON {
  94718. /** @hidden */
  94719. export var defaultVertexDeclaration: {
  94720. name: string;
  94721. shader: string;
  94722. };
  94723. }
  94724. declare module BABYLON {
  94725. /** @hidden */
  94726. export var bumpVertexDeclaration: {
  94727. name: string;
  94728. shader: string;
  94729. };
  94730. }
  94731. declare module BABYLON {
  94732. /** @hidden */
  94733. export var bumpVertex: {
  94734. name: string;
  94735. shader: string;
  94736. };
  94737. }
  94738. declare module BABYLON {
  94739. /** @hidden */
  94740. export var fogVertex: {
  94741. name: string;
  94742. shader: string;
  94743. };
  94744. }
  94745. declare module BABYLON {
  94746. /** @hidden */
  94747. export var shadowsVertex: {
  94748. name: string;
  94749. shader: string;
  94750. };
  94751. }
  94752. declare module BABYLON {
  94753. /** @hidden */
  94754. export var pointCloudVertex: {
  94755. name: string;
  94756. shader: string;
  94757. };
  94758. }
  94759. declare module BABYLON {
  94760. /** @hidden */
  94761. export var logDepthVertex: {
  94762. name: string;
  94763. shader: string;
  94764. };
  94765. }
  94766. declare module BABYLON {
  94767. /** @hidden */
  94768. export var defaultVertexShader: {
  94769. name: string;
  94770. shader: string;
  94771. };
  94772. }
  94773. declare module BABYLON {
  94774. /** @hidden */
  94775. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  94776. MAINUV1: boolean;
  94777. MAINUV2: boolean;
  94778. DIFFUSE: boolean;
  94779. DIFFUSEDIRECTUV: number;
  94780. AMBIENT: boolean;
  94781. AMBIENTDIRECTUV: number;
  94782. OPACITY: boolean;
  94783. OPACITYDIRECTUV: number;
  94784. OPACITYRGB: boolean;
  94785. REFLECTION: boolean;
  94786. EMISSIVE: boolean;
  94787. EMISSIVEDIRECTUV: number;
  94788. SPECULAR: boolean;
  94789. SPECULARDIRECTUV: number;
  94790. BUMP: boolean;
  94791. BUMPDIRECTUV: number;
  94792. PARALLAX: boolean;
  94793. PARALLAXOCCLUSION: boolean;
  94794. SPECULAROVERALPHA: boolean;
  94795. CLIPPLANE: boolean;
  94796. CLIPPLANE2: boolean;
  94797. CLIPPLANE3: boolean;
  94798. CLIPPLANE4: boolean;
  94799. ALPHATEST: boolean;
  94800. DEPTHPREPASS: boolean;
  94801. ALPHAFROMDIFFUSE: boolean;
  94802. POINTSIZE: boolean;
  94803. FOG: boolean;
  94804. SPECULARTERM: boolean;
  94805. DIFFUSEFRESNEL: boolean;
  94806. OPACITYFRESNEL: boolean;
  94807. REFLECTIONFRESNEL: boolean;
  94808. REFRACTIONFRESNEL: boolean;
  94809. EMISSIVEFRESNEL: boolean;
  94810. FRESNEL: boolean;
  94811. NORMAL: boolean;
  94812. UV1: boolean;
  94813. UV2: boolean;
  94814. VERTEXCOLOR: boolean;
  94815. VERTEXALPHA: boolean;
  94816. NUM_BONE_INFLUENCERS: number;
  94817. BonesPerMesh: number;
  94818. BONETEXTURE: boolean;
  94819. INSTANCES: boolean;
  94820. GLOSSINESS: boolean;
  94821. ROUGHNESS: boolean;
  94822. EMISSIVEASILLUMINATION: boolean;
  94823. LINKEMISSIVEWITHDIFFUSE: boolean;
  94824. REFLECTIONFRESNELFROMSPECULAR: boolean;
  94825. LIGHTMAP: boolean;
  94826. LIGHTMAPDIRECTUV: number;
  94827. OBJECTSPACE_NORMALMAP: boolean;
  94828. USELIGHTMAPASSHADOWMAP: boolean;
  94829. REFLECTIONMAP_3D: boolean;
  94830. REFLECTIONMAP_SPHERICAL: boolean;
  94831. REFLECTIONMAP_PLANAR: boolean;
  94832. REFLECTIONMAP_CUBIC: boolean;
  94833. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  94834. REFLECTIONMAP_PROJECTION: boolean;
  94835. REFLECTIONMAP_SKYBOX: boolean;
  94836. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  94837. REFLECTIONMAP_EXPLICIT: boolean;
  94838. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  94839. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  94840. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  94841. INVERTCUBICMAP: boolean;
  94842. LOGARITHMICDEPTH: boolean;
  94843. REFRACTION: boolean;
  94844. REFRACTIONMAP_3D: boolean;
  94845. REFLECTIONOVERALPHA: boolean;
  94846. TWOSIDEDLIGHTING: boolean;
  94847. SHADOWFLOAT: boolean;
  94848. MORPHTARGETS: boolean;
  94849. MORPHTARGETS_NORMAL: boolean;
  94850. MORPHTARGETS_TANGENT: boolean;
  94851. MORPHTARGETS_UV: boolean;
  94852. NUM_MORPH_INFLUENCERS: number;
  94853. NONUNIFORMSCALING: boolean;
  94854. PREMULTIPLYALPHA: boolean;
  94855. IMAGEPROCESSING: boolean;
  94856. VIGNETTE: boolean;
  94857. VIGNETTEBLENDMODEMULTIPLY: boolean;
  94858. VIGNETTEBLENDMODEOPAQUE: boolean;
  94859. TONEMAPPING: boolean;
  94860. TONEMAPPING_ACES: boolean;
  94861. CONTRAST: boolean;
  94862. COLORCURVES: boolean;
  94863. COLORGRADING: boolean;
  94864. COLORGRADING3D: boolean;
  94865. SAMPLER3DGREENDEPTH: boolean;
  94866. SAMPLER3DBGRMAP: boolean;
  94867. IMAGEPROCESSINGPOSTPROCESS: boolean;
  94868. MULTIVIEW: boolean;
  94869. /**
  94870. * If the reflection texture on this material is in linear color space
  94871. * @hidden
  94872. */
  94873. IS_REFLECTION_LINEAR: boolean;
  94874. /**
  94875. * If the refraction texture on this material is in linear color space
  94876. * @hidden
  94877. */
  94878. IS_REFRACTION_LINEAR: boolean;
  94879. EXPOSURE: boolean;
  94880. constructor();
  94881. setReflectionMode(modeToEnable: string): void;
  94882. }
  94883. /**
  94884. * This is the default material used in Babylon. It is the best trade off between quality
  94885. * and performances.
  94886. * @see http://doc.babylonjs.com/babylon101/materials
  94887. */
  94888. export class StandardMaterial extends PushMaterial {
  94889. private _diffuseTexture;
  94890. /**
  94891. * The basic texture of the material as viewed under a light.
  94892. */
  94893. diffuseTexture: Nullable<BaseTexture>;
  94894. private _ambientTexture;
  94895. /**
  94896. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  94897. */
  94898. ambientTexture: Nullable<BaseTexture>;
  94899. private _opacityTexture;
  94900. /**
  94901. * Define the transparency of the material from a texture.
  94902. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  94903. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  94904. */
  94905. opacityTexture: Nullable<BaseTexture>;
  94906. private _reflectionTexture;
  94907. /**
  94908. * Define the texture used to display the reflection.
  94909. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94910. */
  94911. reflectionTexture: Nullable<BaseTexture>;
  94912. private _emissiveTexture;
  94913. /**
  94914. * Define texture of the material as if self lit.
  94915. * This will be mixed in the final result even in the absence of light.
  94916. */
  94917. emissiveTexture: Nullable<BaseTexture>;
  94918. private _specularTexture;
  94919. /**
  94920. * Define how the color and intensity of the highlight given by the light in the material.
  94921. */
  94922. specularTexture: Nullable<BaseTexture>;
  94923. private _bumpTexture;
  94924. /**
  94925. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  94926. * 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.
  94927. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  94928. */
  94929. bumpTexture: Nullable<BaseTexture>;
  94930. private _lightmapTexture;
  94931. /**
  94932. * Complex lighting can be computationally expensive to compute at runtime.
  94933. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  94934. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  94935. */
  94936. lightmapTexture: Nullable<BaseTexture>;
  94937. private _refractionTexture;
  94938. /**
  94939. * Define the texture used to display the refraction.
  94940. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  94941. */
  94942. refractionTexture: Nullable<BaseTexture>;
  94943. /**
  94944. * The color of the material lit by the environmental background lighting.
  94945. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  94946. */
  94947. ambientColor: Color3;
  94948. /**
  94949. * The basic color of the material as viewed under a light.
  94950. */
  94951. diffuseColor: Color3;
  94952. /**
  94953. * Define how the color and intensity of the highlight given by the light in the material.
  94954. */
  94955. specularColor: Color3;
  94956. /**
  94957. * Define the color of the material as if self lit.
  94958. * This will be mixed in the final result even in the absence of light.
  94959. */
  94960. emissiveColor: Color3;
  94961. /**
  94962. * Defines how sharp are the highlights in the material.
  94963. * The bigger the value the sharper giving a more glossy feeling to the result.
  94964. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  94965. */
  94966. specularPower: number;
  94967. private _useAlphaFromDiffuseTexture;
  94968. /**
  94969. * Does the transparency come from the diffuse texture alpha channel.
  94970. */
  94971. useAlphaFromDiffuseTexture: boolean;
  94972. private _useEmissiveAsIllumination;
  94973. /**
  94974. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  94975. */
  94976. useEmissiveAsIllumination: boolean;
  94977. private _linkEmissiveWithDiffuse;
  94978. /**
  94979. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  94980. * the emissive level when the final color is close to one.
  94981. */
  94982. linkEmissiveWithDiffuse: boolean;
  94983. private _useSpecularOverAlpha;
  94984. /**
  94985. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  94986. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  94987. */
  94988. useSpecularOverAlpha: boolean;
  94989. private _useReflectionOverAlpha;
  94990. /**
  94991. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  94992. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  94993. */
  94994. useReflectionOverAlpha: boolean;
  94995. private _disableLighting;
  94996. /**
  94997. * Does lights from the scene impacts this material.
  94998. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  94999. */
  95000. disableLighting: boolean;
  95001. private _useObjectSpaceNormalMap;
  95002. /**
  95003. * Allows using an object space normal map (instead of tangent space).
  95004. */
  95005. useObjectSpaceNormalMap: boolean;
  95006. private _useParallax;
  95007. /**
  95008. * Is parallax enabled or not.
  95009. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95010. */
  95011. useParallax: boolean;
  95012. private _useParallaxOcclusion;
  95013. /**
  95014. * Is parallax occlusion enabled or not.
  95015. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95016. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95017. */
  95018. useParallaxOcclusion: boolean;
  95019. /**
  95020. * 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.
  95021. */
  95022. parallaxScaleBias: number;
  95023. private _roughness;
  95024. /**
  95025. * Helps to define how blurry the reflections should appears in the material.
  95026. */
  95027. roughness: number;
  95028. /**
  95029. * In case of refraction, define the value of the index of refraction.
  95030. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95031. */
  95032. indexOfRefraction: number;
  95033. /**
  95034. * Invert the refraction texture alongside the y axis.
  95035. * It can be useful with procedural textures or probe for instance.
  95036. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95037. */
  95038. invertRefractionY: boolean;
  95039. /**
  95040. * Defines the alpha limits in alpha test mode.
  95041. */
  95042. alphaCutOff: number;
  95043. private _useLightmapAsShadowmap;
  95044. /**
  95045. * In case of light mapping, define whether the map contains light or shadow informations.
  95046. */
  95047. useLightmapAsShadowmap: boolean;
  95048. private _diffuseFresnelParameters;
  95049. /**
  95050. * Define the diffuse fresnel parameters of the material.
  95051. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95052. */
  95053. diffuseFresnelParameters: FresnelParameters;
  95054. private _opacityFresnelParameters;
  95055. /**
  95056. * Define the opacity fresnel parameters of the material.
  95057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95058. */
  95059. opacityFresnelParameters: FresnelParameters;
  95060. private _reflectionFresnelParameters;
  95061. /**
  95062. * Define the reflection fresnel parameters of the material.
  95063. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95064. */
  95065. reflectionFresnelParameters: FresnelParameters;
  95066. private _refractionFresnelParameters;
  95067. /**
  95068. * Define the refraction fresnel parameters of the material.
  95069. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95070. */
  95071. refractionFresnelParameters: FresnelParameters;
  95072. private _emissiveFresnelParameters;
  95073. /**
  95074. * Define the emissive fresnel parameters of the material.
  95075. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95076. */
  95077. emissiveFresnelParameters: FresnelParameters;
  95078. private _useReflectionFresnelFromSpecular;
  95079. /**
  95080. * If true automatically deducts the fresnels values from the material specularity.
  95081. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95082. */
  95083. useReflectionFresnelFromSpecular: boolean;
  95084. private _useGlossinessFromSpecularMapAlpha;
  95085. /**
  95086. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95087. */
  95088. useGlossinessFromSpecularMapAlpha: boolean;
  95089. private _maxSimultaneousLights;
  95090. /**
  95091. * Defines the maximum number of lights that can be used in the material
  95092. */
  95093. maxSimultaneousLights: number;
  95094. private _invertNormalMapX;
  95095. /**
  95096. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95097. */
  95098. invertNormalMapX: boolean;
  95099. private _invertNormalMapY;
  95100. /**
  95101. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95102. */
  95103. invertNormalMapY: boolean;
  95104. private _twoSidedLighting;
  95105. /**
  95106. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95107. */
  95108. twoSidedLighting: boolean;
  95109. /**
  95110. * Default configuration related to image processing available in the standard Material.
  95111. */
  95112. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95113. /**
  95114. * Gets the image processing configuration used either in this material.
  95115. */
  95116. /**
  95117. * Sets the Default image processing configuration used either in the this material.
  95118. *
  95119. * If sets to null, the scene one is in use.
  95120. */
  95121. imageProcessingConfiguration: ImageProcessingConfiguration;
  95122. /**
  95123. * Keep track of the image processing observer to allow dispose and replace.
  95124. */
  95125. private _imageProcessingObserver;
  95126. /**
  95127. * Attaches a new image processing configuration to the Standard Material.
  95128. * @param configuration
  95129. */
  95130. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95131. /**
  95132. * Gets wether the color curves effect is enabled.
  95133. */
  95134. /**
  95135. * Sets wether the color curves effect is enabled.
  95136. */
  95137. cameraColorCurvesEnabled: boolean;
  95138. /**
  95139. * Gets wether the color grading effect is enabled.
  95140. */
  95141. /**
  95142. * Gets wether the color grading effect is enabled.
  95143. */
  95144. cameraColorGradingEnabled: boolean;
  95145. /**
  95146. * Gets wether tonemapping is enabled or not.
  95147. */
  95148. /**
  95149. * Sets wether tonemapping is enabled or not
  95150. */
  95151. cameraToneMappingEnabled: boolean;
  95152. /**
  95153. * The camera exposure used on this material.
  95154. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95155. * This corresponds to a photographic exposure.
  95156. */
  95157. /**
  95158. * The camera exposure used on this material.
  95159. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95160. * This corresponds to a photographic exposure.
  95161. */
  95162. cameraExposure: number;
  95163. /**
  95164. * Gets The camera contrast used on this material.
  95165. */
  95166. /**
  95167. * Sets The camera contrast used on this material.
  95168. */
  95169. cameraContrast: number;
  95170. /**
  95171. * Gets the Color Grading 2D Lookup Texture.
  95172. */
  95173. /**
  95174. * Sets the Color Grading 2D Lookup Texture.
  95175. */
  95176. cameraColorGradingTexture: Nullable<BaseTexture>;
  95177. /**
  95178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95180. * 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;
  95181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95182. */
  95183. /**
  95184. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95185. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95186. * 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;
  95187. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95188. */
  95189. cameraColorCurves: Nullable<ColorCurves>;
  95190. /**
  95191. * Custom callback helping to override the default shader used in the material.
  95192. */
  95193. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95194. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95195. protected _worldViewProjectionMatrix: Matrix;
  95196. protected _globalAmbientColor: Color3;
  95197. protected _useLogarithmicDepth: boolean;
  95198. protected _rebuildInParallel: boolean;
  95199. /**
  95200. * Instantiates a new standard material.
  95201. * This is the default material used in Babylon. It is the best trade off between quality
  95202. * and performances.
  95203. * @see http://doc.babylonjs.com/babylon101/materials
  95204. * @param name Define the name of the material in the scene
  95205. * @param scene Define the scene the material belong to
  95206. */
  95207. constructor(name: string, scene: Scene);
  95208. /**
  95209. * Gets a boolean indicating that current material needs to register RTT
  95210. */
  95211. readonly hasRenderTargetTextures: boolean;
  95212. /**
  95213. * Gets the current class name of the material e.g. "StandardMaterial"
  95214. * Mainly use in serialization.
  95215. * @returns the class name
  95216. */
  95217. getClassName(): string;
  95218. /**
  95219. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95220. * You can try switching to logarithmic depth.
  95221. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95222. */
  95223. useLogarithmicDepth: boolean;
  95224. /**
  95225. * Specifies if the material will require alpha blending
  95226. * @returns a boolean specifying if alpha blending is needed
  95227. */
  95228. needAlphaBlending(): boolean;
  95229. /**
  95230. * Specifies if this material should be rendered in alpha test mode
  95231. * @returns a boolean specifying if an alpha test is needed.
  95232. */
  95233. needAlphaTesting(): boolean;
  95234. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95235. /**
  95236. * Get the texture used for alpha test purpose.
  95237. * @returns the diffuse texture in case of the standard material.
  95238. */
  95239. getAlphaTestTexture(): Nullable<BaseTexture>;
  95240. /**
  95241. * Get if the submesh is ready to be used and all its information available.
  95242. * Child classes can use it to update shaders
  95243. * @param mesh defines the mesh to check
  95244. * @param subMesh defines which submesh to check
  95245. * @param useInstances specifies that instances should be used
  95246. * @returns a boolean indicating that the submesh is ready or not
  95247. */
  95248. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95249. /**
  95250. * Builds the material UBO layouts.
  95251. * Used internally during the effect preparation.
  95252. */
  95253. buildUniformLayout(): void;
  95254. /**
  95255. * Unbinds the material from the mesh
  95256. */
  95257. unbind(): void;
  95258. /**
  95259. * Binds the submesh to this material by preparing the effect and shader to draw
  95260. * @param world defines the world transformation matrix
  95261. * @param mesh defines the mesh containing the submesh
  95262. * @param subMesh defines the submesh to bind the material to
  95263. */
  95264. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95265. /**
  95266. * Get the list of animatables in the material.
  95267. * @returns the list of animatables object used in the material
  95268. */
  95269. getAnimatables(): IAnimatable[];
  95270. /**
  95271. * Gets the active textures from the material
  95272. * @returns an array of textures
  95273. */
  95274. getActiveTextures(): BaseTexture[];
  95275. /**
  95276. * Specifies if the material uses a texture
  95277. * @param texture defines the texture to check against the material
  95278. * @returns a boolean specifying if the material uses the texture
  95279. */
  95280. hasTexture(texture: BaseTexture): boolean;
  95281. /**
  95282. * Disposes the material
  95283. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95284. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95285. */
  95286. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95287. /**
  95288. * Makes a duplicate of the material, and gives it a new name
  95289. * @param name defines the new name for the duplicated material
  95290. * @returns the cloned material
  95291. */
  95292. clone(name: string): StandardMaterial;
  95293. /**
  95294. * Serializes this material in a JSON representation
  95295. * @returns the serialized material object
  95296. */
  95297. serialize(): any;
  95298. /**
  95299. * Creates a standard material from parsed material data
  95300. * @param source defines the JSON representation of the material
  95301. * @param scene defines the hosting scene
  95302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95303. * @returns a new standard material
  95304. */
  95305. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95306. /**
  95307. * Are diffuse textures enabled in the application.
  95308. */
  95309. static DiffuseTextureEnabled: boolean;
  95310. /**
  95311. * Are ambient textures enabled in the application.
  95312. */
  95313. static AmbientTextureEnabled: boolean;
  95314. /**
  95315. * Are opacity textures enabled in the application.
  95316. */
  95317. static OpacityTextureEnabled: boolean;
  95318. /**
  95319. * Are reflection textures enabled in the application.
  95320. */
  95321. static ReflectionTextureEnabled: boolean;
  95322. /**
  95323. * Are emissive textures enabled in the application.
  95324. */
  95325. static EmissiveTextureEnabled: boolean;
  95326. /**
  95327. * Are specular textures enabled in the application.
  95328. */
  95329. static SpecularTextureEnabled: boolean;
  95330. /**
  95331. * Are bump textures enabled in the application.
  95332. */
  95333. static BumpTextureEnabled: boolean;
  95334. /**
  95335. * Are lightmap textures enabled in the application.
  95336. */
  95337. static LightmapTextureEnabled: boolean;
  95338. /**
  95339. * Are refraction textures enabled in the application.
  95340. */
  95341. static RefractionTextureEnabled: boolean;
  95342. /**
  95343. * Are color grading textures enabled in the application.
  95344. */
  95345. static ColorGradingTextureEnabled: boolean;
  95346. /**
  95347. * Are fresnels enabled in the application.
  95348. */
  95349. static FresnelEnabled: boolean;
  95350. }
  95351. }
  95352. declare module BABYLON {
  95353. /**
  95354. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95355. *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.
  95356. * The SPS is also a particle system. It provides some methods to manage the particles.
  95357. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95358. *
  95359. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95360. */
  95361. export class SolidParticleSystem implements IDisposable {
  95362. /**
  95363. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95364. * Example : var p = SPS.particles[i];
  95365. */
  95366. particles: SolidParticle[];
  95367. /**
  95368. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95369. */
  95370. nbParticles: number;
  95371. /**
  95372. * If the particles must ever face the camera (default false). Useful for planar particles.
  95373. */
  95374. billboard: boolean;
  95375. /**
  95376. * Recompute normals when adding a shape
  95377. */
  95378. recomputeNormals: boolean;
  95379. /**
  95380. * This a counter ofr your own usage. It's not set by any SPS functions.
  95381. */
  95382. counter: number;
  95383. /**
  95384. * The SPS name. This name is also given to the underlying mesh.
  95385. */
  95386. name: string;
  95387. /**
  95388. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95389. */
  95390. mesh: Mesh;
  95391. /**
  95392. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95393. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95394. */
  95395. vars: any;
  95396. /**
  95397. * This array is populated when the SPS is set as 'pickable'.
  95398. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95399. * Each element of this array is an object `{idx: int, faceId: int}`.
  95400. * `idx` is the picked particle index in the `SPS.particles` array
  95401. * `faceId` is the picked face index counted within this particle.
  95402. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95403. */
  95404. pickedParticles: {
  95405. idx: number;
  95406. faceId: number;
  95407. }[];
  95408. /**
  95409. * This array is populated when `enableDepthSort` is set to true.
  95410. * Each element of this array is an instance of the class DepthSortedParticle.
  95411. */
  95412. depthSortedParticles: DepthSortedParticle[];
  95413. /**
  95414. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95415. * @hidden
  95416. */
  95417. _bSphereOnly: boolean;
  95418. /**
  95419. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95420. * @hidden
  95421. */
  95422. _bSphereRadiusFactor: number;
  95423. private _scene;
  95424. private _positions;
  95425. private _indices;
  95426. private _normals;
  95427. private _colors;
  95428. private _uvs;
  95429. private _indices32;
  95430. private _positions32;
  95431. private _normals32;
  95432. private _fixedNormal32;
  95433. private _colors32;
  95434. private _uvs32;
  95435. private _index;
  95436. private _updatable;
  95437. private _pickable;
  95438. private _isVisibilityBoxLocked;
  95439. private _alwaysVisible;
  95440. private _depthSort;
  95441. private _expandable;
  95442. private _shapeCounter;
  95443. private _copy;
  95444. private _color;
  95445. private _computeParticleColor;
  95446. private _computeParticleTexture;
  95447. private _computeParticleRotation;
  95448. private _computeParticleVertex;
  95449. private _computeBoundingBox;
  95450. private _depthSortParticles;
  95451. private _camera;
  95452. private _mustUnrotateFixedNormals;
  95453. private _particlesIntersect;
  95454. private _needs32Bits;
  95455. private _isNotBuilt;
  95456. private _lastParticleId;
  95457. private _idxOfId;
  95458. private _multimaterialEnabled;
  95459. private _useModelMaterial;
  95460. private _indicesByMaterial;
  95461. private _materialIndexes;
  95462. private _depthSortFunction;
  95463. private _materialSortFunction;
  95464. private _materials;
  95465. private _multimaterial;
  95466. private _materialIndexesById;
  95467. private _defaultMaterial;
  95468. private _autoUpdateSubMeshes;
  95469. /**
  95470. * Creates a SPS (Solid Particle System) object.
  95471. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95472. * @param scene (Scene) is the scene in which the SPS is added.
  95473. * @param options defines the options of the sps e.g.
  95474. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95475. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95476. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95477. * * 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.
  95478. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95479. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95480. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95481. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95482. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95483. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95484. */
  95485. constructor(name: string, scene: Scene, options?: {
  95486. updatable?: boolean;
  95487. isPickable?: boolean;
  95488. enableDepthSort?: boolean;
  95489. particleIntersection?: boolean;
  95490. boundingSphereOnly?: boolean;
  95491. bSphereRadiusFactor?: number;
  95492. expandable?: boolean;
  95493. useModelMaterial?: boolean;
  95494. enableMultiMaterial?: boolean;
  95495. });
  95496. /**
  95497. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95498. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95499. * @returns the created mesh
  95500. */
  95501. buildMesh(): Mesh;
  95502. /**
  95503. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95504. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95505. * Thus the particles generated from `digest()` have their property `position` set yet.
  95506. * @param mesh ( Mesh ) is the mesh to be digested
  95507. * @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
  95508. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95509. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95510. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95511. * @returns the current SPS
  95512. */
  95513. digest(mesh: Mesh, options?: {
  95514. facetNb?: number;
  95515. number?: number;
  95516. delta?: number;
  95517. storage?: [];
  95518. }): SolidParticleSystem;
  95519. /**
  95520. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95521. * @hidden
  95522. */
  95523. private _unrotateFixedNormals;
  95524. /**
  95525. * Resets the temporary working copy particle
  95526. * @hidden
  95527. */
  95528. private _resetCopy;
  95529. /**
  95530. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  95531. * @param p the current index in the positions array to be updated
  95532. * @param ind the current index in the indices array
  95533. * @param shape a Vector3 array, the shape geometry
  95534. * @param positions the positions array to be updated
  95535. * @param meshInd the shape indices array
  95536. * @param indices the indices array to be updated
  95537. * @param meshUV the shape uv array
  95538. * @param uvs the uv array to be updated
  95539. * @param meshCol the shape color array
  95540. * @param colors the color array to be updated
  95541. * @param meshNor the shape normals array
  95542. * @param normals the normals array to be updated
  95543. * @param idx the particle index
  95544. * @param idxInShape the particle index in its shape
  95545. * @param options the addShape() method passed options
  95546. * @model the particle model
  95547. * @hidden
  95548. */
  95549. private _meshBuilder;
  95550. /**
  95551. * Returns a shape Vector3 array from positions float array
  95552. * @param positions float array
  95553. * @returns a vector3 array
  95554. * @hidden
  95555. */
  95556. private _posToShape;
  95557. /**
  95558. * Returns a shapeUV array from a float uvs (array deep copy)
  95559. * @param uvs as a float array
  95560. * @returns a shapeUV array
  95561. * @hidden
  95562. */
  95563. private _uvsToShapeUV;
  95564. /**
  95565. * Adds a new particle object in the particles array
  95566. * @param idx particle index in particles array
  95567. * @param id particle id
  95568. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  95569. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  95570. * @param model particle ModelShape object
  95571. * @param shapeId model shape identifier
  95572. * @param idxInShape index of the particle in the current model
  95573. * @param bInfo model bounding info object
  95574. * @param storage target storage array, if any
  95575. * @hidden
  95576. */
  95577. private _addParticle;
  95578. /**
  95579. * Adds some particles to the SPS from the model shape. Returns the shape id.
  95580. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  95581. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  95582. * @param nb (positive integer) the number of particles to be created from this model
  95583. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  95584. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  95585. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95586. * @returns the number of shapes in the system
  95587. */
  95588. addShape(mesh: Mesh, nb: number, options?: {
  95589. positionFunction?: any;
  95590. vertexFunction?: any;
  95591. storage?: [];
  95592. }): number;
  95593. /**
  95594. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  95595. * @hidden
  95596. */
  95597. private _rebuildParticle;
  95598. /**
  95599. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  95600. * @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.
  95601. * @returns the SPS.
  95602. */
  95603. rebuildMesh(reset?: boolean): SolidParticleSystem;
  95604. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  95605. * Returns an array with the removed particles.
  95606. * 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.
  95607. * The SPS can't be empty so at least one particle needs to remain in place.
  95608. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  95609. * @param start index of the first particle to remove
  95610. * @param end index of the last particle to remove (included)
  95611. * @returns an array populated with the removed particles
  95612. */
  95613. removeParticles(start: number, end: number): SolidParticle[];
  95614. /**
  95615. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  95616. * @param solidParticleArray an array populated with Solid Particles objects
  95617. * @returns the SPS
  95618. */
  95619. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  95620. /**
  95621. * Creates a new particle and modifies the SPS mesh geometry :
  95622. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  95623. * - calls _addParticle() to populate the particle array
  95624. * factorized code from addShape() and insertParticlesFromArray()
  95625. * @param idx particle index in the particles array
  95626. * @param i particle index in its shape
  95627. * @param modelShape particle ModelShape object
  95628. * @param shape shape vertex array
  95629. * @param meshInd shape indices array
  95630. * @param meshUV shape uv array
  95631. * @param meshCol shape color array
  95632. * @param meshNor shape normals array
  95633. * @param bbInfo shape bounding info
  95634. * @param storage target particle storage
  95635. * @options addShape() passed options
  95636. * @hidden
  95637. */
  95638. private _insertNewParticle;
  95639. /**
  95640. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  95641. * This method calls `updateParticle()` for each particle of the SPS.
  95642. * For an animated SPS, it is usually called within the render loop.
  95643. * 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.
  95644. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  95645. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  95646. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  95647. * @returns the SPS.
  95648. */
  95649. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  95650. /**
  95651. * Disposes the SPS.
  95652. */
  95653. dispose(): void;
  95654. /**
  95655. * Returns a SolidParticle object from its identifier : particle.id
  95656. * @param id (integer) the particle Id
  95657. * @returns the searched particle or null if not found in the SPS.
  95658. */
  95659. getParticleById(id: number): Nullable<SolidParticle>;
  95660. /**
  95661. * Returns a new array populated with the particles having the passed shapeId.
  95662. * @param shapeId (integer) the shape identifier
  95663. * @returns a new solid particle array
  95664. */
  95665. getParticlesByShapeId(shapeId: number): SolidParticle[];
  95666. /**
  95667. * Populates the passed array "ref" with the particles having the passed shapeId.
  95668. * @param shapeId the shape identifier
  95669. * @returns the SPS
  95670. * @param ref
  95671. */
  95672. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  95673. /**
  95674. * Computes the required SubMeshes according the materials assigned to the particles.
  95675. * @returns the solid particle system.
  95676. * Does nothing if called before the SPS mesh is built.
  95677. */
  95678. computeSubMeshes(): SolidParticleSystem;
  95679. /**
  95680. * Sorts the solid particles by material when MultiMaterial is enabled.
  95681. * Updates the indices32 array.
  95682. * Updates the indicesByMaterial array.
  95683. * Updates the mesh indices array.
  95684. * @returns the SPS
  95685. * @hidden
  95686. */
  95687. private _sortParticlesByMaterial;
  95688. /**
  95689. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  95690. * @hidden
  95691. */
  95692. private _setMaterialIndexesById;
  95693. /**
  95694. * Returns an array with unique values of Materials from the passed array
  95695. * @param array the material array to be checked and filtered
  95696. * @hidden
  95697. */
  95698. private _filterUniqueMaterialId;
  95699. /**
  95700. * Sets a new Standard Material as _defaultMaterial if not already set.
  95701. * @hidden
  95702. */
  95703. private _setDefaultMaterial;
  95704. /**
  95705. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  95706. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95707. * @returns the SPS.
  95708. */
  95709. refreshVisibleSize(): SolidParticleSystem;
  95710. /**
  95711. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  95712. * @param size the size (float) of the visibility box
  95713. * note : this doesn't lock the SPS mesh bounding box.
  95714. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95715. */
  95716. setVisibilityBox(size: number): void;
  95717. /**
  95718. * Gets whether the SPS as always visible or not
  95719. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95720. */
  95721. /**
  95722. * Sets the SPS as always visible or not
  95723. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95724. */
  95725. isAlwaysVisible: boolean;
  95726. /**
  95727. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95728. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95729. */
  95730. /**
  95731. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  95732. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  95733. */
  95734. isVisibilityBoxLocked: boolean;
  95735. /**
  95736. * Tells to `setParticles()` to compute the particle rotations or not.
  95737. * Default value : true. The SPS is faster when it's set to false.
  95738. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95739. */
  95740. /**
  95741. * Gets if `setParticles()` computes the particle rotations or not.
  95742. * Default value : true. The SPS is faster when it's set to false.
  95743. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  95744. */
  95745. computeParticleRotation: boolean;
  95746. /**
  95747. * Tells to `setParticles()` to compute the particle colors or not.
  95748. * Default value : true. The SPS is faster when it's set to false.
  95749. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95750. */
  95751. /**
  95752. * Gets if `setParticles()` computes the particle colors or not.
  95753. * Default value : true. The SPS is faster when it's set to false.
  95754. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  95755. */
  95756. computeParticleColor: boolean;
  95757. /**
  95758. * Gets if `setParticles()` computes the particle textures or not.
  95759. * Default value : true. The SPS is faster when it's set to false.
  95760. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  95761. */
  95762. computeParticleTexture: boolean;
  95763. /**
  95764. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  95765. * Default value : false. The SPS is faster when it's set to false.
  95766. * Note : the particle custom vertex positions aren't stored values.
  95767. */
  95768. /**
  95769. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  95770. * Default value : false. The SPS is faster when it's set to false.
  95771. * Note : the particle custom vertex positions aren't stored values.
  95772. */
  95773. computeParticleVertex: boolean;
  95774. /**
  95775. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  95776. */
  95777. /**
  95778. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  95779. */
  95780. computeBoundingBox: boolean;
  95781. /**
  95782. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  95783. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95784. * Default : `true`
  95785. */
  95786. /**
  95787. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  95788. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  95789. * Default : `true`
  95790. */
  95791. depthSortParticles: boolean;
  95792. /**
  95793. * Gets if the SPS is created as expandable at construction time.
  95794. * Default : `false`
  95795. */
  95796. readonly expandable: boolean;
  95797. /**
  95798. * Gets if the SPS supports the Multi Materials
  95799. */
  95800. readonly multimaterialEnabled: boolean;
  95801. /**
  95802. * Gets if the SPS uses the model materials for its own multimaterial.
  95803. */
  95804. readonly useModelMaterial: boolean;
  95805. /**
  95806. * The SPS used material array.
  95807. */
  95808. readonly materials: Material[];
  95809. /**
  95810. * Sets the SPS MultiMaterial from the passed materials.
  95811. * Note : the passed array is internally copied and not used then by reference.
  95812. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  95813. */
  95814. setMultiMaterial(materials: Material[]): void;
  95815. /**
  95816. * The SPS computed multimaterial object
  95817. */
  95818. multimaterial: MultiMaterial;
  95819. /**
  95820. * If the subMeshes must be updated on the next call to setParticles()
  95821. */
  95822. autoUpdateSubMeshes: boolean;
  95823. /**
  95824. * This function does nothing. It may be overwritten to set all the particle first values.
  95825. * The SPS doesn't call this function, you may have to call it by your own.
  95826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95827. */
  95828. initParticles(): void;
  95829. /**
  95830. * This function does nothing. It may be overwritten to recycle a particle.
  95831. * The SPS doesn't call this function, you may have to call it by your own.
  95832. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95833. * @param particle The particle to recycle
  95834. * @returns the recycled particle
  95835. */
  95836. recycleParticle(particle: SolidParticle): SolidParticle;
  95837. /**
  95838. * Updates a particle : this function should be overwritten by the user.
  95839. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  95840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  95841. * @example : just set a particle position or velocity and recycle conditions
  95842. * @param particle The particle to update
  95843. * @returns the updated particle
  95844. */
  95845. updateParticle(particle: SolidParticle): SolidParticle;
  95846. /**
  95847. * Updates a vertex of a particle : it can be overwritten by the user.
  95848. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  95849. * @param particle the current particle
  95850. * @param vertex the current index of the current particle
  95851. * @param pt the index of the current vertex in the particle shape
  95852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  95853. * @example : just set a vertex particle position
  95854. * @returns the updated vertex
  95855. */
  95856. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  95857. /**
  95858. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  95859. * This does nothing and may be overwritten by the user.
  95860. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95861. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95862. * @param update the boolean update value actually passed to setParticles()
  95863. */
  95864. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95865. /**
  95866. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  95867. * This will be passed three parameters.
  95868. * This does nothing and may be overwritten by the user.
  95869. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95870. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  95871. * @param update the boolean update value actually passed to setParticles()
  95872. */
  95873. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  95874. }
  95875. }
  95876. declare module BABYLON {
  95877. /**
  95878. * Represents one particle of a solid particle system.
  95879. */
  95880. export class SolidParticle {
  95881. /**
  95882. * particle global index
  95883. */
  95884. idx: number;
  95885. /**
  95886. * particle identifier
  95887. */
  95888. id: number;
  95889. /**
  95890. * The color of the particle
  95891. */
  95892. color: Nullable<Color4>;
  95893. /**
  95894. * The world space position of the particle.
  95895. */
  95896. position: Vector3;
  95897. /**
  95898. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  95899. */
  95900. rotation: Vector3;
  95901. /**
  95902. * The world space rotation quaternion of the particle.
  95903. */
  95904. rotationQuaternion: Nullable<Quaternion>;
  95905. /**
  95906. * The scaling of the particle.
  95907. */
  95908. scaling: Vector3;
  95909. /**
  95910. * The uvs of the particle.
  95911. */
  95912. uvs: Vector4;
  95913. /**
  95914. * The current speed of the particle.
  95915. */
  95916. velocity: Vector3;
  95917. /**
  95918. * The pivot point in the particle local space.
  95919. */
  95920. pivot: Vector3;
  95921. /**
  95922. * Must the particle be translated from its pivot point in its local space ?
  95923. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  95924. * Default : false
  95925. */
  95926. translateFromPivot: boolean;
  95927. /**
  95928. * Is the particle active or not ?
  95929. */
  95930. alive: boolean;
  95931. /**
  95932. * Is the particle visible or not ?
  95933. */
  95934. isVisible: boolean;
  95935. /**
  95936. * Index of this particle in the global "positions" array (Internal use)
  95937. * @hidden
  95938. */
  95939. _pos: number;
  95940. /**
  95941. * @hidden Index of this particle in the global "indices" array (Internal use)
  95942. */
  95943. _ind: number;
  95944. /**
  95945. * @hidden ModelShape of this particle (Internal use)
  95946. */
  95947. _model: ModelShape;
  95948. /**
  95949. * ModelShape id of this particle
  95950. */
  95951. shapeId: number;
  95952. /**
  95953. * Index of the particle in its shape id
  95954. */
  95955. idxInShape: number;
  95956. /**
  95957. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  95958. */
  95959. _modelBoundingInfo: BoundingInfo;
  95960. /**
  95961. * @hidden Particle BoundingInfo object (Internal use)
  95962. */
  95963. _boundingInfo: BoundingInfo;
  95964. /**
  95965. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  95966. */
  95967. _sps: SolidParticleSystem;
  95968. /**
  95969. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  95970. */
  95971. _stillInvisible: boolean;
  95972. /**
  95973. * @hidden Last computed particle rotation matrix
  95974. */
  95975. _rotationMatrix: number[];
  95976. /**
  95977. * Parent particle Id, if any.
  95978. * Default null.
  95979. */
  95980. parentId: Nullable<number>;
  95981. /**
  95982. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  95983. */
  95984. materialIndex: Nullable<number>;
  95985. /**
  95986. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  95987. * The possible values are :
  95988. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  95989. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  95990. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  95991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  95992. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  95993. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  95994. * */
  95995. cullingStrategy: number;
  95996. /**
  95997. * @hidden Internal global position in the SPS.
  95998. */
  95999. _globalPosition: Vector3;
  96000. /**
  96001. * Creates a Solid Particle object.
  96002. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96003. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96004. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96005. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96006. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96007. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96008. * @param shapeId (integer) is the model shape identifier in the SPS.
  96009. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96010. * @param sps defines the sps it is associated to
  96011. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96012. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96013. */
  96014. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96015. /**
  96016. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96017. * @param target the particle target
  96018. * @returns the current particle
  96019. */
  96020. copyToRef(target: SolidParticle): SolidParticle;
  96021. /**
  96022. * Legacy support, changed scale to scaling
  96023. */
  96024. /**
  96025. * Legacy support, changed scale to scaling
  96026. */
  96027. scale: Vector3;
  96028. /**
  96029. * Legacy support, changed quaternion to rotationQuaternion
  96030. */
  96031. /**
  96032. * Legacy support, changed quaternion to rotationQuaternion
  96033. */
  96034. quaternion: Nullable<Quaternion>;
  96035. /**
  96036. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96037. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96038. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96039. * @returns true if it intersects
  96040. */
  96041. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96042. /**
  96043. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96044. * A particle is in the frustum if its bounding box intersects the frustum
  96045. * @param frustumPlanes defines the frustum to test
  96046. * @returns true if the particle is in the frustum planes
  96047. */
  96048. isInFrustum(frustumPlanes: Plane[]): boolean;
  96049. /**
  96050. * get the rotation matrix of the particle
  96051. * @hidden
  96052. */
  96053. getRotationMatrix(m: Matrix): void;
  96054. }
  96055. /**
  96056. * Represents the shape of the model used by one particle of a solid particle system.
  96057. * SPS internal tool, don't use it manually.
  96058. */
  96059. export class ModelShape {
  96060. /**
  96061. * The shape id
  96062. * @hidden
  96063. */
  96064. shapeID: number;
  96065. /**
  96066. * flat array of model positions (internal use)
  96067. * @hidden
  96068. */
  96069. _shape: Vector3[];
  96070. /**
  96071. * flat array of model UVs (internal use)
  96072. * @hidden
  96073. */
  96074. _shapeUV: number[];
  96075. /**
  96076. * color array of the model
  96077. * @hidden
  96078. */
  96079. _shapeColors: number[];
  96080. /**
  96081. * indices array of the model
  96082. * @hidden
  96083. */
  96084. _indices: number[];
  96085. /**
  96086. * normals array of the model
  96087. * @hidden
  96088. */
  96089. _normals: number[];
  96090. /**
  96091. * length of the shape in the model indices array (internal use)
  96092. * @hidden
  96093. */
  96094. _indicesLength: number;
  96095. /**
  96096. * Custom position function (internal use)
  96097. * @hidden
  96098. */
  96099. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96100. /**
  96101. * Custom vertex function (internal use)
  96102. * @hidden
  96103. */
  96104. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96105. /**
  96106. * Model material (internal use)
  96107. * @hidden
  96108. */
  96109. _material: Nullable<Material>;
  96110. /**
  96111. * 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.
  96112. * SPS internal tool, don't use it manually.
  96113. * @hidden
  96114. */
  96115. 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>);
  96116. }
  96117. /**
  96118. * Represents a Depth Sorted Particle in the solid particle system.
  96119. * @hidden
  96120. */
  96121. export class DepthSortedParticle {
  96122. /**
  96123. * Index of the particle in the "indices" array
  96124. */
  96125. ind: number;
  96126. /**
  96127. * Length of the particle shape in the "indices" array
  96128. */
  96129. indicesLength: number;
  96130. /**
  96131. * Squared distance from the particle to the camera
  96132. */
  96133. sqDistance: number;
  96134. /**
  96135. * Material index when used with MultiMaterials
  96136. */
  96137. materialIndex: number;
  96138. /**
  96139. * Creates a new sorted particle
  96140. * @param materialIndex
  96141. */
  96142. constructor(ind: number, indLength: number, materialIndex: number);
  96143. }
  96144. }
  96145. declare module BABYLON {
  96146. /**
  96147. * @hidden
  96148. */
  96149. export class _MeshCollisionData {
  96150. _checkCollisions: boolean;
  96151. _collisionMask: number;
  96152. _collisionGroup: number;
  96153. _collider: Nullable<Collider>;
  96154. _oldPositionForCollisions: Vector3;
  96155. _diffPositionForCollisions: Vector3;
  96156. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96157. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96158. }
  96159. }
  96160. declare module BABYLON {
  96161. /** @hidden */
  96162. class _FacetDataStorage {
  96163. facetPositions: Vector3[];
  96164. facetNormals: Vector3[];
  96165. facetPartitioning: number[][];
  96166. facetNb: number;
  96167. partitioningSubdivisions: number;
  96168. partitioningBBoxRatio: number;
  96169. facetDataEnabled: boolean;
  96170. facetParameters: any;
  96171. bbSize: Vector3;
  96172. subDiv: {
  96173. max: number;
  96174. X: number;
  96175. Y: number;
  96176. Z: number;
  96177. };
  96178. facetDepthSort: boolean;
  96179. facetDepthSortEnabled: boolean;
  96180. depthSortedIndices: IndicesArray;
  96181. depthSortedFacets: {
  96182. ind: number;
  96183. sqDistance: number;
  96184. }[];
  96185. facetDepthSortFunction: (f1: {
  96186. ind: number;
  96187. sqDistance: number;
  96188. }, f2: {
  96189. ind: number;
  96190. sqDistance: number;
  96191. }) => number;
  96192. facetDepthSortFrom: Vector3;
  96193. facetDepthSortOrigin: Vector3;
  96194. invertedMatrix: Matrix;
  96195. }
  96196. /**
  96197. * @hidden
  96198. **/
  96199. class _InternalAbstractMeshDataInfo {
  96200. _hasVertexAlpha: boolean;
  96201. _useVertexColors: boolean;
  96202. _numBoneInfluencers: number;
  96203. _applyFog: boolean;
  96204. _receiveShadows: boolean;
  96205. _facetData: _FacetDataStorage;
  96206. _visibility: number;
  96207. _skeleton: Nullable<Skeleton>;
  96208. _layerMask: number;
  96209. _computeBonesUsingShaders: boolean;
  96210. _isActive: boolean;
  96211. _onlyForInstances: boolean;
  96212. _isActiveIntermediate: boolean;
  96213. _onlyForInstancesIntermediate: boolean;
  96214. _actAsRegularMesh: boolean;
  96215. }
  96216. /**
  96217. * Class used to store all common mesh properties
  96218. */
  96219. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96220. /** No occlusion */
  96221. static OCCLUSION_TYPE_NONE: number;
  96222. /** Occlusion set to optimisitic */
  96223. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96224. /** Occlusion set to strict */
  96225. static OCCLUSION_TYPE_STRICT: number;
  96226. /** Use an accurante occlusion algorithm */
  96227. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96228. /** Use a conservative occlusion algorithm */
  96229. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96230. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96231. * Test order :
  96232. * Is the bounding sphere outside the frustum ?
  96233. * If not, are the bounding box vertices outside the frustum ?
  96234. * It not, then the cullable object is in the frustum.
  96235. */
  96236. static readonly CULLINGSTRATEGY_STANDARD: number;
  96237. /** Culling strategy : Bounding Sphere Only.
  96238. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96239. * It's also less accurate than the standard because some not visible objects can still be selected.
  96240. * Test : is the bounding sphere outside the frustum ?
  96241. * If not, then the cullable object is in the frustum.
  96242. */
  96243. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96244. /** Culling strategy : Optimistic Inclusion.
  96245. * This in an inclusion test first, then the standard exclusion test.
  96246. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96247. * 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.
  96248. * Anyway, it's as accurate as the standard strategy.
  96249. * Test :
  96250. * Is the cullable object bounding sphere center in the frustum ?
  96251. * If not, apply the default culling strategy.
  96252. */
  96253. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96254. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96255. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96256. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96257. * 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.
  96258. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96259. * Test :
  96260. * Is the cullable object bounding sphere center in the frustum ?
  96261. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96262. */
  96263. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96264. /**
  96265. * No billboard
  96266. */
  96267. static readonly BILLBOARDMODE_NONE: number;
  96268. /** Billboard on X axis */
  96269. static readonly BILLBOARDMODE_X: number;
  96270. /** Billboard on Y axis */
  96271. static readonly BILLBOARDMODE_Y: number;
  96272. /** Billboard on Z axis */
  96273. static readonly BILLBOARDMODE_Z: number;
  96274. /** Billboard on all axes */
  96275. static readonly BILLBOARDMODE_ALL: number;
  96276. /** Billboard on using position instead of orientation */
  96277. static readonly BILLBOARDMODE_USE_POSITION: number;
  96278. /** @hidden */
  96279. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96280. /**
  96281. * The culling strategy to use to check whether the mesh must be rendered or not.
  96282. * This value can be changed at any time and will be used on the next render mesh selection.
  96283. * The possible values are :
  96284. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96285. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96286. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96287. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96288. * Please read each static variable documentation to get details about the culling process.
  96289. * */
  96290. cullingStrategy: number;
  96291. /**
  96292. * Gets the number of facets in the mesh
  96293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96294. */
  96295. readonly facetNb: number;
  96296. /**
  96297. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96299. */
  96300. partitioningSubdivisions: number;
  96301. /**
  96302. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96303. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96305. */
  96306. partitioningBBoxRatio: number;
  96307. /**
  96308. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96309. * Works only for updatable meshes.
  96310. * Doesn't work with multi-materials
  96311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96312. */
  96313. mustDepthSortFacets: boolean;
  96314. /**
  96315. * The location (Vector3) where the facet depth sort must be computed from.
  96316. * By default, the active camera position.
  96317. * Used only when facet depth sort is enabled
  96318. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96319. */
  96320. facetDepthSortFrom: Vector3;
  96321. /**
  96322. * gets a boolean indicating if facetData is enabled
  96323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96324. */
  96325. readonly isFacetDataEnabled: boolean;
  96326. /** @hidden */
  96327. _updateNonUniformScalingState(value: boolean): boolean;
  96328. /**
  96329. * An event triggered when this mesh collides with another one
  96330. */
  96331. onCollideObservable: Observable<AbstractMesh>;
  96332. /** Set a function to call when this mesh collides with another one */
  96333. onCollide: () => void;
  96334. /**
  96335. * An event triggered when the collision's position changes
  96336. */
  96337. onCollisionPositionChangeObservable: Observable<Vector3>;
  96338. /** Set a function to call when the collision's position changes */
  96339. onCollisionPositionChange: () => void;
  96340. /**
  96341. * An event triggered when material is changed
  96342. */
  96343. onMaterialChangedObservable: Observable<AbstractMesh>;
  96344. /**
  96345. * Gets or sets the orientation for POV movement & rotation
  96346. */
  96347. definedFacingForward: boolean;
  96348. /** @hidden */
  96349. _occlusionQuery: Nullable<WebGLQuery>;
  96350. /** @hidden */
  96351. _renderingGroup: Nullable<RenderingGroup>;
  96352. /**
  96353. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96354. */
  96355. /**
  96356. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96357. */
  96358. visibility: number;
  96359. /** Gets or sets the alpha index used to sort transparent meshes
  96360. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96361. */
  96362. alphaIndex: number;
  96363. /**
  96364. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96365. */
  96366. isVisible: boolean;
  96367. /**
  96368. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96369. */
  96370. isPickable: boolean;
  96371. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96372. showSubMeshesBoundingBox: boolean;
  96373. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96374. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96375. */
  96376. isBlocker: boolean;
  96377. /**
  96378. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96379. */
  96380. enablePointerMoveEvents: boolean;
  96381. /**
  96382. * Specifies the rendering group id for this mesh (0 by default)
  96383. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96384. */
  96385. renderingGroupId: number;
  96386. private _material;
  96387. /** Gets or sets current material */
  96388. material: Nullable<Material>;
  96389. /**
  96390. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96391. * @see http://doc.babylonjs.com/babylon101/shadows
  96392. */
  96393. receiveShadows: boolean;
  96394. /** Defines color to use when rendering outline */
  96395. outlineColor: Color3;
  96396. /** Define width to use when rendering outline */
  96397. outlineWidth: number;
  96398. /** Defines color to use when rendering overlay */
  96399. overlayColor: Color3;
  96400. /** Defines alpha to use when rendering overlay */
  96401. overlayAlpha: number;
  96402. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96403. hasVertexAlpha: boolean;
  96404. /** 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) */
  96405. useVertexColors: boolean;
  96406. /**
  96407. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96408. */
  96409. computeBonesUsingShaders: boolean;
  96410. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96411. numBoneInfluencers: number;
  96412. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96413. applyFog: boolean;
  96414. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96415. useOctreeForRenderingSelection: boolean;
  96416. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96417. useOctreeForPicking: boolean;
  96418. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96419. useOctreeForCollisions: boolean;
  96420. /**
  96421. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96422. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96423. */
  96424. layerMask: number;
  96425. /**
  96426. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96427. */
  96428. alwaysSelectAsActiveMesh: boolean;
  96429. /**
  96430. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96431. */
  96432. doNotSyncBoundingInfo: boolean;
  96433. /**
  96434. * Gets or sets the current action manager
  96435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96436. */
  96437. actionManager: Nullable<AbstractActionManager>;
  96438. private _meshCollisionData;
  96439. /**
  96440. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96441. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96442. */
  96443. ellipsoid: Vector3;
  96444. /**
  96445. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96447. */
  96448. ellipsoidOffset: Vector3;
  96449. /**
  96450. * Gets or sets a collision mask used to mask collisions (default is -1).
  96451. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96452. */
  96453. collisionMask: number;
  96454. /**
  96455. * Gets or sets the current collision group mask (-1 by default).
  96456. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96457. */
  96458. collisionGroup: number;
  96459. /**
  96460. * Defines edge width used when edgesRenderer is enabled
  96461. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96462. */
  96463. edgesWidth: number;
  96464. /**
  96465. * Defines edge color used when edgesRenderer is enabled
  96466. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96467. */
  96468. edgesColor: Color4;
  96469. /** @hidden */
  96470. _edgesRenderer: Nullable<IEdgesRenderer>;
  96471. /** @hidden */
  96472. _masterMesh: Nullable<AbstractMesh>;
  96473. /** @hidden */
  96474. _boundingInfo: Nullable<BoundingInfo>;
  96475. /** @hidden */
  96476. _renderId: number;
  96477. /**
  96478. * Gets or sets the list of subMeshes
  96479. * @see http://doc.babylonjs.com/how_to/multi_materials
  96480. */
  96481. subMeshes: SubMesh[];
  96482. /** @hidden */
  96483. _intersectionsInProgress: AbstractMesh[];
  96484. /** @hidden */
  96485. _unIndexed: boolean;
  96486. /** @hidden */
  96487. _lightSources: Light[];
  96488. /** Gets the list of lights affecting that mesh */
  96489. readonly lightSources: Light[];
  96490. /** @hidden */
  96491. readonly _positions: Nullable<Vector3[]>;
  96492. /** @hidden */
  96493. _waitingData: {
  96494. lods: Nullable<any>;
  96495. actions: Nullable<any>;
  96496. freezeWorldMatrix: Nullable<boolean>;
  96497. };
  96498. /** @hidden */
  96499. _bonesTransformMatrices: Nullable<Float32Array>;
  96500. /** @hidden */
  96501. _transformMatrixTexture: Nullable<RawTexture>;
  96502. /**
  96503. * Gets or sets a skeleton to apply skining transformations
  96504. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96505. */
  96506. skeleton: Nullable<Skeleton>;
  96507. /**
  96508. * An event triggered when the mesh is rebuilt.
  96509. */
  96510. onRebuildObservable: Observable<AbstractMesh>;
  96511. /**
  96512. * Creates a new AbstractMesh
  96513. * @param name defines the name of the mesh
  96514. * @param scene defines the hosting scene
  96515. */
  96516. constructor(name: string, scene?: Nullable<Scene>);
  96517. /**
  96518. * Returns the string "AbstractMesh"
  96519. * @returns "AbstractMesh"
  96520. */
  96521. getClassName(): string;
  96522. /**
  96523. * Gets a string representation of the current mesh
  96524. * @param fullDetails defines a boolean indicating if full details must be included
  96525. * @returns a string representation of the current mesh
  96526. */
  96527. toString(fullDetails?: boolean): string;
  96528. /**
  96529. * @hidden
  96530. */
  96531. protected _getEffectiveParent(): Nullable<Node>;
  96532. /** @hidden */
  96533. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  96534. /** @hidden */
  96535. _rebuild(): void;
  96536. /** @hidden */
  96537. _resyncLightSources(): void;
  96538. /** @hidden */
  96539. _resyncLightSource(light: Light): void;
  96540. /** @hidden */
  96541. _unBindEffect(): void;
  96542. /** @hidden */
  96543. _removeLightSource(light: Light, dispose: boolean): void;
  96544. private _markSubMeshesAsDirty;
  96545. /** @hidden */
  96546. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  96547. /** @hidden */
  96548. _markSubMeshesAsAttributesDirty(): void;
  96549. /** @hidden */
  96550. _markSubMeshesAsMiscDirty(): void;
  96551. /**
  96552. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  96553. */
  96554. scaling: Vector3;
  96555. /**
  96556. * Returns true if the mesh is blocked. Implemented by child classes
  96557. */
  96558. readonly isBlocked: boolean;
  96559. /**
  96560. * Returns the mesh itself by default. Implemented by child classes
  96561. * @param camera defines the camera to use to pick the right LOD level
  96562. * @returns the currentAbstractMesh
  96563. */
  96564. getLOD(camera: Camera): Nullable<AbstractMesh>;
  96565. /**
  96566. * Returns 0 by default. Implemented by child classes
  96567. * @returns an integer
  96568. */
  96569. getTotalVertices(): number;
  96570. /**
  96571. * Returns a positive integer : the total number of indices in this mesh geometry.
  96572. * @returns the numner of indices or zero if the mesh has no geometry.
  96573. */
  96574. getTotalIndices(): number;
  96575. /**
  96576. * Returns null by default. Implemented by child classes
  96577. * @returns null
  96578. */
  96579. getIndices(): Nullable<IndicesArray>;
  96580. /**
  96581. * Returns the array of the requested vertex data kind. Implemented by child classes
  96582. * @param kind defines the vertex data kind to use
  96583. * @returns null
  96584. */
  96585. getVerticesData(kind: string): Nullable<FloatArray>;
  96586. /**
  96587. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96588. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96589. * Note that a new underlying VertexBuffer object is created each call.
  96590. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96591. * @param kind defines vertex data kind:
  96592. * * VertexBuffer.PositionKind
  96593. * * VertexBuffer.UVKind
  96594. * * VertexBuffer.UV2Kind
  96595. * * VertexBuffer.UV3Kind
  96596. * * VertexBuffer.UV4Kind
  96597. * * VertexBuffer.UV5Kind
  96598. * * VertexBuffer.UV6Kind
  96599. * * VertexBuffer.ColorKind
  96600. * * VertexBuffer.MatricesIndicesKind
  96601. * * VertexBuffer.MatricesIndicesExtraKind
  96602. * * VertexBuffer.MatricesWeightsKind
  96603. * * VertexBuffer.MatricesWeightsExtraKind
  96604. * @param data defines the data source
  96605. * @param updatable defines if the data must be flagged as updatable (or static)
  96606. * @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
  96607. * @returns the current mesh
  96608. */
  96609. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96610. /**
  96611. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96612. * If the mesh has no geometry, it is simply returned as it is.
  96613. * @param kind defines vertex data kind:
  96614. * * VertexBuffer.PositionKind
  96615. * * VertexBuffer.UVKind
  96616. * * VertexBuffer.UV2Kind
  96617. * * VertexBuffer.UV3Kind
  96618. * * VertexBuffer.UV4Kind
  96619. * * VertexBuffer.UV5Kind
  96620. * * VertexBuffer.UV6Kind
  96621. * * VertexBuffer.ColorKind
  96622. * * VertexBuffer.MatricesIndicesKind
  96623. * * VertexBuffer.MatricesIndicesExtraKind
  96624. * * VertexBuffer.MatricesWeightsKind
  96625. * * VertexBuffer.MatricesWeightsExtraKind
  96626. * @param data defines the data source
  96627. * @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
  96628. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  96629. * @returns the current mesh
  96630. */
  96631. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  96632. /**
  96633. * Sets the mesh indices,
  96634. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96635. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  96636. * @param totalVertices Defines the total number of vertices
  96637. * @returns the current mesh
  96638. */
  96639. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  96640. /**
  96641. * Gets a boolean indicating if specific vertex data is present
  96642. * @param kind defines the vertex data kind to use
  96643. * @returns true is data kind is present
  96644. */
  96645. isVerticesDataPresent(kind: string): boolean;
  96646. /**
  96647. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  96648. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  96649. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  96650. * @returns a BoundingInfo
  96651. */
  96652. getBoundingInfo(): BoundingInfo;
  96653. /**
  96654. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96655. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96656. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96657. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96658. * @returns the current mesh
  96659. */
  96660. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  96661. /**
  96662. * Overwrite the current bounding info
  96663. * @param boundingInfo defines the new bounding info
  96664. * @returns the current mesh
  96665. */
  96666. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  96667. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  96668. readonly useBones: boolean;
  96669. /** @hidden */
  96670. _preActivate(): void;
  96671. /** @hidden */
  96672. _preActivateForIntermediateRendering(renderId: number): void;
  96673. /** @hidden */
  96674. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96675. /** @hidden */
  96676. _postActivate(): void;
  96677. /** @hidden */
  96678. _freeze(): void;
  96679. /** @hidden */
  96680. _unFreeze(): void;
  96681. /**
  96682. * Gets the current world matrix
  96683. * @returns a Matrix
  96684. */
  96685. getWorldMatrix(): Matrix;
  96686. /** @hidden */
  96687. _getWorldMatrixDeterminant(): number;
  96688. /**
  96689. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  96690. */
  96691. readonly isAnInstance: boolean;
  96692. /**
  96693. * Gets a boolean indicating if this mesh has instances
  96694. */
  96695. readonly hasInstances: boolean;
  96696. /**
  96697. * Perform relative position change from the point of view of behind the front of the mesh.
  96698. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96699. * Supports definition of mesh facing forward or backward
  96700. * @param amountRight defines the distance on the right axis
  96701. * @param amountUp defines the distance on the up axis
  96702. * @param amountForward defines the distance on the forward axis
  96703. * @returns the current mesh
  96704. */
  96705. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  96706. /**
  96707. * Calculate relative position change from the point of view of behind the front of the mesh.
  96708. * This is performed taking into account the meshes current rotation, so you do not have to care.
  96709. * Supports definition of mesh facing forward or backward
  96710. * @param amountRight defines the distance on the right axis
  96711. * @param amountUp defines the distance on the up axis
  96712. * @param amountForward defines the distance on the forward axis
  96713. * @returns the new displacement vector
  96714. */
  96715. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  96716. /**
  96717. * Perform relative rotation change from the point of view of behind the front of the mesh.
  96718. * Supports definition of mesh facing forward or backward
  96719. * @param flipBack defines the flip
  96720. * @param twirlClockwise defines the twirl
  96721. * @param tiltRight defines the tilt
  96722. * @returns the current mesh
  96723. */
  96724. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  96725. /**
  96726. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  96727. * Supports definition of mesh facing forward or backward.
  96728. * @param flipBack defines the flip
  96729. * @param twirlClockwise defines the twirl
  96730. * @param tiltRight defines the tilt
  96731. * @returns the new rotation vector
  96732. */
  96733. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  96734. /**
  96735. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96736. * This means the mesh underlying bounding box and sphere are recomputed.
  96737. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96738. * @returns the current mesh
  96739. */
  96740. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  96741. /** @hidden */
  96742. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  96743. /** @hidden */
  96744. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  96745. /** @hidden */
  96746. _updateBoundingInfo(): AbstractMesh;
  96747. /** @hidden */
  96748. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  96749. /** @hidden */
  96750. protected _afterComputeWorldMatrix(): void;
  96751. /** @hidden */
  96752. readonly _effectiveMesh: AbstractMesh;
  96753. /**
  96754. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96755. * A mesh is in the frustum if its bounding box intersects the frustum
  96756. * @param frustumPlanes defines the frustum to test
  96757. * @returns true if the mesh is in the frustum planes
  96758. */
  96759. isInFrustum(frustumPlanes: Plane[]): boolean;
  96760. /**
  96761. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  96762. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  96763. * @param frustumPlanes defines the frustum to test
  96764. * @returns true if the mesh is completely in the frustum planes
  96765. */
  96766. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96767. /**
  96768. * True if the mesh intersects another mesh or a SolidParticle object
  96769. * @param mesh defines a target mesh or SolidParticle to test
  96770. * @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)
  96771. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  96772. * @returns true if there is an intersection
  96773. */
  96774. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  96775. /**
  96776. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  96777. * @param point defines the point to test
  96778. * @returns true if there is an intersection
  96779. */
  96780. intersectsPoint(point: Vector3): boolean;
  96781. /**
  96782. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  96783. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96784. */
  96785. checkCollisions: boolean;
  96786. /**
  96787. * Gets Collider object used to compute collisions (not physics)
  96788. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96789. */
  96790. readonly collider: Nullable<Collider>;
  96791. /**
  96792. * Move the mesh using collision engine
  96793. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96794. * @param displacement defines the requested displacement vector
  96795. * @returns the current mesh
  96796. */
  96797. moveWithCollisions(displacement: Vector3): AbstractMesh;
  96798. private _onCollisionPositionChange;
  96799. /** @hidden */
  96800. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  96801. /** @hidden */
  96802. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  96803. /** @hidden */
  96804. _checkCollision(collider: Collider): AbstractMesh;
  96805. /** @hidden */
  96806. _generatePointsArray(): boolean;
  96807. /**
  96808. * Checks if the passed Ray intersects with the mesh
  96809. * @param ray defines the ray to use
  96810. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  96811. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96812. * @returns the picking info
  96813. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  96814. */
  96815. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  96816. /**
  96817. * Clones the current mesh
  96818. * @param name defines the mesh name
  96819. * @param newParent defines the new mesh parent
  96820. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  96821. * @returns the new mesh
  96822. */
  96823. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  96824. /**
  96825. * Disposes all the submeshes of the current meshnp
  96826. * @returns the current mesh
  96827. */
  96828. releaseSubMeshes(): AbstractMesh;
  96829. /**
  96830. * Releases resources associated with this abstract mesh.
  96831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96833. */
  96834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96835. /**
  96836. * Adds the passed mesh as a child to the current mesh
  96837. * @param mesh defines the child mesh
  96838. * @returns the current mesh
  96839. */
  96840. addChild(mesh: AbstractMesh): AbstractMesh;
  96841. /**
  96842. * Removes the passed mesh from the current mesh children list
  96843. * @param mesh defines the child mesh
  96844. * @returns the current mesh
  96845. */
  96846. removeChild(mesh: AbstractMesh): AbstractMesh;
  96847. /** @hidden */
  96848. private _initFacetData;
  96849. /**
  96850. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  96851. * This method can be called within the render loop.
  96852. * 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
  96853. * @returns the current mesh
  96854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96855. */
  96856. updateFacetData(): AbstractMesh;
  96857. /**
  96858. * Returns the facetLocalNormals array.
  96859. * The normals are expressed in the mesh local spac
  96860. * @returns an array of Vector3
  96861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96862. */
  96863. getFacetLocalNormals(): Vector3[];
  96864. /**
  96865. * Returns the facetLocalPositions array.
  96866. * The facet positions are expressed in the mesh local space
  96867. * @returns an array of Vector3
  96868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96869. */
  96870. getFacetLocalPositions(): Vector3[];
  96871. /**
  96872. * Returns the facetLocalPartioning array
  96873. * @returns an array of array of numbers
  96874. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96875. */
  96876. getFacetLocalPartitioning(): number[][];
  96877. /**
  96878. * Returns the i-th facet position in the world system.
  96879. * This method allocates a new Vector3 per call
  96880. * @param i defines the facet index
  96881. * @returns a new Vector3
  96882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96883. */
  96884. getFacetPosition(i: number): Vector3;
  96885. /**
  96886. * Sets the reference Vector3 with the i-th facet position in the world system
  96887. * @param i defines the facet index
  96888. * @param ref defines the target vector
  96889. * @returns the current mesh
  96890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96891. */
  96892. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  96893. /**
  96894. * Returns the i-th facet normal in the world system.
  96895. * This method allocates a new Vector3 per call
  96896. * @param i defines the facet index
  96897. * @returns a new Vector3
  96898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96899. */
  96900. getFacetNormal(i: number): Vector3;
  96901. /**
  96902. * Sets the reference Vector3 with the i-th facet normal in the world system
  96903. * @param i defines the facet index
  96904. * @param ref defines the target vector
  96905. * @returns the current mesh
  96906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96907. */
  96908. getFacetNormalToRef(i: number, ref: Vector3): this;
  96909. /**
  96910. * 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)
  96911. * @param x defines x coordinate
  96912. * @param y defines y coordinate
  96913. * @param z defines z coordinate
  96914. * @returns the array of facet indexes
  96915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96916. */
  96917. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  96918. /**
  96919. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  96920. * @param projected sets as the (x,y,z) world projection on the facet
  96921. * @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
  96922. * @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
  96923. * @param x defines x coordinate
  96924. * @param y defines y coordinate
  96925. * @param z defines z coordinate
  96926. * @returns the face index if found (or null instead)
  96927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96928. */
  96929. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96930. /**
  96931. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  96932. * @param projected sets as the (x,y,z) local projection on the facet
  96933. * @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
  96934. * @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
  96935. * @param x defines x coordinate
  96936. * @param y defines y coordinate
  96937. * @param z defines z coordinate
  96938. * @returns the face index if found (or null instead)
  96939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96940. */
  96941. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  96942. /**
  96943. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  96944. * @returns the parameters
  96945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96946. */
  96947. getFacetDataParameters(): any;
  96948. /**
  96949. * Disables the feature FacetData and frees the related memory
  96950. * @returns the current mesh
  96951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  96952. */
  96953. disableFacetData(): AbstractMesh;
  96954. /**
  96955. * Updates the AbstractMesh indices array
  96956. * @param indices defines the data source
  96957. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  96958. * @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)
  96959. * @returns the current mesh
  96960. */
  96961. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  96962. /**
  96963. * Creates new normals data for the mesh
  96964. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  96965. * @returns the current mesh
  96966. */
  96967. createNormals(updatable: boolean): AbstractMesh;
  96968. /**
  96969. * Align the mesh with a normal
  96970. * @param normal defines the normal to use
  96971. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  96972. * @returns the current mesh
  96973. */
  96974. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  96975. /** @hidden */
  96976. _checkOcclusionQuery(): boolean;
  96977. /**
  96978. * Disables the mesh edge rendering mode
  96979. * @returns the currentAbstractMesh
  96980. */
  96981. disableEdgesRendering(): AbstractMesh;
  96982. /**
  96983. * Enables the edge rendering mode on the mesh.
  96984. * This mode makes the mesh edges visible
  96985. * @param epsilon defines the maximal distance between two angles to detect a face
  96986. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96987. * @returns the currentAbstractMesh
  96988. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96989. */
  96990. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96991. }
  96992. }
  96993. declare module BABYLON {
  96994. /**
  96995. * Interface used to define ActionEvent
  96996. */
  96997. export interface IActionEvent {
  96998. /** The mesh or sprite that triggered the action */
  96999. source: any;
  97000. /** The X mouse cursor position at the time of the event */
  97001. pointerX: number;
  97002. /** The Y mouse cursor position at the time of the event */
  97003. pointerY: number;
  97004. /** The mesh that is currently pointed at (can be null) */
  97005. meshUnderPointer: Nullable<AbstractMesh>;
  97006. /** the original (browser) event that triggered the ActionEvent */
  97007. sourceEvent?: any;
  97008. /** additional data for the event */
  97009. additionalData?: any;
  97010. }
  97011. /**
  97012. * ActionEvent is the event being sent when an action is triggered.
  97013. */
  97014. export class ActionEvent implements IActionEvent {
  97015. /** The mesh or sprite that triggered the action */
  97016. source: any;
  97017. /** The X mouse cursor position at the time of the event */
  97018. pointerX: number;
  97019. /** The Y mouse cursor position at the time of the event */
  97020. pointerY: number;
  97021. /** The mesh that is currently pointed at (can be null) */
  97022. meshUnderPointer: Nullable<AbstractMesh>;
  97023. /** the original (browser) event that triggered the ActionEvent */
  97024. sourceEvent?: any;
  97025. /** additional data for the event */
  97026. additionalData?: any;
  97027. /**
  97028. * Creates a new ActionEvent
  97029. * @param source The mesh or sprite that triggered the action
  97030. * @param pointerX The X mouse cursor position at the time of the event
  97031. * @param pointerY The Y mouse cursor position at the time of the event
  97032. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97033. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97034. * @param additionalData additional data for the event
  97035. */
  97036. constructor(
  97037. /** The mesh or sprite that triggered the action */
  97038. source: any,
  97039. /** The X mouse cursor position at the time of the event */
  97040. pointerX: number,
  97041. /** The Y mouse cursor position at the time of the event */
  97042. pointerY: number,
  97043. /** The mesh that is currently pointed at (can be null) */
  97044. meshUnderPointer: Nullable<AbstractMesh>,
  97045. /** the original (browser) event that triggered the ActionEvent */
  97046. sourceEvent?: any,
  97047. /** additional data for the event */
  97048. additionalData?: any);
  97049. /**
  97050. * Helper function to auto-create an ActionEvent from a source mesh.
  97051. * @param source The source mesh that triggered the event
  97052. * @param evt The original (browser) event
  97053. * @param additionalData additional data for the event
  97054. * @returns the new ActionEvent
  97055. */
  97056. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97057. /**
  97058. * Helper function to auto-create an ActionEvent from a source sprite
  97059. * @param source The source sprite that triggered the event
  97060. * @param scene Scene associated with the sprite
  97061. * @param evt The original (browser) event
  97062. * @param additionalData additional data for the event
  97063. * @returns the new ActionEvent
  97064. */
  97065. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97066. /**
  97067. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97068. * @param scene the scene where the event occurred
  97069. * @param evt The original (browser) event
  97070. * @returns the new ActionEvent
  97071. */
  97072. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97073. /**
  97074. * Helper function to auto-create an ActionEvent from a primitive
  97075. * @param prim defines the target primitive
  97076. * @param pointerPos defines the pointer position
  97077. * @param evt The original (browser) event
  97078. * @param additionalData additional data for the event
  97079. * @returns the new ActionEvent
  97080. */
  97081. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97082. }
  97083. }
  97084. declare module BABYLON {
  97085. /**
  97086. * Abstract class used to decouple action Manager from scene and meshes.
  97087. * Do not instantiate.
  97088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97089. */
  97090. export abstract class AbstractActionManager implements IDisposable {
  97091. /** Gets the list of active triggers */
  97092. static Triggers: {
  97093. [key: string]: number;
  97094. };
  97095. /** Gets the cursor to use when hovering items */
  97096. hoverCursor: string;
  97097. /** Gets the list of actions */
  97098. actions: IAction[];
  97099. /**
  97100. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97101. */
  97102. isRecursive: boolean;
  97103. /**
  97104. * Releases all associated resources
  97105. */
  97106. abstract dispose(): void;
  97107. /**
  97108. * Does this action manager has pointer triggers
  97109. */
  97110. abstract readonly hasPointerTriggers: boolean;
  97111. /**
  97112. * Does this action manager has pick triggers
  97113. */
  97114. abstract readonly hasPickTriggers: boolean;
  97115. /**
  97116. * Process a specific trigger
  97117. * @param trigger defines the trigger to process
  97118. * @param evt defines the event details to be processed
  97119. */
  97120. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97121. /**
  97122. * Does this action manager handles actions of any of the given triggers
  97123. * @param triggers defines the triggers to be tested
  97124. * @return a boolean indicating whether one (or more) of the triggers is handled
  97125. */
  97126. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97127. /**
  97128. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97129. * speed.
  97130. * @param triggerA defines the trigger to be tested
  97131. * @param triggerB defines the trigger to be tested
  97132. * @return a boolean indicating whether one (or more) of the triggers is handled
  97133. */
  97134. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97135. /**
  97136. * Does this action manager handles actions of a given trigger
  97137. * @param trigger defines the trigger to be tested
  97138. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97139. * @return whether the trigger is handled
  97140. */
  97141. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97142. /**
  97143. * Serialize this manager to a JSON object
  97144. * @param name defines the property name to store this manager
  97145. * @returns a JSON representation of this manager
  97146. */
  97147. abstract serialize(name: string): any;
  97148. /**
  97149. * Registers an action to this action manager
  97150. * @param action defines the action to be registered
  97151. * @return the action amended (prepared) after registration
  97152. */
  97153. abstract registerAction(action: IAction): Nullable<IAction>;
  97154. /**
  97155. * Unregisters an action to this action manager
  97156. * @param action defines the action to be unregistered
  97157. * @return a boolean indicating whether the action has been unregistered
  97158. */
  97159. abstract unregisterAction(action: IAction): Boolean;
  97160. /**
  97161. * Does exist one action manager with at least one trigger
  97162. **/
  97163. static readonly HasTriggers: boolean;
  97164. /**
  97165. * Does exist one action manager with at least one pick trigger
  97166. **/
  97167. static readonly HasPickTriggers: boolean;
  97168. /**
  97169. * Does exist one action manager that handles actions of a given trigger
  97170. * @param trigger defines the trigger to be tested
  97171. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97172. **/
  97173. static HasSpecificTrigger(trigger: number): boolean;
  97174. }
  97175. }
  97176. declare module BABYLON {
  97177. /**
  97178. * Defines how a node can be built from a string name.
  97179. */
  97180. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97181. /**
  97182. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97183. */
  97184. export class Node implements IBehaviorAware<Node> {
  97185. /** @hidden */
  97186. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97187. private static _NodeConstructors;
  97188. /**
  97189. * Add a new node constructor
  97190. * @param type defines the type name of the node to construct
  97191. * @param constructorFunc defines the constructor function
  97192. */
  97193. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97194. /**
  97195. * Returns a node constructor based on type name
  97196. * @param type defines the type name
  97197. * @param name defines the new node name
  97198. * @param scene defines the hosting scene
  97199. * @param options defines optional options to transmit to constructors
  97200. * @returns the new constructor or null
  97201. */
  97202. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97203. /**
  97204. * Gets or sets the name of the node
  97205. */
  97206. name: string;
  97207. /**
  97208. * Gets or sets the id of the node
  97209. */
  97210. id: string;
  97211. /**
  97212. * Gets or sets the unique id of the node
  97213. */
  97214. uniqueId: number;
  97215. /**
  97216. * Gets or sets a string used to store user defined state for the node
  97217. */
  97218. state: string;
  97219. /**
  97220. * Gets or sets an object used to store user defined information for the node
  97221. */
  97222. metadata: any;
  97223. /**
  97224. * For internal use only. Please do not use.
  97225. */
  97226. reservedDataStore: any;
  97227. /**
  97228. * List of inspectable custom properties (used by the Inspector)
  97229. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97230. */
  97231. inspectableCustomProperties: IInspectable[];
  97232. private _doNotSerialize;
  97233. /**
  97234. * Gets or sets a boolean used to define if the node must be serialized
  97235. */
  97236. doNotSerialize: boolean;
  97237. /** @hidden */
  97238. _isDisposed: boolean;
  97239. /**
  97240. * Gets a list of Animations associated with the node
  97241. */
  97242. animations: Animation[];
  97243. protected _ranges: {
  97244. [name: string]: Nullable<AnimationRange>;
  97245. };
  97246. /**
  97247. * Callback raised when the node is ready to be used
  97248. */
  97249. onReady: Nullable<(node: Node) => void>;
  97250. private _isEnabled;
  97251. private _isParentEnabled;
  97252. private _isReady;
  97253. /** @hidden */
  97254. _currentRenderId: number;
  97255. private _parentUpdateId;
  97256. /** @hidden */
  97257. _childUpdateId: number;
  97258. /** @hidden */
  97259. _waitingParentId: Nullable<string>;
  97260. /** @hidden */
  97261. _scene: Scene;
  97262. /** @hidden */
  97263. _cache: any;
  97264. private _parentNode;
  97265. private _children;
  97266. /** @hidden */
  97267. _worldMatrix: Matrix;
  97268. /** @hidden */
  97269. _worldMatrixDeterminant: number;
  97270. /** @hidden */
  97271. _worldMatrixDeterminantIsDirty: boolean;
  97272. /** @hidden */
  97273. private _sceneRootNodesIndex;
  97274. /**
  97275. * Gets a boolean indicating if the node has been disposed
  97276. * @returns true if the node was disposed
  97277. */
  97278. isDisposed(): boolean;
  97279. /**
  97280. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97281. * @see https://doc.babylonjs.com/how_to/parenting
  97282. */
  97283. parent: Nullable<Node>;
  97284. /** @hidden */
  97285. _addToSceneRootNodes(): void;
  97286. /** @hidden */
  97287. _removeFromSceneRootNodes(): void;
  97288. private _animationPropertiesOverride;
  97289. /**
  97290. * Gets or sets the animation properties override
  97291. */
  97292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97293. /**
  97294. * Gets a string idenfifying the name of the class
  97295. * @returns "Node" string
  97296. */
  97297. getClassName(): string;
  97298. /** @hidden */
  97299. readonly _isNode: boolean;
  97300. /**
  97301. * An event triggered when the mesh is disposed
  97302. */
  97303. onDisposeObservable: Observable<Node>;
  97304. private _onDisposeObserver;
  97305. /**
  97306. * Sets a callback that will be raised when the node will be disposed
  97307. */
  97308. onDispose: () => void;
  97309. /**
  97310. * Creates a new Node
  97311. * @param name the name and id to be given to this node
  97312. * @param scene the scene this node will be added to
  97313. */
  97314. constructor(name: string, scene?: Nullable<Scene>);
  97315. /**
  97316. * Gets the scene of the node
  97317. * @returns a scene
  97318. */
  97319. getScene(): Scene;
  97320. /**
  97321. * Gets the engine of the node
  97322. * @returns a Engine
  97323. */
  97324. getEngine(): Engine;
  97325. private _behaviors;
  97326. /**
  97327. * Attach a behavior to the node
  97328. * @see http://doc.babylonjs.com/features/behaviour
  97329. * @param behavior defines the behavior to attach
  97330. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97331. * @returns the current Node
  97332. */
  97333. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97334. /**
  97335. * Remove an attached behavior
  97336. * @see http://doc.babylonjs.com/features/behaviour
  97337. * @param behavior defines the behavior to attach
  97338. * @returns the current Node
  97339. */
  97340. removeBehavior(behavior: Behavior<Node>): Node;
  97341. /**
  97342. * Gets the list of attached behaviors
  97343. * @see http://doc.babylonjs.com/features/behaviour
  97344. */
  97345. readonly behaviors: Behavior<Node>[];
  97346. /**
  97347. * Gets an attached behavior by name
  97348. * @param name defines the name of the behavior to look for
  97349. * @see http://doc.babylonjs.com/features/behaviour
  97350. * @returns null if behavior was not found else the requested behavior
  97351. */
  97352. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97353. /**
  97354. * Returns the latest update of the World matrix
  97355. * @returns a Matrix
  97356. */
  97357. getWorldMatrix(): Matrix;
  97358. /** @hidden */
  97359. _getWorldMatrixDeterminant(): number;
  97360. /**
  97361. * Returns directly the latest state of the mesh World matrix.
  97362. * A Matrix is returned.
  97363. */
  97364. readonly worldMatrixFromCache: Matrix;
  97365. /** @hidden */
  97366. _initCache(): void;
  97367. /** @hidden */
  97368. updateCache(force?: boolean): void;
  97369. /** @hidden */
  97370. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97371. /** @hidden */
  97372. _updateCache(ignoreParentClass?: boolean): void;
  97373. /** @hidden */
  97374. _isSynchronized(): boolean;
  97375. /** @hidden */
  97376. _markSyncedWithParent(): void;
  97377. /** @hidden */
  97378. isSynchronizedWithParent(): boolean;
  97379. /** @hidden */
  97380. isSynchronized(): boolean;
  97381. /**
  97382. * Is this node ready to be used/rendered
  97383. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97384. * @return true if the node is ready
  97385. */
  97386. isReady(completeCheck?: boolean): boolean;
  97387. /**
  97388. * Is this node enabled?
  97389. * 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
  97390. * @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
  97391. * @return whether this node (and its parent) is enabled
  97392. */
  97393. isEnabled(checkAncestors?: boolean): boolean;
  97394. /** @hidden */
  97395. protected _syncParentEnabledState(): void;
  97396. /**
  97397. * Set the enabled state of this node
  97398. * @param value defines the new enabled state
  97399. */
  97400. setEnabled(value: boolean): void;
  97401. /**
  97402. * Is this node a descendant of the given node?
  97403. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97404. * @param ancestor defines the parent node to inspect
  97405. * @returns a boolean indicating if this node is a descendant of the given node
  97406. */
  97407. isDescendantOf(ancestor: Node): boolean;
  97408. /** @hidden */
  97409. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97410. /**
  97411. * Will return all nodes that have this node as ascendant
  97412. * @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
  97413. * @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
  97414. * @return all children nodes of all types
  97415. */
  97416. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97417. /**
  97418. * Get all child-meshes of this node
  97419. * @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)
  97420. * @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
  97421. * @returns an array of AbstractMesh
  97422. */
  97423. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97424. /**
  97425. * Get all direct children of this node
  97426. * @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
  97427. * @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)
  97428. * @returns an array of Node
  97429. */
  97430. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97431. /** @hidden */
  97432. _setReady(state: boolean): void;
  97433. /**
  97434. * Get an animation by name
  97435. * @param name defines the name of the animation to look for
  97436. * @returns null if not found else the requested animation
  97437. */
  97438. getAnimationByName(name: string): Nullable<Animation>;
  97439. /**
  97440. * Creates an animation range for this node
  97441. * @param name defines the name of the range
  97442. * @param from defines the starting key
  97443. * @param to defines the end key
  97444. */
  97445. createAnimationRange(name: string, from: number, to: number): void;
  97446. /**
  97447. * Delete a specific animation range
  97448. * @param name defines the name of the range to delete
  97449. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97450. */
  97451. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97452. /**
  97453. * Get an animation range by name
  97454. * @param name defines the name of the animation range to look for
  97455. * @returns null if not found else the requested animation range
  97456. */
  97457. getAnimationRange(name: string): Nullable<AnimationRange>;
  97458. /**
  97459. * Gets the list of all animation ranges defined on this node
  97460. * @returns an array
  97461. */
  97462. getAnimationRanges(): Nullable<AnimationRange>[];
  97463. /**
  97464. * Will start the animation sequence
  97465. * @param name defines the range frames for animation sequence
  97466. * @param loop defines if the animation should loop (false by default)
  97467. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97468. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97469. * @returns the object created for this animation. If range does not exist, it will return null
  97470. */
  97471. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97472. /**
  97473. * Serialize animation ranges into a JSON compatible object
  97474. * @returns serialization object
  97475. */
  97476. serializeAnimationRanges(): any;
  97477. /**
  97478. * Computes the world matrix of the node
  97479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97480. * @returns the world matrix
  97481. */
  97482. computeWorldMatrix(force?: boolean): Matrix;
  97483. /**
  97484. * Releases resources associated with this node.
  97485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97487. */
  97488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97489. /**
  97490. * Parse animation range data from a serialization object and store them into a given node
  97491. * @param node defines where to store the animation ranges
  97492. * @param parsedNode defines the serialization object to read data from
  97493. * @param scene defines the hosting scene
  97494. */
  97495. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97496. /**
  97497. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97498. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97499. * @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
  97500. * @returns the new bounding vectors
  97501. */
  97502. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97503. min: Vector3;
  97504. max: Vector3;
  97505. };
  97506. }
  97507. }
  97508. declare module BABYLON {
  97509. /**
  97510. * @hidden
  97511. */
  97512. export class _IAnimationState {
  97513. key: number;
  97514. repeatCount: number;
  97515. workValue?: any;
  97516. loopMode?: number;
  97517. offsetValue?: any;
  97518. highLimitValue?: any;
  97519. }
  97520. /**
  97521. * Class used to store any kind of animation
  97522. */
  97523. export class Animation {
  97524. /**Name of the animation */
  97525. name: string;
  97526. /**Property to animate */
  97527. targetProperty: string;
  97528. /**The frames per second of the animation */
  97529. framePerSecond: number;
  97530. /**The data type of the animation */
  97531. dataType: number;
  97532. /**The loop mode of the animation */
  97533. loopMode?: number | undefined;
  97534. /**Specifies if blending should be enabled */
  97535. enableBlending?: boolean | undefined;
  97536. /**
  97537. * Use matrix interpolation instead of using direct key value when animating matrices
  97538. */
  97539. static AllowMatricesInterpolation: boolean;
  97540. /**
  97541. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  97542. */
  97543. static AllowMatrixDecomposeForInterpolation: boolean;
  97544. /**
  97545. * Stores the key frames of the animation
  97546. */
  97547. private _keys;
  97548. /**
  97549. * Stores the easing function of the animation
  97550. */
  97551. private _easingFunction;
  97552. /**
  97553. * @hidden Internal use only
  97554. */
  97555. _runtimeAnimations: RuntimeAnimation[];
  97556. /**
  97557. * The set of event that will be linked to this animation
  97558. */
  97559. private _events;
  97560. /**
  97561. * Stores an array of target property paths
  97562. */
  97563. targetPropertyPath: string[];
  97564. /**
  97565. * Stores the blending speed of the animation
  97566. */
  97567. blendingSpeed: number;
  97568. /**
  97569. * Stores the animation ranges for the animation
  97570. */
  97571. private _ranges;
  97572. /**
  97573. * @hidden Internal use
  97574. */
  97575. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  97576. /**
  97577. * Sets up an animation
  97578. * @param property The property to animate
  97579. * @param animationType The animation type to apply
  97580. * @param framePerSecond The frames per second of the animation
  97581. * @param easingFunction The easing function used in the animation
  97582. * @returns The created animation
  97583. */
  97584. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  97585. /**
  97586. * Create and start an animation on a node
  97587. * @param name defines the name of the global animation that will be run on all nodes
  97588. * @param node defines the root node where the animation will take place
  97589. * @param targetProperty defines property to animate
  97590. * @param framePerSecond defines the number of frame per second yo use
  97591. * @param totalFrame defines the number of frames in total
  97592. * @param from defines the initial value
  97593. * @param to defines the final value
  97594. * @param loopMode defines which loop mode you want to use (off by default)
  97595. * @param easingFunction defines the easing function to use (linear by default)
  97596. * @param onAnimationEnd defines the callback to call when animation end
  97597. * @returns the animatable created for this animation
  97598. */
  97599. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97600. /**
  97601. * Create and start an animation on a node and its descendants
  97602. * @param name defines the name of the global animation that will be run on all nodes
  97603. * @param node defines the root node where the animation will take place
  97604. * @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
  97605. * @param targetProperty defines property to animate
  97606. * @param framePerSecond defines the number of frame per second to use
  97607. * @param totalFrame defines the number of frames in total
  97608. * @param from defines the initial value
  97609. * @param to defines the final value
  97610. * @param loopMode defines which loop mode you want to use (off by default)
  97611. * @param easingFunction defines the easing function to use (linear by default)
  97612. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97613. * @returns the list of animatables created for all nodes
  97614. * @example https://www.babylonjs-playground.com/#MH0VLI
  97615. */
  97616. 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[]>;
  97617. /**
  97618. * Creates a new animation, merges it with the existing animations and starts it
  97619. * @param name Name of the animation
  97620. * @param node Node which contains the scene that begins the animations
  97621. * @param targetProperty Specifies which property to animate
  97622. * @param framePerSecond The frames per second of the animation
  97623. * @param totalFrame The total number of frames
  97624. * @param from The frame at the beginning of the animation
  97625. * @param to The frame at the end of the animation
  97626. * @param loopMode Specifies the loop mode of the animation
  97627. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  97628. * @param onAnimationEnd Callback to run once the animation is complete
  97629. * @returns Nullable animation
  97630. */
  97631. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  97632. /**
  97633. * Transition property of an host to the target Value
  97634. * @param property The property to transition
  97635. * @param targetValue The target Value of the property
  97636. * @param host The object where the property to animate belongs
  97637. * @param scene Scene used to run the animation
  97638. * @param frameRate Framerate (in frame/s) to use
  97639. * @param transition The transition type we want to use
  97640. * @param duration The duration of the animation, in milliseconds
  97641. * @param onAnimationEnd Callback trigger at the end of the animation
  97642. * @returns Nullable animation
  97643. */
  97644. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  97645. /**
  97646. * Return the array of runtime animations currently using this animation
  97647. */
  97648. readonly runtimeAnimations: RuntimeAnimation[];
  97649. /**
  97650. * Specifies if any of the runtime animations are currently running
  97651. */
  97652. readonly hasRunningRuntimeAnimations: boolean;
  97653. /**
  97654. * Initializes the animation
  97655. * @param name Name of the animation
  97656. * @param targetProperty Property to animate
  97657. * @param framePerSecond The frames per second of the animation
  97658. * @param dataType The data type of the animation
  97659. * @param loopMode The loop mode of the animation
  97660. * @param enableBlending Specifies if blending should be enabled
  97661. */
  97662. constructor(
  97663. /**Name of the animation */
  97664. name: string,
  97665. /**Property to animate */
  97666. targetProperty: string,
  97667. /**The frames per second of the animation */
  97668. framePerSecond: number,
  97669. /**The data type of the animation */
  97670. dataType: number,
  97671. /**The loop mode of the animation */
  97672. loopMode?: number | undefined,
  97673. /**Specifies if blending should be enabled */
  97674. enableBlending?: boolean | undefined);
  97675. /**
  97676. * Converts the animation to a string
  97677. * @param fullDetails support for multiple levels of logging within scene loading
  97678. * @returns String form of the animation
  97679. */
  97680. toString(fullDetails?: boolean): string;
  97681. /**
  97682. * Add an event to this animation
  97683. * @param event Event to add
  97684. */
  97685. addEvent(event: AnimationEvent): void;
  97686. /**
  97687. * Remove all events found at the given frame
  97688. * @param frame The frame to remove events from
  97689. */
  97690. removeEvents(frame: number): void;
  97691. /**
  97692. * Retrieves all the events from the animation
  97693. * @returns Events from the animation
  97694. */
  97695. getEvents(): AnimationEvent[];
  97696. /**
  97697. * Creates an animation range
  97698. * @param name Name of the animation range
  97699. * @param from Starting frame of the animation range
  97700. * @param to Ending frame of the animation
  97701. */
  97702. createRange(name: string, from: number, to: number): void;
  97703. /**
  97704. * Deletes an animation range by name
  97705. * @param name Name of the animation range to delete
  97706. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  97707. */
  97708. deleteRange(name: string, deleteFrames?: boolean): void;
  97709. /**
  97710. * Gets the animation range by name, or null if not defined
  97711. * @param name Name of the animation range
  97712. * @returns Nullable animation range
  97713. */
  97714. getRange(name: string): Nullable<AnimationRange>;
  97715. /**
  97716. * Gets the key frames from the animation
  97717. * @returns The key frames of the animation
  97718. */
  97719. getKeys(): Array<IAnimationKey>;
  97720. /**
  97721. * Gets the highest frame rate of the animation
  97722. * @returns Highest frame rate of the animation
  97723. */
  97724. getHighestFrame(): number;
  97725. /**
  97726. * Gets the easing function of the animation
  97727. * @returns Easing function of the animation
  97728. */
  97729. getEasingFunction(): IEasingFunction;
  97730. /**
  97731. * Sets the easing function of the animation
  97732. * @param easingFunction A custom mathematical formula for animation
  97733. */
  97734. setEasingFunction(easingFunction: EasingFunction): void;
  97735. /**
  97736. * Interpolates a scalar linearly
  97737. * @param startValue Start value of the animation curve
  97738. * @param endValue End value of the animation curve
  97739. * @param gradient Scalar amount to interpolate
  97740. * @returns Interpolated scalar value
  97741. */
  97742. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  97743. /**
  97744. * Interpolates a scalar cubically
  97745. * @param startValue Start value of the animation curve
  97746. * @param outTangent End tangent of the animation
  97747. * @param endValue End value of the animation curve
  97748. * @param inTangent Start tangent of the animation curve
  97749. * @param gradient Scalar amount to interpolate
  97750. * @returns Interpolated scalar value
  97751. */
  97752. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  97753. /**
  97754. * Interpolates a quaternion using a spherical linear interpolation
  97755. * @param startValue Start value of the animation curve
  97756. * @param endValue End value of the animation curve
  97757. * @param gradient Scalar amount to interpolate
  97758. * @returns Interpolated quaternion value
  97759. */
  97760. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  97761. /**
  97762. * Interpolates a quaternion cubically
  97763. * @param startValue Start value of the animation curve
  97764. * @param outTangent End tangent of the animation curve
  97765. * @param endValue End value of the animation curve
  97766. * @param inTangent Start tangent of the animation curve
  97767. * @param gradient Scalar amount to interpolate
  97768. * @returns Interpolated quaternion value
  97769. */
  97770. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  97771. /**
  97772. * Interpolates a Vector3 linearl
  97773. * @param startValue Start value of the animation curve
  97774. * @param endValue End value of the animation curve
  97775. * @param gradient Scalar amount to interpolate
  97776. * @returns Interpolated scalar value
  97777. */
  97778. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  97779. /**
  97780. * Interpolates a Vector3 cubically
  97781. * @param startValue Start value of the animation curve
  97782. * @param outTangent End tangent of the animation
  97783. * @param endValue End value of the animation curve
  97784. * @param inTangent Start tangent of the animation curve
  97785. * @param gradient Scalar amount to interpolate
  97786. * @returns InterpolatedVector3 value
  97787. */
  97788. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  97789. /**
  97790. * Interpolates a Vector2 linearly
  97791. * @param startValue Start value of the animation curve
  97792. * @param endValue End value of the animation curve
  97793. * @param gradient Scalar amount to interpolate
  97794. * @returns Interpolated Vector2 value
  97795. */
  97796. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  97797. /**
  97798. * Interpolates a Vector2 cubically
  97799. * @param startValue Start value of the animation curve
  97800. * @param outTangent End tangent of the animation
  97801. * @param endValue End value of the animation curve
  97802. * @param inTangent Start tangent of the animation curve
  97803. * @param gradient Scalar amount to interpolate
  97804. * @returns Interpolated Vector2 value
  97805. */
  97806. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  97807. /**
  97808. * Interpolates a size linearly
  97809. * @param startValue Start value of the animation curve
  97810. * @param endValue End value of the animation curve
  97811. * @param gradient Scalar amount to interpolate
  97812. * @returns Interpolated Size value
  97813. */
  97814. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  97815. /**
  97816. * Interpolates a Color3 linearly
  97817. * @param startValue Start value of the animation curve
  97818. * @param endValue End value of the animation curve
  97819. * @param gradient Scalar amount to interpolate
  97820. * @returns Interpolated Color3 value
  97821. */
  97822. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  97823. /**
  97824. * Interpolates a Color4 linearly
  97825. * @param startValue Start value of the animation curve
  97826. * @param endValue End value of the animation curve
  97827. * @param gradient Scalar amount to interpolate
  97828. * @returns Interpolated Color3 value
  97829. */
  97830. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  97831. /**
  97832. * @hidden Internal use only
  97833. */
  97834. _getKeyValue(value: any): any;
  97835. /**
  97836. * @hidden Internal use only
  97837. */
  97838. _interpolate(currentFrame: number, state: _IAnimationState): any;
  97839. /**
  97840. * Defines the function to use to interpolate matrices
  97841. * @param startValue defines the start matrix
  97842. * @param endValue defines the end matrix
  97843. * @param gradient defines the gradient between both matrices
  97844. * @param result defines an optional target matrix where to store the interpolation
  97845. * @returns the interpolated matrix
  97846. */
  97847. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  97848. /**
  97849. * Makes a copy of the animation
  97850. * @returns Cloned animation
  97851. */
  97852. clone(): Animation;
  97853. /**
  97854. * Sets the key frames of the animation
  97855. * @param values The animation key frames to set
  97856. */
  97857. setKeys(values: Array<IAnimationKey>): void;
  97858. /**
  97859. * Serializes the animation to an object
  97860. * @returns Serialized object
  97861. */
  97862. serialize(): any;
  97863. /**
  97864. * Float animation type
  97865. */
  97866. static readonly ANIMATIONTYPE_FLOAT: number;
  97867. /**
  97868. * Vector3 animation type
  97869. */
  97870. static readonly ANIMATIONTYPE_VECTOR3: number;
  97871. /**
  97872. * Quaternion animation type
  97873. */
  97874. static readonly ANIMATIONTYPE_QUATERNION: number;
  97875. /**
  97876. * Matrix animation type
  97877. */
  97878. static readonly ANIMATIONTYPE_MATRIX: number;
  97879. /**
  97880. * Color3 animation type
  97881. */
  97882. static readonly ANIMATIONTYPE_COLOR3: number;
  97883. /**
  97884. * Color3 animation type
  97885. */
  97886. static readonly ANIMATIONTYPE_COLOR4: number;
  97887. /**
  97888. * Vector2 animation type
  97889. */
  97890. static readonly ANIMATIONTYPE_VECTOR2: number;
  97891. /**
  97892. * Size animation type
  97893. */
  97894. static readonly ANIMATIONTYPE_SIZE: number;
  97895. /**
  97896. * Relative Loop Mode
  97897. */
  97898. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  97899. /**
  97900. * Cycle Loop Mode
  97901. */
  97902. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  97903. /**
  97904. * Constant Loop Mode
  97905. */
  97906. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  97907. /** @hidden */
  97908. static _UniversalLerp(left: any, right: any, amount: number): any;
  97909. /**
  97910. * Parses an animation object and creates an animation
  97911. * @param parsedAnimation Parsed animation object
  97912. * @returns Animation object
  97913. */
  97914. static Parse(parsedAnimation: any): Animation;
  97915. /**
  97916. * Appends the serialized animations from the source animations
  97917. * @param source Source containing the animations
  97918. * @param destination Target to store the animations
  97919. */
  97920. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97921. }
  97922. }
  97923. declare module BABYLON {
  97924. /**
  97925. * Interface containing an array of animations
  97926. */
  97927. export interface IAnimatable {
  97928. /**
  97929. * Array of animations
  97930. */
  97931. animations: Nullable<Array<Animation>>;
  97932. }
  97933. }
  97934. declare module BABYLON {
  97935. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  97936. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97937. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97938. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97939. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97940. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97941. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97942. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97943. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97944. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97945. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97946. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97947. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97948. /**
  97949. * Decorator used to define property that can be serialized as reference to a camera
  97950. * @param sourceName defines the name of the property to decorate
  97951. */
  97952. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  97953. /**
  97954. * Class used to help serialization objects
  97955. */
  97956. export class SerializationHelper {
  97957. /** @hidden */
  97958. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  97959. /** @hidden */
  97960. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  97961. /** @hidden */
  97962. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  97963. /** @hidden */
  97964. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  97965. /**
  97966. * Appends the serialized animations from the source animations
  97967. * @param source Source containing the animations
  97968. * @param destination Target to store the animations
  97969. */
  97970. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  97971. /**
  97972. * Static function used to serialized a specific entity
  97973. * @param entity defines the entity to serialize
  97974. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97975. * @returns a JSON compatible object representing the serialization of the entity
  97976. */
  97977. static Serialize<T>(entity: T, serializationObject?: any): any;
  97978. /**
  97979. * Creates a new entity from a serialization data object
  97980. * @param creationFunction defines a function used to instanciated the new entity
  97981. * @param source defines the source serialization data
  97982. * @param scene defines the hosting scene
  97983. * @param rootUrl defines the root url for resources
  97984. * @returns a new entity
  97985. */
  97986. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  97987. /**
  97988. * Clones an object
  97989. * @param creationFunction defines the function used to instanciate the new object
  97990. * @param source defines the source object
  97991. * @returns the cloned object
  97992. */
  97993. static Clone<T>(creationFunction: () => T, source: T): T;
  97994. /**
  97995. * Instanciates a new object based on a source one (some data will be shared between both object)
  97996. * @param creationFunction defines the function used to instanciate the new object
  97997. * @param source defines the source object
  97998. * @returns the new object
  97999. */
  98000. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98001. }
  98002. }
  98003. declare module BABYLON {
  98004. /**
  98005. * Class used to manipulate GUIDs
  98006. */
  98007. export class GUID {
  98008. /**
  98009. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98010. * Be aware Math.random() could cause collisions, but:
  98011. * "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"
  98012. * @returns a pseudo random id
  98013. */
  98014. static RandomId(): string;
  98015. }
  98016. }
  98017. declare module BABYLON {
  98018. /**
  98019. * Base class of all the textures in babylon.
  98020. * It groups all the common properties the materials, post process, lights... might need
  98021. * in order to make a correct use of the texture.
  98022. */
  98023. export class BaseTexture implements IAnimatable {
  98024. /**
  98025. * Default anisotropic filtering level for the application.
  98026. * It is set to 4 as a good tradeoff between perf and quality.
  98027. */
  98028. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98029. /**
  98030. * Gets or sets the unique id of the texture
  98031. */
  98032. uniqueId: number;
  98033. /**
  98034. * Define the name of the texture.
  98035. */
  98036. name: string;
  98037. /**
  98038. * Gets or sets an object used to store user defined information.
  98039. */
  98040. metadata: any;
  98041. /**
  98042. * For internal use only. Please do not use.
  98043. */
  98044. reservedDataStore: any;
  98045. private _hasAlpha;
  98046. /**
  98047. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98048. */
  98049. hasAlpha: boolean;
  98050. /**
  98051. * Defines if the alpha value should be determined via the rgb values.
  98052. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98053. */
  98054. getAlphaFromRGB: boolean;
  98055. /**
  98056. * Intensity or strength of the texture.
  98057. * It is commonly used by materials to fine tune the intensity of the texture
  98058. */
  98059. level: number;
  98060. /**
  98061. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98062. * This is part of the texture as textures usually maps to one uv set.
  98063. */
  98064. coordinatesIndex: number;
  98065. private _coordinatesMode;
  98066. /**
  98067. * How a texture is mapped.
  98068. *
  98069. * | Value | Type | Description |
  98070. * | ----- | ----------------------------------- | ----------- |
  98071. * | 0 | EXPLICIT_MODE | |
  98072. * | 1 | SPHERICAL_MODE | |
  98073. * | 2 | PLANAR_MODE | |
  98074. * | 3 | CUBIC_MODE | |
  98075. * | 4 | PROJECTION_MODE | |
  98076. * | 5 | SKYBOX_MODE | |
  98077. * | 6 | INVCUBIC_MODE | |
  98078. * | 7 | EQUIRECTANGULAR_MODE | |
  98079. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98080. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98081. */
  98082. coordinatesMode: number;
  98083. /**
  98084. * | Value | Type | Description |
  98085. * | ----- | ------------------ | ----------- |
  98086. * | 0 | CLAMP_ADDRESSMODE | |
  98087. * | 1 | WRAP_ADDRESSMODE | |
  98088. * | 2 | MIRROR_ADDRESSMODE | |
  98089. */
  98090. wrapU: number;
  98091. /**
  98092. * | Value | Type | Description |
  98093. * | ----- | ------------------ | ----------- |
  98094. * | 0 | CLAMP_ADDRESSMODE | |
  98095. * | 1 | WRAP_ADDRESSMODE | |
  98096. * | 2 | MIRROR_ADDRESSMODE | |
  98097. */
  98098. wrapV: number;
  98099. /**
  98100. * | Value | Type | Description |
  98101. * | ----- | ------------------ | ----------- |
  98102. * | 0 | CLAMP_ADDRESSMODE | |
  98103. * | 1 | WRAP_ADDRESSMODE | |
  98104. * | 2 | MIRROR_ADDRESSMODE | |
  98105. */
  98106. wrapR: number;
  98107. /**
  98108. * With compliant hardware and browser (supporting anisotropic filtering)
  98109. * this defines the level of anisotropic filtering in the texture.
  98110. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98111. */
  98112. anisotropicFilteringLevel: number;
  98113. /**
  98114. * Define if the texture is a cube texture or if false a 2d texture.
  98115. */
  98116. isCube: boolean;
  98117. /**
  98118. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98119. */
  98120. is3D: boolean;
  98121. /**
  98122. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98123. */
  98124. is2DArray: boolean;
  98125. /**
  98126. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98127. * HDR texture are usually stored in linear space.
  98128. * This only impacts the PBR and Background materials
  98129. */
  98130. gammaSpace: boolean;
  98131. /**
  98132. * Gets or sets whether or not the texture contains RGBD data.
  98133. */
  98134. isRGBD: boolean;
  98135. /**
  98136. * Is Z inverted in the texture (useful in a cube texture).
  98137. */
  98138. invertZ: boolean;
  98139. /**
  98140. * Are mip maps generated for this texture or not.
  98141. */
  98142. readonly noMipmap: boolean;
  98143. /**
  98144. * @hidden
  98145. */
  98146. lodLevelInAlpha: boolean;
  98147. /**
  98148. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98149. */
  98150. lodGenerationOffset: number;
  98151. /**
  98152. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98153. */
  98154. lodGenerationScale: number;
  98155. /**
  98156. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98157. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98158. * average roughness values.
  98159. */
  98160. linearSpecularLOD: boolean;
  98161. /**
  98162. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98163. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98164. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98165. */
  98166. irradianceTexture: Nullable<BaseTexture>;
  98167. /**
  98168. * Define if the texture is a render target.
  98169. */
  98170. isRenderTarget: boolean;
  98171. /**
  98172. * Define the unique id of the texture in the scene.
  98173. */
  98174. readonly uid: string;
  98175. /**
  98176. * Return a string representation of the texture.
  98177. * @returns the texture as a string
  98178. */
  98179. toString(): string;
  98180. /**
  98181. * Get the class name of the texture.
  98182. * @returns "BaseTexture"
  98183. */
  98184. getClassName(): string;
  98185. /**
  98186. * Define the list of animation attached to the texture.
  98187. */
  98188. animations: Animation[];
  98189. /**
  98190. * An event triggered when the texture is disposed.
  98191. */
  98192. onDisposeObservable: Observable<BaseTexture>;
  98193. private _onDisposeObserver;
  98194. /**
  98195. * Callback triggered when the texture has been disposed.
  98196. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98197. */
  98198. onDispose: () => void;
  98199. /**
  98200. * Define the current state of the loading sequence when in delayed load mode.
  98201. */
  98202. delayLoadState: number;
  98203. private _scene;
  98204. /** @hidden */
  98205. _texture: Nullable<InternalTexture>;
  98206. private _uid;
  98207. /**
  98208. * Define if the texture is preventinga material to render or not.
  98209. * If not and the texture is not ready, the engine will use a default black texture instead.
  98210. */
  98211. readonly isBlocking: boolean;
  98212. /**
  98213. * Instantiates a new BaseTexture.
  98214. * Base class of all the textures in babylon.
  98215. * It groups all the common properties the materials, post process, lights... might need
  98216. * in order to make a correct use of the texture.
  98217. * @param scene Define the scene the texture blongs to
  98218. */
  98219. constructor(scene: Nullable<Scene>);
  98220. /**
  98221. * Get the scene the texture belongs to.
  98222. * @returns the scene or null if undefined
  98223. */
  98224. getScene(): Nullable<Scene>;
  98225. /**
  98226. * Get the texture transform matrix used to offset tile the texture for istance.
  98227. * @returns the transformation matrix
  98228. */
  98229. getTextureMatrix(): Matrix;
  98230. /**
  98231. * Get the texture reflection matrix used to rotate/transform the reflection.
  98232. * @returns the reflection matrix
  98233. */
  98234. getReflectionTextureMatrix(): Matrix;
  98235. /**
  98236. * Get the underlying lower level texture from Babylon.
  98237. * @returns the insternal texture
  98238. */
  98239. getInternalTexture(): Nullable<InternalTexture>;
  98240. /**
  98241. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98242. * @returns true if ready or not blocking
  98243. */
  98244. isReadyOrNotBlocking(): boolean;
  98245. /**
  98246. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98247. * @returns true if fully ready
  98248. */
  98249. isReady(): boolean;
  98250. private _cachedSize;
  98251. /**
  98252. * Get the size of the texture.
  98253. * @returns the texture size.
  98254. */
  98255. getSize(): ISize;
  98256. /**
  98257. * Get the base size of the texture.
  98258. * It can be different from the size if the texture has been resized for POT for instance
  98259. * @returns the base size
  98260. */
  98261. getBaseSize(): ISize;
  98262. /**
  98263. * Update the sampling mode of the texture.
  98264. * Default is Trilinear mode.
  98265. *
  98266. * | Value | Type | Description |
  98267. * | ----- | ------------------ | ----------- |
  98268. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98269. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98270. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98271. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98272. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98273. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98274. * | 7 | NEAREST_LINEAR | |
  98275. * | 8 | NEAREST_NEAREST | |
  98276. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98277. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98278. * | 11 | LINEAR_LINEAR | |
  98279. * | 12 | LINEAR_NEAREST | |
  98280. *
  98281. * > _mag_: magnification filter (close to the viewer)
  98282. * > _min_: minification filter (far from the viewer)
  98283. * > _mip_: filter used between mip map levels
  98284. *@param samplingMode Define the new sampling mode of the texture
  98285. */
  98286. updateSamplingMode(samplingMode: number): void;
  98287. /**
  98288. * Scales the texture if is `canRescale()`
  98289. * @param ratio the resize factor we want to use to rescale
  98290. */
  98291. scale(ratio: number): void;
  98292. /**
  98293. * Get if the texture can rescale.
  98294. */
  98295. readonly canRescale: boolean;
  98296. /** @hidden */
  98297. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98298. /** @hidden */
  98299. _rebuild(): void;
  98300. /**
  98301. * Triggers the load sequence in delayed load mode.
  98302. */
  98303. delayLoad(): void;
  98304. /**
  98305. * Clones the texture.
  98306. * @returns the cloned texture
  98307. */
  98308. clone(): Nullable<BaseTexture>;
  98309. /**
  98310. * Get the texture underlying type (INT, FLOAT...)
  98311. */
  98312. readonly textureType: number;
  98313. /**
  98314. * Get the texture underlying format (RGB, RGBA...)
  98315. */
  98316. readonly textureFormat: number;
  98317. /**
  98318. * Indicates that textures need to be re-calculated for all materials
  98319. */
  98320. protected _markAllSubMeshesAsTexturesDirty(): void;
  98321. /**
  98322. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98323. * This will returns an RGBA array buffer containing either in values (0-255) or
  98324. * float values (0-1) depending of the underlying buffer type.
  98325. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98326. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98327. * @param buffer defines a user defined buffer to fill with data (can be null)
  98328. * @returns The Array buffer containing the pixels data.
  98329. */
  98330. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98331. /**
  98332. * Release and destroy the underlying lower level texture aka internalTexture.
  98333. */
  98334. releaseInternalTexture(): void;
  98335. /** @hidden */
  98336. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98337. /** @hidden */
  98338. readonly _lodTextureMid: Nullable<BaseTexture>;
  98339. /** @hidden */
  98340. readonly _lodTextureLow: Nullable<BaseTexture>;
  98341. /**
  98342. * Dispose the texture and release its associated resources.
  98343. */
  98344. dispose(): void;
  98345. /**
  98346. * Serialize the texture into a JSON representation that can be parsed later on.
  98347. * @returns the JSON representation of the texture
  98348. */
  98349. serialize(): any;
  98350. /**
  98351. * Helper function to be called back once a list of texture contains only ready textures.
  98352. * @param textures Define the list of textures to wait for
  98353. * @param callback Define the callback triggered once the entire list will be ready
  98354. */
  98355. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98356. }
  98357. }
  98358. declare module BABYLON {
  98359. /**
  98360. * Options to be used when creating an effect.
  98361. */
  98362. export interface IEffectCreationOptions {
  98363. /**
  98364. * Atrributes that will be used in the shader.
  98365. */
  98366. attributes: string[];
  98367. /**
  98368. * Uniform varible names that will be set in the shader.
  98369. */
  98370. uniformsNames: string[];
  98371. /**
  98372. * Uniform buffer variable names that will be set in the shader.
  98373. */
  98374. uniformBuffersNames: string[];
  98375. /**
  98376. * Sampler texture variable names that will be set in the shader.
  98377. */
  98378. samplers: string[];
  98379. /**
  98380. * Define statements that will be set in the shader.
  98381. */
  98382. defines: any;
  98383. /**
  98384. * Possible fallbacks for this effect to improve performance when needed.
  98385. */
  98386. fallbacks: Nullable<IEffectFallbacks>;
  98387. /**
  98388. * Callback that will be called when the shader is compiled.
  98389. */
  98390. onCompiled: Nullable<(effect: Effect) => void>;
  98391. /**
  98392. * Callback that will be called if an error occurs during shader compilation.
  98393. */
  98394. onError: Nullable<(effect: Effect, errors: string) => void>;
  98395. /**
  98396. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98397. */
  98398. indexParameters?: any;
  98399. /**
  98400. * Max number of lights that can be used in the shader.
  98401. */
  98402. maxSimultaneousLights?: number;
  98403. /**
  98404. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98405. */
  98406. transformFeedbackVaryings?: Nullable<string[]>;
  98407. }
  98408. /**
  98409. * Effect containing vertex and fragment shader that can be executed on an object.
  98410. */
  98411. export class Effect implements IDisposable {
  98412. /**
  98413. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98414. */
  98415. static ShadersRepository: string;
  98416. /**
  98417. * Name of the effect.
  98418. */
  98419. name: any;
  98420. /**
  98421. * String container all the define statements that should be set on the shader.
  98422. */
  98423. defines: string;
  98424. /**
  98425. * Callback that will be called when the shader is compiled.
  98426. */
  98427. onCompiled: Nullable<(effect: Effect) => void>;
  98428. /**
  98429. * Callback that will be called if an error occurs during shader compilation.
  98430. */
  98431. onError: Nullable<(effect: Effect, errors: string) => void>;
  98432. /**
  98433. * Callback that will be called when effect is bound.
  98434. */
  98435. onBind: Nullable<(effect: Effect) => void>;
  98436. /**
  98437. * Unique ID of the effect.
  98438. */
  98439. uniqueId: number;
  98440. /**
  98441. * Observable that will be called when the shader is compiled.
  98442. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98443. */
  98444. onCompileObservable: Observable<Effect>;
  98445. /**
  98446. * Observable that will be called if an error occurs during shader compilation.
  98447. */
  98448. onErrorObservable: Observable<Effect>;
  98449. /** @hidden */
  98450. _onBindObservable: Nullable<Observable<Effect>>;
  98451. /**
  98452. * Observable that will be called when effect is bound.
  98453. */
  98454. readonly onBindObservable: Observable<Effect>;
  98455. /** @hidden */
  98456. _bonesComputationForcedToCPU: boolean;
  98457. private static _uniqueIdSeed;
  98458. private _engine;
  98459. private _uniformBuffersNames;
  98460. private _uniformsNames;
  98461. private _samplerList;
  98462. private _samplers;
  98463. private _isReady;
  98464. private _compilationError;
  98465. private _allFallbacksProcessed;
  98466. private _attributesNames;
  98467. private _attributes;
  98468. private _uniforms;
  98469. /**
  98470. * Key for the effect.
  98471. * @hidden
  98472. */
  98473. _key: string;
  98474. private _indexParameters;
  98475. private _fallbacks;
  98476. private _vertexSourceCode;
  98477. private _fragmentSourceCode;
  98478. private _vertexSourceCodeOverride;
  98479. private _fragmentSourceCodeOverride;
  98480. private _transformFeedbackVaryings;
  98481. /**
  98482. * Compiled shader to webGL program.
  98483. * @hidden
  98484. */
  98485. _pipelineContext: Nullable<IPipelineContext>;
  98486. private _valueCache;
  98487. private static _baseCache;
  98488. /**
  98489. * Instantiates an effect.
  98490. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98491. * @param baseName Name of the effect.
  98492. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98493. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98494. * @param samplers List of sampler variables that will be passed to the shader.
  98495. * @param engine Engine to be used to render the effect
  98496. * @param defines Define statements to be added to the shader.
  98497. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98498. * @param onCompiled Callback that will be called when the shader is compiled.
  98499. * @param onError Callback that will be called if an error occurs during shader compilation.
  98500. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98501. */
  98502. 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);
  98503. private _useFinalCode;
  98504. /**
  98505. * Unique key for this effect
  98506. */
  98507. readonly key: string;
  98508. /**
  98509. * If the effect has been compiled and prepared.
  98510. * @returns if the effect is compiled and prepared.
  98511. */
  98512. isReady(): boolean;
  98513. private _isReadyInternal;
  98514. /**
  98515. * The engine the effect was initialized with.
  98516. * @returns the engine.
  98517. */
  98518. getEngine(): Engine;
  98519. /**
  98520. * The pipeline context for this effect
  98521. * @returns the associated pipeline context
  98522. */
  98523. getPipelineContext(): Nullable<IPipelineContext>;
  98524. /**
  98525. * The set of names of attribute variables for the shader.
  98526. * @returns An array of attribute names.
  98527. */
  98528. getAttributesNames(): string[];
  98529. /**
  98530. * Returns the attribute at the given index.
  98531. * @param index The index of the attribute.
  98532. * @returns The location of the attribute.
  98533. */
  98534. getAttributeLocation(index: number): number;
  98535. /**
  98536. * Returns the attribute based on the name of the variable.
  98537. * @param name of the attribute to look up.
  98538. * @returns the attribute location.
  98539. */
  98540. getAttributeLocationByName(name: string): number;
  98541. /**
  98542. * The number of attributes.
  98543. * @returns the numnber of attributes.
  98544. */
  98545. getAttributesCount(): number;
  98546. /**
  98547. * Gets the index of a uniform variable.
  98548. * @param uniformName of the uniform to look up.
  98549. * @returns the index.
  98550. */
  98551. getUniformIndex(uniformName: string): number;
  98552. /**
  98553. * Returns the attribute based on the name of the variable.
  98554. * @param uniformName of the uniform to look up.
  98555. * @returns the location of the uniform.
  98556. */
  98557. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  98558. /**
  98559. * Returns an array of sampler variable names
  98560. * @returns The array of sampler variable neames.
  98561. */
  98562. getSamplers(): string[];
  98563. /**
  98564. * The error from the last compilation.
  98565. * @returns the error string.
  98566. */
  98567. getCompilationError(): string;
  98568. /**
  98569. * Gets a boolean indicating that all fallbacks were used during compilation
  98570. * @returns true if all fallbacks were used
  98571. */
  98572. allFallbacksProcessed(): boolean;
  98573. /**
  98574. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  98575. * @param func The callback to be used.
  98576. */
  98577. executeWhenCompiled(func: (effect: Effect) => void): void;
  98578. private _checkIsReady;
  98579. private _loadShader;
  98580. /**
  98581. * Recompiles the webGL program
  98582. * @param vertexSourceCode The source code for the vertex shader.
  98583. * @param fragmentSourceCode The source code for the fragment shader.
  98584. * @param onCompiled Callback called when completed.
  98585. * @param onError Callback called on error.
  98586. * @hidden
  98587. */
  98588. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  98589. /**
  98590. * Prepares the effect
  98591. * @hidden
  98592. */
  98593. _prepareEffect(): void;
  98594. private _processCompilationErrors;
  98595. /**
  98596. * Checks if the effect is supported. (Must be called after compilation)
  98597. */
  98598. readonly isSupported: boolean;
  98599. /**
  98600. * Binds a texture to the engine to be used as output of the shader.
  98601. * @param channel Name of the output variable.
  98602. * @param texture Texture to bind.
  98603. * @hidden
  98604. */
  98605. _bindTexture(channel: string, texture: InternalTexture): void;
  98606. /**
  98607. * Sets a texture on the engine to be used in the shader.
  98608. * @param channel Name of the sampler variable.
  98609. * @param texture Texture to set.
  98610. */
  98611. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  98612. /**
  98613. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  98614. * @param channel Name of the sampler variable.
  98615. * @param texture Texture to set.
  98616. */
  98617. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  98618. /**
  98619. * Sets an array of textures on the engine to be used in the shader.
  98620. * @param channel Name of the variable.
  98621. * @param textures Textures to set.
  98622. */
  98623. setTextureArray(channel: string, textures: BaseTexture[]): void;
  98624. /**
  98625. * 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)
  98626. * @param channel Name of the sampler variable.
  98627. * @param postProcess Post process to get the input texture from.
  98628. */
  98629. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  98630. /**
  98631. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  98632. * 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)
  98633. * @param channel Name of the sampler variable.
  98634. * @param postProcess Post process to get the output texture from.
  98635. */
  98636. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  98637. /** @hidden */
  98638. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  98639. /** @hidden */
  98640. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  98641. /** @hidden */
  98642. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  98643. /** @hidden */
  98644. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  98645. /**
  98646. * Binds a buffer to a uniform.
  98647. * @param buffer Buffer to bind.
  98648. * @param name Name of the uniform variable to bind to.
  98649. */
  98650. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  98651. /**
  98652. * Binds block to a uniform.
  98653. * @param blockName Name of the block to bind.
  98654. * @param index Index to bind.
  98655. */
  98656. bindUniformBlock(blockName: string, index: number): void;
  98657. /**
  98658. * Sets an interger value on a uniform variable.
  98659. * @param uniformName Name of the variable.
  98660. * @param value Value to be set.
  98661. * @returns this effect.
  98662. */
  98663. setInt(uniformName: string, value: number): Effect;
  98664. /**
  98665. * Sets an int array on a uniform variable.
  98666. * @param uniformName Name of the variable.
  98667. * @param array array to be set.
  98668. * @returns this effect.
  98669. */
  98670. setIntArray(uniformName: string, array: Int32Array): Effect;
  98671. /**
  98672. * 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)
  98673. * @param uniformName Name of the variable.
  98674. * @param array array to be set.
  98675. * @returns this effect.
  98676. */
  98677. setIntArray2(uniformName: string, array: Int32Array): Effect;
  98678. /**
  98679. * 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)
  98680. * @param uniformName Name of the variable.
  98681. * @param array array to be set.
  98682. * @returns this effect.
  98683. */
  98684. setIntArray3(uniformName: string, array: Int32Array): Effect;
  98685. /**
  98686. * 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)
  98687. * @param uniformName Name of the variable.
  98688. * @param array array to be set.
  98689. * @returns this effect.
  98690. */
  98691. setIntArray4(uniformName: string, array: Int32Array): Effect;
  98692. /**
  98693. * Sets an float array on a uniform variable.
  98694. * @param uniformName Name of the variable.
  98695. * @param array array to be set.
  98696. * @returns this effect.
  98697. */
  98698. setFloatArray(uniformName: string, array: Float32Array): Effect;
  98699. /**
  98700. * 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)
  98701. * @param uniformName Name of the variable.
  98702. * @param array array to be set.
  98703. * @returns this effect.
  98704. */
  98705. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  98706. /**
  98707. * 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)
  98708. * @param uniformName Name of the variable.
  98709. * @param array array to be set.
  98710. * @returns this effect.
  98711. */
  98712. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  98713. /**
  98714. * 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)
  98715. * @param uniformName Name of the variable.
  98716. * @param array array to be set.
  98717. * @returns this effect.
  98718. */
  98719. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  98720. /**
  98721. * Sets an array on a uniform variable.
  98722. * @param uniformName Name of the variable.
  98723. * @param array array to be set.
  98724. * @returns this effect.
  98725. */
  98726. setArray(uniformName: string, array: number[]): Effect;
  98727. /**
  98728. * 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)
  98729. * @param uniformName Name of the variable.
  98730. * @param array array to be set.
  98731. * @returns this effect.
  98732. */
  98733. setArray2(uniformName: string, array: number[]): Effect;
  98734. /**
  98735. * 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)
  98736. * @param uniformName Name of the variable.
  98737. * @param array array to be set.
  98738. * @returns this effect.
  98739. */
  98740. setArray3(uniformName: string, array: number[]): Effect;
  98741. /**
  98742. * 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)
  98743. * @param uniformName Name of the variable.
  98744. * @param array array to be set.
  98745. * @returns this effect.
  98746. */
  98747. setArray4(uniformName: string, array: number[]): Effect;
  98748. /**
  98749. * Sets matrices on a uniform variable.
  98750. * @param uniformName Name of the variable.
  98751. * @param matrices matrices to be set.
  98752. * @returns this effect.
  98753. */
  98754. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  98755. /**
  98756. * Sets matrix on a uniform variable.
  98757. * @param uniformName Name of the variable.
  98758. * @param matrix matrix to be set.
  98759. * @returns this effect.
  98760. */
  98761. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  98762. /**
  98763. * 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)
  98764. * @param uniformName Name of the variable.
  98765. * @param matrix matrix to be set.
  98766. * @returns this effect.
  98767. */
  98768. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  98769. /**
  98770. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  98771. * @param uniformName Name of the variable.
  98772. * @param matrix matrix to be set.
  98773. * @returns this effect.
  98774. */
  98775. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  98776. /**
  98777. * Sets a float on a uniform variable.
  98778. * @param uniformName Name of the variable.
  98779. * @param value value to be set.
  98780. * @returns this effect.
  98781. */
  98782. setFloat(uniformName: string, value: number): Effect;
  98783. /**
  98784. * Sets a boolean on a uniform variable.
  98785. * @param uniformName Name of the variable.
  98786. * @param bool value to be set.
  98787. * @returns this effect.
  98788. */
  98789. setBool(uniformName: string, bool: boolean): Effect;
  98790. /**
  98791. * Sets a Vector2 on a uniform variable.
  98792. * @param uniformName Name of the variable.
  98793. * @param vector2 vector2 to be set.
  98794. * @returns this effect.
  98795. */
  98796. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  98797. /**
  98798. * Sets a float2 on a uniform variable.
  98799. * @param uniformName Name of the variable.
  98800. * @param x First float in float2.
  98801. * @param y Second float in float2.
  98802. * @returns this effect.
  98803. */
  98804. setFloat2(uniformName: string, x: number, y: number): Effect;
  98805. /**
  98806. * Sets a Vector3 on a uniform variable.
  98807. * @param uniformName Name of the variable.
  98808. * @param vector3 Value to be set.
  98809. * @returns this effect.
  98810. */
  98811. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  98812. /**
  98813. * Sets a float3 on a uniform variable.
  98814. * @param uniformName Name of the variable.
  98815. * @param x First float in float3.
  98816. * @param y Second float in float3.
  98817. * @param z Third float in float3.
  98818. * @returns this effect.
  98819. */
  98820. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  98821. /**
  98822. * Sets a Vector4 on a uniform variable.
  98823. * @param uniformName Name of the variable.
  98824. * @param vector4 Value to be set.
  98825. * @returns this effect.
  98826. */
  98827. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  98828. /**
  98829. * Sets a float4 on a uniform variable.
  98830. * @param uniformName Name of the variable.
  98831. * @param x First float in float4.
  98832. * @param y Second float in float4.
  98833. * @param z Third float in float4.
  98834. * @param w Fourth float in float4.
  98835. * @returns this effect.
  98836. */
  98837. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  98838. /**
  98839. * Sets a Color3 on a uniform variable.
  98840. * @param uniformName Name of the variable.
  98841. * @param color3 Value to be set.
  98842. * @returns this effect.
  98843. */
  98844. setColor3(uniformName: string, color3: IColor3Like): Effect;
  98845. /**
  98846. * Sets a Color4 on a uniform variable.
  98847. * @param uniformName Name of the variable.
  98848. * @param color3 Value to be set.
  98849. * @param alpha Alpha value to be set.
  98850. * @returns this effect.
  98851. */
  98852. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  98853. /**
  98854. * Sets a Color4 on a uniform variable
  98855. * @param uniformName defines the name of the variable
  98856. * @param color4 defines the value to be set
  98857. * @returns this effect.
  98858. */
  98859. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  98860. /** Release all associated resources */
  98861. dispose(): void;
  98862. /**
  98863. * This function will add a new shader to the shader store
  98864. * @param name the name of the shader
  98865. * @param pixelShader optional pixel shader content
  98866. * @param vertexShader optional vertex shader content
  98867. */
  98868. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  98869. /**
  98870. * Store of each shader (The can be looked up using effect.key)
  98871. */
  98872. static ShadersStore: {
  98873. [key: string]: string;
  98874. };
  98875. /**
  98876. * Store of each included file for a shader (The can be looked up using effect.key)
  98877. */
  98878. static IncludesShadersStore: {
  98879. [key: string]: string;
  98880. };
  98881. /**
  98882. * Resets the cache of effects.
  98883. */
  98884. static ResetCache(): void;
  98885. }
  98886. }
  98887. declare module BABYLON {
  98888. /**
  98889. * Interface used to describe the capabilities of the engine relatively to the current browser
  98890. */
  98891. export interface EngineCapabilities {
  98892. /** Maximum textures units per fragment shader */
  98893. maxTexturesImageUnits: number;
  98894. /** Maximum texture units per vertex shader */
  98895. maxVertexTextureImageUnits: number;
  98896. /** Maximum textures units in the entire pipeline */
  98897. maxCombinedTexturesImageUnits: number;
  98898. /** Maximum texture size */
  98899. maxTextureSize: number;
  98900. /** Maximum texture samples */
  98901. maxSamples?: number;
  98902. /** Maximum cube texture size */
  98903. maxCubemapTextureSize: number;
  98904. /** Maximum render texture size */
  98905. maxRenderTextureSize: number;
  98906. /** Maximum number of vertex attributes */
  98907. maxVertexAttribs: number;
  98908. /** Maximum number of varyings */
  98909. maxVaryingVectors: number;
  98910. /** Maximum number of uniforms per vertex shader */
  98911. maxVertexUniformVectors: number;
  98912. /** Maximum number of uniforms per fragment shader */
  98913. maxFragmentUniformVectors: number;
  98914. /** Defines if standard derivates (dx/dy) are supported */
  98915. standardDerivatives: boolean;
  98916. /** Defines if s3tc texture compression is supported */
  98917. s3tc?: WEBGL_compressed_texture_s3tc;
  98918. /** Defines if pvrtc texture compression is supported */
  98919. pvrtc: any;
  98920. /** Defines if etc1 texture compression is supported */
  98921. etc1: any;
  98922. /** Defines if etc2 texture compression is supported */
  98923. etc2: any;
  98924. /** Defines if astc texture compression is supported */
  98925. astc: any;
  98926. /** Defines if float textures are supported */
  98927. textureFloat: boolean;
  98928. /** Defines if vertex array objects are supported */
  98929. vertexArrayObject: boolean;
  98930. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  98931. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  98932. /** Gets the maximum level of anisotropy supported */
  98933. maxAnisotropy: number;
  98934. /** Defines if instancing is supported */
  98935. instancedArrays: boolean;
  98936. /** Defines if 32 bits indices are supported */
  98937. uintIndices: boolean;
  98938. /** Defines if high precision shaders are supported */
  98939. highPrecisionShaderSupported: boolean;
  98940. /** Defines if depth reading in the fragment shader is supported */
  98941. fragmentDepthSupported: boolean;
  98942. /** Defines if float texture linear filtering is supported*/
  98943. textureFloatLinearFiltering: boolean;
  98944. /** Defines if rendering to float textures is supported */
  98945. textureFloatRender: boolean;
  98946. /** Defines if half float textures are supported*/
  98947. textureHalfFloat: boolean;
  98948. /** Defines if half float texture linear filtering is supported*/
  98949. textureHalfFloatLinearFiltering: boolean;
  98950. /** Defines if rendering to half float textures is supported */
  98951. textureHalfFloatRender: boolean;
  98952. /** Defines if textureLOD shader command is supported */
  98953. textureLOD: boolean;
  98954. /** Defines if draw buffers extension is supported */
  98955. drawBuffersExtension: boolean;
  98956. /** Defines if depth textures are supported */
  98957. depthTextureExtension: boolean;
  98958. /** Defines if float color buffer are supported */
  98959. colorBufferFloat: boolean;
  98960. /** Gets disjoint timer query extension (null if not supported) */
  98961. timerQuery?: EXT_disjoint_timer_query;
  98962. /** Defines if timestamp can be used with timer query */
  98963. canUseTimestampForTimerQuery: boolean;
  98964. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  98965. multiview?: any;
  98966. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  98967. oculusMultiview?: any;
  98968. /** Function used to let the system compiles shaders in background */
  98969. parallelShaderCompile?: {
  98970. COMPLETION_STATUS_KHR: number;
  98971. };
  98972. /** Max number of texture samples for MSAA */
  98973. maxMSAASamples: number;
  98974. /** Defines if the blend min max extension is supported */
  98975. blendMinMax: boolean;
  98976. }
  98977. }
  98978. declare module BABYLON {
  98979. /**
  98980. * @hidden
  98981. **/
  98982. export class DepthCullingState {
  98983. private _isDepthTestDirty;
  98984. private _isDepthMaskDirty;
  98985. private _isDepthFuncDirty;
  98986. private _isCullFaceDirty;
  98987. private _isCullDirty;
  98988. private _isZOffsetDirty;
  98989. private _isFrontFaceDirty;
  98990. private _depthTest;
  98991. private _depthMask;
  98992. private _depthFunc;
  98993. private _cull;
  98994. private _cullFace;
  98995. private _zOffset;
  98996. private _frontFace;
  98997. /**
  98998. * Initializes the state.
  98999. */
  99000. constructor();
  99001. readonly isDirty: boolean;
  99002. zOffset: number;
  99003. cullFace: Nullable<number>;
  99004. cull: Nullable<boolean>;
  99005. depthFunc: Nullable<number>;
  99006. depthMask: boolean;
  99007. depthTest: boolean;
  99008. frontFace: Nullable<number>;
  99009. reset(): void;
  99010. apply(gl: WebGLRenderingContext): void;
  99011. }
  99012. }
  99013. declare module BABYLON {
  99014. /**
  99015. * @hidden
  99016. **/
  99017. export class StencilState {
  99018. /** 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 */
  99019. static readonly ALWAYS: number;
  99020. /** Passed to stencilOperation to specify that stencil value must be kept */
  99021. static readonly KEEP: number;
  99022. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99023. static readonly REPLACE: number;
  99024. private _isStencilTestDirty;
  99025. private _isStencilMaskDirty;
  99026. private _isStencilFuncDirty;
  99027. private _isStencilOpDirty;
  99028. private _stencilTest;
  99029. private _stencilMask;
  99030. private _stencilFunc;
  99031. private _stencilFuncRef;
  99032. private _stencilFuncMask;
  99033. private _stencilOpStencilFail;
  99034. private _stencilOpDepthFail;
  99035. private _stencilOpStencilDepthPass;
  99036. readonly isDirty: boolean;
  99037. stencilFunc: number;
  99038. stencilFuncRef: number;
  99039. stencilFuncMask: number;
  99040. stencilOpStencilFail: number;
  99041. stencilOpDepthFail: number;
  99042. stencilOpStencilDepthPass: number;
  99043. stencilMask: number;
  99044. stencilTest: boolean;
  99045. constructor();
  99046. reset(): void;
  99047. apply(gl: WebGLRenderingContext): void;
  99048. }
  99049. }
  99050. declare module BABYLON {
  99051. /**
  99052. * @hidden
  99053. **/
  99054. export class AlphaState {
  99055. private _isAlphaBlendDirty;
  99056. private _isBlendFunctionParametersDirty;
  99057. private _isBlendEquationParametersDirty;
  99058. private _isBlendConstantsDirty;
  99059. private _alphaBlend;
  99060. private _blendFunctionParameters;
  99061. private _blendEquationParameters;
  99062. private _blendConstants;
  99063. /**
  99064. * Initializes the state.
  99065. */
  99066. constructor();
  99067. readonly isDirty: boolean;
  99068. alphaBlend: boolean;
  99069. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99070. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99071. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99072. reset(): void;
  99073. apply(gl: WebGLRenderingContext): void;
  99074. }
  99075. }
  99076. declare module BABYLON {
  99077. /** @hidden */
  99078. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99079. attributeProcessor(attribute: string): string;
  99080. varyingProcessor(varying: string, isFragment: boolean): string;
  99081. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99082. }
  99083. }
  99084. declare module BABYLON {
  99085. /**
  99086. * Interface for attribute information associated with buffer instanciation
  99087. */
  99088. export interface InstancingAttributeInfo {
  99089. /**
  99090. * Index/offset of the attribute in the vertex shader
  99091. */
  99092. index: number;
  99093. /**
  99094. * size of the attribute, 1, 2, 3 or 4
  99095. */
  99096. attributeSize: number;
  99097. /**
  99098. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99099. * default is FLOAT
  99100. */
  99101. attributeType: number;
  99102. /**
  99103. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99104. */
  99105. normalized: boolean;
  99106. /**
  99107. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99108. */
  99109. offset: number;
  99110. /**
  99111. * Name of the GLSL attribute, for debugging purpose only
  99112. */
  99113. attributeName: string;
  99114. }
  99115. }
  99116. declare module BABYLON {
  99117. interface ThinEngine {
  99118. /**
  99119. * Update a video texture
  99120. * @param texture defines the texture to update
  99121. * @param video defines the video element to use
  99122. * @param invertY defines if data must be stored with Y axis inverted
  99123. */
  99124. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99125. }
  99126. }
  99127. declare module BABYLON {
  99128. /**
  99129. * Settings for finer control over video usage
  99130. */
  99131. export interface VideoTextureSettings {
  99132. /**
  99133. * Applies `autoplay` to video, if specified
  99134. */
  99135. autoPlay?: boolean;
  99136. /**
  99137. * Applies `loop` to video, if specified
  99138. */
  99139. loop?: boolean;
  99140. /**
  99141. * Automatically updates internal texture from video at every frame in the render loop
  99142. */
  99143. autoUpdateTexture: boolean;
  99144. /**
  99145. * Image src displayed during the video loading or until the user interacts with the video.
  99146. */
  99147. poster?: string;
  99148. }
  99149. /**
  99150. * If you want to display a video in your scene, this is the special texture for that.
  99151. * This special texture works similar to other textures, with the exception of a few parameters.
  99152. * @see https://doc.babylonjs.com/how_to/video_texture
  99153. */
  99154. export class VideoTexture extends Texture {
  99155. /**
  99156. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99157. */
  99158. readonly autoUpdateTexture: boolean;
  99159. /**
  99160. * The video instance used by the texture internally
  99161. */
  99162. readonly video: HTMLVideoElement;
  99163. private _onUserActionRequestedObservable;
  99164. /**
  99165. * Event triggerd when a dom action is required by the user to play the video.
  99166. * This happens due to recent changes in browser policies preventing video to auto start.
  99167. */
  99168. readonly onUserActionRequestedObservable: Observable<Texture>;
  99169. private _generateMipMaps;
  99170. private _engine;
  99171. private _stillImageCaptured;
  99172. private _displayingPosterTexture;
  99173. private _settings;
  99174. private _createInternalTextureOnEvent;
  99175. private _frameId;
  99176. /**
  99177. * Creates a video texture.
  99178. * If you want to display a video in your scene, this is the special texture for that.
  99179. * This special texture works similar to other textures, with the exception of a few parameters.
  99180. * @see https://doc.babylonjs.com/how_to/video_texture
  99181. * @param name optional name, will detect from video source, if not defined
  99182. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99183. * @param scene is obviously the current scene.
  99184. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99185. * @param invertY is false by default but can be used to invert video on Y axis
  99186. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99187. * @param settings allows finer control over video usage
  99188. */
  99189. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99190. private _getName;
  99191. private _getVideo;
  99192. private _createInternalTexture;
  99193. private reset;
  99194. /**
  99195. * @hidden Internal method to initiate `update`.
  99196. */
  99197. _rebuild(): void;
  99198. /**
  99199. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99200. */
  99201. update(): void;
  99202. /**
  99203. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99204. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99205. */
  99206. updateTexture(isVisible: boolean): void;
  99207. protected _updateInternalTexture: () => void;
  99208. /**
  99209. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99210. * @param url New url.
  99211. */
  99212. updateURL(url: string): void;
  99213. /**
  99214. * Dispose the texture and release its associated resources.
  99215. */
  99216. dispose(): void;
  99217. /**
  99218. * Creates a video texture straight from a stream.
  99219. * @param scene Define the scene the texture should be created in
  99220. * @param stream Define the stream the texture should be created from
  99221. * @returns The created video texture as a promise
  99222. */
  99223. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99224. /**
  99225. * Creates a video texture straight from your WebCam video feed.
  99226. * @param scene Define the scene the texture should be created in
  99227. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99228. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99229. * @returns The created video texture as a promise
  99230. */
  99231. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99232. minWidth: number;
  99233. maxWidth: number;
  99234. minHeight: number;
  99235. maxHeight: number;
  99236. deviceId: string;
  99237. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99238. /**
  99239. * Creates a video texture straight from your WebCam video feed.
  99240. * @param scene Define the scene the texture should be created in
  99241. * @param onReady Define a callback to triggered once the texture will be ready
  99242. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99243. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99244. */
  99245. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99246. minWidth: number;
  99247. maxWidth: number;
  99248. minHeight: number;
  99249. maxHeight: number;
  99250. deviceId: string;
  99251. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99252. }
  99253. }
  99254. declare module BABYLON {
  99255. /**
  99256. * Defines the interface used by objects working like Scene
  99257. * @hidden
  99258. */
  99259. interface ISceneLike {
  99260. _addPendingData(data: any): void;
  99261. _removePendingData(data: any): void;
  99262. offlineProvider: IOfflineProvider;
  99263. }
  99264. /** Interface defining initialization parameters for Engine class */
  99265. export interface EngineOptions extends WebGLContextAttributes {
  99266. /**
  99267. * Defines if the engine should no exceed a specified device ratio
  99268. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99269. */
  99270. limitDeviceRatio?: number;
  99271. /**
  99272. * Defines if webvr should be enabled automatically
  99273. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99274. */
  99275. autoEnableWebVR?: boolean;
  99276. /**
  99277. * Defines if webgl2 should be turned off even if supported
  99278. * @see http://doc.babylonjs.com/features/webgl2
  99279. */
  99280. disableWebGL2Support?: boolean;
  99281. /**
  99282. * Defines if webaudio should be initialized as well
  99283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99284. */
  99285. audioEngine?: boolean;
  99286. /**
  99287. * Defines if animations should run using a deterministic lock step
  99288. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99289. */
  99290. deterministicLockstep?: boolean;
  99291. /** Defines the maximum steps to use with deterministic lock step mode */
  99292. lockstepMaxSteps?: number;
  99293. /** Defines the seconds between each deterministic lock step */
  99294. timeStep?: number;
  99295. /**
  99296. * Defines that engine should ignore context lost events
  99297. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99298. */
  99299. doNotHandleContextLost?: boolean;
  99300. /**
  99301. * Defines that engine should ignore modifying touch action attribute and style
  99302. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99303. */
  99304. doNotHandleTouchAction?: boolean;
  99305. /**
  99306. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99307. */
  99308. useHighPrecisionFloats?: boolean;
  99309. }
  99310. /**
  99311. * The base engine class (root of all engines)
  99312. */
  99313. export class ThinEngine {
  99314. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99315. static ExceptionList: ({
  99316. key: string;
  99317. capture: string;
  99318. captureConstraint: number;
  99319. targets: string[];
  99320. } | {
  99321. key: string;
  99322. capture: null;
  99323. captureConstraint: null;
  99324. targets: string[];
  99325. })[];
  99326. /** @hidden */
  99327. static _TextureLoaders: IInternalTextureLoader[];
  99328. /**
  99329. * Returns the current npm package of the sdk
  99330. */
  99331. static readonly NpmPackage: string;
  99332. /**
  99333. * Returns the current version of the framework
  99334. */
  99335. static readonly Version: string;
  99336. /**
  99337. * Returns a string describing the current engine
  99338. */
  99339. readonly description: string;
  99340. /**
  99341. * Gets or sets the epsilon value used by collision engine
  99342. */
  99343. static CollisionsEpsilon: number;
  99344. /**
  99345. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99346. */
  99347. static ShadersRepository: string;
  99348. /** @hidden */
  99349. _shaderProcessor: IShaderProcessor;
  99350. /**
  99351. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99352. */
  99353. forcePOTTextures: boolean;
  99354. /**
  99355. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99356. */
  99357. isFullscreen: boolean;
  99358. /**
  99359. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99360. */
  99361. cullBackFaces: boolean;
  99362. /**
  99363. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99364. */
  99365. renderEvenInBackground: boolean;
  99366. /**
  99367. * Gets or sets a boolean indicating that cache can be kept between frames
  99368. */
  99369. preventCacheWipeBetweenFrames: boolean;
  99370. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99371. validateShaderPrograms: boolean;
  99372. /**
  99373. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99374. * This can provide greater z depth for distant objects.
  99375. */
  99376. useReverseDepthBuffer: boolean;
  99377. /**
  99378. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99379. */
  99380. disableUniformBuffers: boolean;
  99381. /** @hidden */
  99382. _uniformBuffers: UniformBuffer[];
  99383. /**
  99384. * Gets a boolean indicating that the engine supports uniform buffers
  99385. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99386. */
  99387. readonly supportsUniformBuffers: boolean;
  99388. /** @hidden */
  99389. _gl: WebGLRenderingContext;
  99390. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99391. protected _windowIsBackground: boolean;
  99392. protected _webGLVersion: number;
  99393. protected _creationOptions: EngineOptions;
  99394. protected _highPrecisionShadersAllowed: boolean;
  99395. /** @hidden */
  99396. readonly _shouldUseHighPrecisionShader: boolean;
  99397. /**
  99398. * Gets a boolean indicating that only power of 2 textures are supported
  99399. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99400. */
  99401. readonly needPOTTextures: boolean;
  99402. /** @hidden */
  99403. _badOS: boolean;
  99404. /** @hidden */
  99405. _badDesktopOS: boolean;
  99406. private _hardwareScalingLevel;
  99407. /** @hidden */
  99408. _caps: EngineCapabilities;
  99409. private _isStencilEnable;
  99410. protected _colorWrite: boolean;
  99411. private _glVersion;
  99412. private _glRenderer;
  99413. private _glVendor;
  99414. /** @hidden */
  99415. _videoTextureSupported: boolean;
  99416. protected _renderingQueueLaunched: boolean;
  99417. protected _activeRenderLoops: (() => void)[];
  99418. /**
  99419. * Observable signaled when a context lost event is raised
  99420. */
  99421. onContextLostObservable: Observable<ThinEngine>;
  99422. /**
  99423. * Observable signaled when a context restored event is raised
  99424. */
  99425. onContextRestoredObservable: Observable<ThinEngine>;
  99426. private _onContextLost;
  99427. private _onContextRestored;
  99428. protected _contextWasLost: boolean;
  99429. /** @hidden */
  99430. _doNotHandleContextLost: boolean;
  99431. /**
  99432. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99434. */
  99435. doNotHandleContextLost: boolean;
  99436. /**
  99437. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99438. */
  99439. disableVertexArrayObjects: boolean;
  99440. /** @hidden */
  99441. protected _depthCullingState: DepthCullingState;
  99442. /** @hidden */
  99443. protected _stencilState: StencilState;
  99444. /** @hidden */
  99445. protected _alphaState: AlphaState;
  99446. /** @hidden */
  99447. _internalTexturesCache: InternalTexture[];
  99448. /** @hidden */
  99449. protected _activeChannel: number;
  99450. private _currentTextureChannel;
  99451. /** @hidden */
  99452. protected _boundTexturesCache: {
  99453. [key: string]: Nullable<InternalTexture>;
  99454. };
  99455. /** @hidden */
  99456. protected _currentEffect: Nullable<Effect>;
  99457. /** @hidden */
  99458. protected _currentProgram: Nullable<WebGLProgram>;
  99459. private _compiledEffects;
  99460. private _vertexAttribArraysEnabled;
  99461. /** @hidden */
  99462. protected _cachedViewport: Nullable<IViewportLike>;
  99463. private _cachedVertexArrayObject;
  99464. /** @hidden */
  99465. protected _cachedVertexBuffers: any;
  99466. /** @hidden */
  99467. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99468. /** @hidden */
  99469. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99470. /** @hidden */
  99471. _currentRenderTarget: Nullable<InternalTexture>;
  99472. private _uintIndicesCurrentlySet;
  99473. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99474. /** @hidden */
  99475. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99476. private _currentBufferPointers;
  99477. private _currentInstanceLocations;
  99478. private _currentInstanceBuffers;
  99479. private _textureUnits;
  99480. /** @hidden */
  99481. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99482. /** @hidden */
  99483. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99484. /** @hidden */
  99485. _boundRenderFunction: any;
  99486. private _vaoRecordInProgress;
  99487. private _mustWipeVertexAttributes;
  99488. private _emptyTexture;
  99489. private _emptyCubeTexture;
  99490. private _emptyTexture3D;
  99491. private _emptyTexture2DArray;
  99492. /** @hidden */
  99493. _frameHandler: number;
  99494. private _nextFreeTextureSlots;
  99495. private _maxSimultaneousTextures;
  99496. private _activeRequests;
  99497. protected _texturesSupported: string[];
  99498. /** @hidden */
  99499. _textureFormatInUse: Nullable<string>;
  99500. protected readonly _supportsHardwareTextureRescaling: boolean;
  99501. /**
  99502. * Gets the list of texture formats supported
  99503. */
  99504. readonly texturesSupported: Array<string>;
  99505. /**
  99506. * Gets the list of texture formats in use
  99507. */
  99508. readonly textureFormatInUse: Nullable<string>;
  99509. /**
  99510. * Gets the current viewport
  99511. */
  99512. readonly currentViewport: Nullable<IViewportLike>;
  99513. /**
  99514. * Gets the default empty texture
  99515. */
  99516. readonly emptyTexture: InternalTexture;
  99517. /**
  99518. * Gets the default empty 3D texture
  99519. */
  99520. readonly emptyTexture3D: InternalTexture;
  99521. /**
  99522. * Gets the default empty 2D array texture
  99523. */
  99524. readonly emptyTexture2DArray: InternalTexture;
  99525. /**
  99526. * Gets the default empty cube texture
  99527. */
  99528. readonly emptyCubeTexture: InternalTexture;
  99529. /**
  99530. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  99531. */
  99532. readonly premultipliedAlpha: boolean;
  99533. /**
  99534. * Observable event triggered before each texture is initialized
  99535. */
  99536. onBeforeTextureInitObservable: Observable<Texture>;
  99537. /**
  99538. * Creates a new engine
  99539. * @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
  99540. * @param antialias defines enable antialiasing (default: false)
  99541. * @param options defines further options to be sent to the getContext() function
  99542. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  99543. */
  99544. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  99545. private _rebuildInternalTextures;
  99546. private _rebuildEffects;
  99547. /**
  99548. * Gets a boolean indicating if all created effects are ready
  99549. * @returns true if all effects are ready
  99550. */
  99551. areAllEffectsReady(): boolean;
  99552. protected _rebuildBuffers(): void;
  99553. private _initGLContext;
  99554. /**
  99555. * Gets version of the current webGL context
  99556. */
  99557. readonly webGLVersion: number;
  99558. /**
  99559. * Gets a string idenfifying the name of the class
  99560. * @returns "Engine" string
  99561. */
  99562. getClassName(): string;
  99563. /**
  99564. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  99565. */
  99566. readonly isStencilEnable: boolean;
  99567. /** @hidden */
  99568. _prepareWorkingCanvas(): void;
  99569. /**
  99570. * Reset the texture cache to empty state
  99571. */
  99572. resetTextureCache(): void;
  99573. /**
  99574. * Gets an object containing information about the current webGL context
  99575. * @returns an object containing the vender, the renderer and the version of the current webGL context
  99576. */
  99577. getGlInfo(): {
  99578. vendor: string;
  99579. renderer: string;
  99580. version: string;
  99581. };
  99582. /**
  99583. * Defines the hardware scaling level.
  99584. * By default the hardware scaling level is computed from the window device ratio.
  99585. * 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.
  99586. * @param level defines the level to use
  99587. */
  99588. setHardwareScalingLevel(level: number): void;
  99589. /**
  99590. * Gets the current hardware scaling level.
  99591. * By default the hardware scaling level is computed from the window device ratio.
  99592. * 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.
  99593. * @returns a number indicating the current hardware scaling level
  99594. */
  99595. getHardwareScalingLevel(): number;
  99596. /**
  99597. * Gets the list of loaded textures
  99598. * @returns an array containing all loaded textures
  99599. */
  99600. getLoadedTexturesCache(): InternalTexture[];
  99601. /**
  99602. * Gets the object containing all engine capabilities
  99603. * @returns the EngineCapabilities object
  99604. */
  99605. getCaps(): EngineCapabilities;
  99606. /**
  99607. * stop executing a render loop function and remove it from the execution array
  99608. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  99609. */
  99610. stopRenderLoop(renderFunction?: () => void): void;
  99611. /** @hidden */
  99612. _renderLoop(): void;
  99613. /**
  99614. * Gets the HTML canvas attached with the current webGL context
  99615. * @returns a HTML canvas
  99616. */
  99617. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  99618. /**
  99619. * Gets host window
  99620. * @returns the host window object
  99621. */
  99622. getHostWindow(): Nullable<Window>;
  99623. /**
  99624. * Gets the current render width
  99625. * @param useScreen defines if screen size must be used (or the current render target if any)
  99626. * @returns a number defining the current render width
  99627. */
  99628. getRenderWidth(useScreen?: boolean): number;
  99629. /**
  99630. * Gets the current render height
  99631. * @param useScreen defines if screen size must be used (or the current render target if any)
  99632. * @returns a number defining the current render height
  99633. */
  99634. getRenderHeight(useScreen?: boolean): number;
  99635. /**
  99636. * Can be used to override the current requestAnimationFrame requester.
  99637. * @hidden
  99638. */
  99639. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  99640. /**
  99641. * Register and execute a render loop. The engine can have more than one render function
  99642. * @param renderFunction defines the function to continuously execute
  99643. */
  99644. runRenderLoop(renderFunction: () => void): void;
  99645. /**
  99646. * Clear the current render buffer or the current render target (if any is set up)
  99647. * @param color defines the color to use
  99648. * @param backBuffer defines if the back buffer must be cleared
  99649. * @param depth defines if the depth buffer must be cleared
  99650. * @param stencil defines if the stencil buffer must be cleared
  99651. */
  99652. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99653. private _viewportCached;
  99654. /** @hidden */
  99655. _viewport(x: number, y: number, width: number, height: number): void;
  99656. /**
  99657. * Set the WebGL's viewport
  99658. * @param viewport defines the viewport element to be used
  99659. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  99660. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  99661. */
  99662. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  99663. /**
  99664. * Begin a new frame
  99665. */
  99666. beginFrame(): void;
  99667. /**
  99668. * Enf the current frame
  99669. */
  99670. endFrame(): void;
  99671. /**
  99672. * Resize the view according to the canvas' size
  99673. */
  99674. resize(): void;
  99675. /**
  99676. * Force a specific size of the canvas
  99677. * @param width defines the new canvas' width
  99678. * @param height defines the new canvas' height
  99679. */
  99680. setSize(width: number, height: number): void;
  99681. /**
  99682. * Binds the frame buffer to the specified texture.
  99683. * @param texture The texture to render to or null for the default canvas
  99684. * @param faceIndex The face of the texture to render to in case of cube texture
  99685. * @param requiredWidth The width of the target to render to
  99686. * @param requiredHeight The height of the target to render to
  99687. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  99688. * @param depthStencilTexture The depth stencil texture to use to render
  99689. * @param lodLevel defines le lod level to bind to the frame buffer
  99690. */
  99691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  99692. /** @hidden */
  99693. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  99694. /**
  99695. * Unbind the current render target texture from the webGL context
  99696. * @param texture defines the render target texture to unbind
  99697. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99698. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99699. */
  99700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99701. /**
  99702. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  99703. */
  99704. flushFramebuffer(): void;
  99705. /**
  99706. * Unbind the current render target and bind the default framebuffer
  99707. */
  99708. restoreDefaultFramebuffer(): void;
  99709. /** @hidden */
  99710. protected _resetVertexBufferBinding(): void;
  99711. /**
  99712. * Creates a vertex buffer
  99713. * @param data the data for the vertex buffer
  99714. * @returns the new WebGL static buffer
  99715. */
  99716. createVertexBuffer(data: DataArray): DataBuffer;
  99717. private _createVertexBuffer;
  99718. /**
  99719. * Creates a dynamic vertex buffer
  99720. * @param data the data for the dynamic vertex buffer
  99721. * @returns the new WebGL dynamic buffer
  99722. */
  99723. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  99724. protected _resetIndexBufferBinding(): void;
  99725. /**
  99726. * Creates a new index buffer
  99727. * @param indices defines the content of the index buffer
  99728. * @param updatable defines if the index buffer must be updatable
  99729. * @returns a new webGL buffer
  99730. */
  99731. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  99732. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  99733. /**
  99734. * Bind a webGL buffer to the webGL context
  99735. * @param buffer defines the buffer to bind
  99736. */
  99737. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  99738. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  99739. private bindBuffer;
  99740. /**
  99741. * update the bound buffer with the given data
  99742. * @param data defines the data to update
  99743. */
  99744. updateArrayBuffer(data: Float32Array): void;
  99745. private _vertexAttribPointer;
  99746. private _bindIndexBufferWithCache;
  99747. private _bindVertexBuffersAttributes;
  99748. /**
  99749. * Records a vertex array object
  99750. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99751. * @param vertexBuffers defines the list of vertex buffers to store
  99752. * @param indexBuffer defines the index buffer to store
  99753. * @param effect defines the effect to store
  99754. * @returns the new vertex array object
  99755. */
  99756. recordVertexArrayObject(vertexBuffers: {
  99757. [key: string]: VertexBuffer;
  99758. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  99759. /**
  99760. * Bind a specific vertex array object
  99761. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  99762. * @param vertexArrayObject defines the vertex array object to bind
  99763. * @param indexBuffer defines the index buffer to bind
  99764. */
  99765. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  99766. /**
  99767. * Bind webGl buffers directly to the webGL context
  99768. * @param vertexBuffer defines the vertex buffer to bind
  99769. * @param indexBuffer defines the index buffer to bind
  99770. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  99771. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  99772. * @param effect defines the effect associated with the vertex buffer
  99773. */
  99774. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  99775. private _unbindVertexArrayObject;
  99776. /**
  99777. * Bind a list of vertex buffers to the webGL context
  99778. * @param vertexBuffers defines the list of vertex buffers to bind
  99779. * @param indexBuffer defines the index buffer to bind
  99780. * @param effect defines the effect associated with the vertex buffers
  99781. */
  99782. bindBuffers(vertexBuffers: {
  99783. [key: string]: Nullable<VertexBuffer>;
  99784. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  99785. /**
  99786. * Unbind all instance attributes
  99787. */
  99788. unbindInstanceAttributes(): void;
  99789. /**
  99790. * Release and free the memory of a vertex array object
  99791. * @param vao defines the vertex array object to delete
  99792. */
  99793. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  99794. /** @hidden */
  99795. _releaseBuffer(buffer: DataBuffer): boolean;
  99796. protected _deleteBuffer(buffer: DataBuffer): void;
  99797. /**
  99798. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  99799. * @param instancesBuffer defines the webGL buffer to update and bind
  99800. * @param data defines the data to store in the buffer
  99801. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  99802. */
  99803. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  99804. /**
  99805. * Apply all cached states (depth, culling, stencil and alpha)
  99806. */
  99807. applyStates(): void;
  99808. /**
  99809. * Send a draw order
  99810. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99811. * @param indexStart defines the starting index
  99812. * @param indexCount defines the number of index to draw
  99813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99814. */
  99815. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99816. /**
  99817. * Draw a list of points
  99818. * @param verticesStart defines the index of first vertex to draw
  99819. * @param verticesCount defines the count of vertices to draw
  99820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99821. */
  99822. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99823. /**
  99824. * Draw a list of unindexed primitives
  99825. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  99826. * @param verticesStart defines the index of first vertex to draw
  99827. * @param verticesCount defines the count of vertices to draw
  99828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99829. */
  99830. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99831. /**
  99832. * Draw a list of indexed primitives
  99833. * @param fillMode defines the primitive to use
  99834. * @param indexStart defines the starting index
  99835. * @param indexCount defines the number of index to draw
  99836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99837. */
  99838. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99839. /**
  99840. * Draw a list of unindexed primitives
  99841. * @param fillMode defines the primitive to use
  99842. * @param verticesStart defines the index of first vertex to draw
  99843. * @param verticesCount defines the count of vertices to draw
  99844. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  99845. */
  99846. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99847. private _drawMode;
  99848. /** @hidden */
  99849. protected _reportDrawCall(): void;
  99850. /** @hidden */
  99851. _releaseEffect(effect: Effect): void;
  99852. /** @hidden */
  99853. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  99854. /**
  99855. * Create a new effect (used to store vertex/fragment shaders)
  99856. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  99857. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  99858. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  99859. * @param samplers defines an array of string used to represent textures
  99860. * @param defines defines the string containing the defines to use to compile the shaders
  99861. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  99862. * @param onCompiled defines a function to call when the effect creation is successful
  99863. * @param onError defines a function to call when the effect creation has failed
  99864. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  99865. * @returns the new Effect
  99866. */
  99867. 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;
  99868. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  99869. private _compileShader;
  99870. private _compileRawShader;
  99871. /**
  99872. * Directly creates a webGL program
  99873. * @param pipelineContext defines the pipeline context to attach to
  99874. * @param vertexCode defines the vertex shader code to use
  99875. * @param fragmentCode defines the fragment shader code to use
  99876. * @param context defines the webGL context to use (if not set, the current one will be used)
  99877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99878. * @returns the new webGL program
  99879. */
  99880. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99881. /**
  99882. * Creates a webGL program
  99883. * @param pipelineContext defines the pipeline context to attach to
  99884. * @param vertexCode defines the vertex shader code to use
  99885. * @param fragmentCode defines the fragment shader code to use
  99886. * @param defines defines the string containing the defines to use to compile the shaders
  99887. * @param context defines the webGL context to use (if not set, the current one will be used)
  99888. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  99889. * @returns the new webGL program
  99890. */
  99891. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99892. /**
  99893. * Creates a new pipeline context
  99894. * @returns the new pipeline
  99895. */
  99896. createPipelineContext(): IPipelineContext;
  99897. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  99898. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  99899. /** @hidden */
  99900. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  99901. /** @hidden */
  99902. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  99903. /** @hidden */
  99904. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  99905. /**
  99906. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  99907. * @param pipelineContext defines the pipeline context to use
  99908. * @param uniformsNames defines the list of uniform names
  99909. * @returns an array of webGL uniform locations
  99910. */
  99911. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  99912. /**
  99913. * Gets the lsit of active attributes for a given webGL program
  99914. * @param pipelineContext defines the pipeline context to use
  99915. * @param attributesNames defines the list of attribute names to get
  99916. * @returns an array of indices indicating the offset of each attribute
  99917. */
  99918. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  99919. /**
  99920. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  99921. * @param effect defines the effect to activate
  99922. */
  99923. enableEffect(effect: Nullable<Effect>): void;
  99924. /**
  99925. * Set the value of an uniform to a number (int)
  99926. * @param uniform defines the webGL uniform location where to store the value
  99927. * @param value defines the int number to store
  99928. */
  99929. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  99930. /**
  99931. * Set the value of an uniform to an array of int32
  99932. * @param uniform defines the webGL uniform location where to store the value
  99933. * @param array defines the array of int32 to store
  99934. */
  99935. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99936. /**
  99937. * Set the value of an uniform to an array of int32 (stored as vec2)
  99938. * @param uniform defines the webGL uniform location where to store the value
  99939. * @param array defines the array of int32 to store
  99940. */
  99941. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99942. /**
  99943. * Set the value of an uniform to an array of int32 (stored as vec3)
  99944. * @param uniform defines the webGL uniform location where to store the value
  99945. * @param array defines the array of int32 to store
  99946. */
  99947. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99948. /**
  99949. * Set the value of an uniform to an array of int32 (stored as vec4)
  99950. * @param uniform defines the webGL uniform location where to store the value
  99951. * @param array defines the array of int32 to store
  99952. */
  99953. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  99954. /**
  99955. * Set the value of an uniform to an array of number
  99956. * @param uniform defines the webGL uniform location where to store the value
  99957. * @param array defines the array of number to store
  99958. */
  99959. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99960. /**
  99961. * Set the value of an uniform to an array of number (stored as vec2)
  99962. * @param uniform defines the webGL uniform location where to store the value
  99963. * @param array defines the array of number to store
  99964. */
  99965. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99966. /**
  99967. * Set the value of an uniform to an array of number (stored as vec3)
  99968. * @param uniform defines the webGL uniform location where to store the value
  99969. * @param array defines the array of number to store
  99970. */
  99971. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99972. /**
  99973. * Set the value of an uniform to an array of number (stored as vec4)
  99974. * @param uniform defines the webGL uniform location where to store the value
  99975. * @param array defines the array of number to store
  99976. */
  99977. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  99978. /**
  99979. * Set the value of an uniform to an array of float32 (stored as matrices)
  99980. * @param uniform defines the webGL uniform location where to store the value
  99981. * @param matrices defines the array of float32 to store
  99982. */
  99983. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  99984. /**
  99985. * Set the value of an uniform to a matrix (3x3)
  99986. * @param uniform defines the webGL uniform location where to store the value
  99987. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  99988. */
  99989. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  99990. /**
  99991. * Set the value of an uniform to a matrix (2x2)
  99992. * @param uniform defines the webGL uniform location where to store the value
  99993. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  99994. */
  99995. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  99996. /**
  99997. * Set the value of an uniform to a number (float)
  99998. * @param uniform defines the webGL uniform location where to store the value
  99999. * @param value defines the float number to store
  100000. */
  100001. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100002. /**
  100003. * Set the value of an uniform to a vec2
  100004. * @param uniform defines the webGL uniform location where to store the value
  100005. * @param x defines the 1st component of the value
  100006. * @param y defines the 2nd component of the value
  100007. */
  100008. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100009. /**
  100010. * Set the value of an uniform to a vec3
  100011. * @param uniform defines the webGL uniform location where to store the value
  100012. * @param x defines the 1st component of the value
  100013. * @param y defines the 2nd component of the value
  100014. * @param z defines the 3rd component of the value
  100015. */
  100016. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100017. /**
  100018. * Set the value of an uniform to a vec4
  100019. * @param uniform defines the webGL uniform location where to store the value
  100020. * @param x defines the 1st component of the value
  100021. * @param y defines the 2nd component of the value
  100022. * @param z defines the 3rd component of the value
  100023. * @param w defines the 4th component of the value
  100024. */
  100025. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100026. /**
  100027. * Gets the depth culling state manager
  100028. */
  100029. readonly depthCullingState: DepthCullingState;
  100030. /**
  100031. * Gets the alpha state manager
  100032. */
  100033. readonly alphaState: AlphaState;
  100034. /**
  100035. * Gets the stencil state manager
  100036. */
  100037. readonly stencilState: StencilState;
  100038. /**
  100039. * Clears the list of texture accessible through engine.
  100040. * This can help preventing texture load conflict due to name collision.
  100041. */
  100042. clearInternalTexturesCache(): void;
  100043. /**
  100044. * Force the entire cache to be cleared
  100045. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100046. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100047. */
  100048. wipeCaches(bruteForce?: boolean): void;
  100049. /** @hidden */
  100050. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100051. min: number;
  100052. mag: number;
  100053. };
  100054. /** @hidden */
  100055. _createTexture(): WebGLTexture;
  100056. /**
  100057. * Usually called from Texture.ts.
  100058. * Passed information to create a WebGLTexture
  100059. * @param urlArg defines a value which contains one of the following:
  100060. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100061. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100062. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100063. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100064. * @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)
  100065. * @param scene needed for loading to the correct scene
  100066. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100067. * @param onLoad optional callback to be called upon successful completion
  100068. * @param onError optional callback to be called upon failure
  100069. * @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
  100070. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100071. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100072. * @param forcedExtension defines the extension to use to pick the right loader
  100073. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100074. * @param mimeType defines an optional mime type
  100075. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100076. */
  100077. 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;
  100078. /**
  100079. * @hidden
  100080. */
  100081. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100082. /**
  100083. * Creates a raw texture
  100084. * @param data defines the data to store in the texture
  100085. * @param width defines the width of the texture
  100086. * @param height defines the height of the texture
  100087. * @param format defines the format of the data
  100088. * @param generateMipMaps defines if the engine should generate the mip levels
  100089. * @param invertY defines if data must be stored with Y axis inverted
  100090. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100091. * @param compression defines the compression used (null by default)
  100092. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100093. * @returns the raw texture inside an InternalTexture
  100094. */
  100095. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100096. /**
  100097. * Creates a new raw cube texture
  100098. * @param data defines the array of data to use to create each face
  100099. * @param size defines the size of the textures
  100100. * @param format defines the format of the data
  100101. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100102. * @param generateMipMaps defines if the engine should generate the mip levels
  100103. * @param invertY defines if data must be stored with Y axis inverted
  100104. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100105. * @param compression defines the compression used (null by default)
  100106. * @returns the cube texture as an InternalTexture
  100107. */
  100108. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100109. /**
  100110. * Creates a new raw 3D texture
  100111. * @param data defines the data used to create the texture
  100112. * @param width defines the width of the texture
  100113. * @param height defines the height of the texture
  100114. * @param depth defines the depth of the texture
  100115. * @param format defines the format of the texture
  100116. * @param generateMipMaps defines if the engine must generate mip levels
  100117. * @param invertY defines if data must be stored with Y axis inverted
  100118. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100119. * @param compression defines the compressed used (can be null)
  100120. * @param textureType defines the compressed used (can be null)
  100121. * @returns a new raw 3D texture (stored in an InternalTexture)
  100122. */
  100123. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100124. /**
  100125. * Creates a new raw 2D array texture
  100126. * @param data defines the data used to create the texture
  100127. * @param width defines the width of the texture
  100128. * @param height defines the height of the texture
  100129. * @param depth defines the number of layers of the texture
  100130. * @param format defines the format of the texture
  100131. * @param generateMipMaps defines if the engine must generate mip levels
  100132. * @param invertY defines if data must be stored with Y axis inverted
  100133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100134. * @param compression defines the compressed used (can be null)
  100135. * @param textureType defines the compressed used (can be null)
  100136. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100137. */
  100138. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100139. private _unpackFlipYCached;
  100140. /**
  100141. * In case you are sharing the context with other applications, it might
  100142. * be interested to not cache the unpack flip y state to ensure a consistent
  100143. * value would be set.
  100144. */
  100145. enableUnpackFlipYCached: boolean;
  100146. /** @hidden */
  100147. _unpackFlipY(value: boolean): void;
  100148. /** @hidden */
  100149. _getUnpackAlignement(): number;
  100150. /**
  100151. * Update the sampling mode of a given texture
  100152. * @param samplingMode defines the required sampling mode
  100153. * @param texture defines the texture to update
  100154. */
  100155. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100156. /** @hidden */
  100157. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100158. width: number;
  100159. height: number;
  100160. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100161. /** @hidden */
  100162. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100163. /** @hidden */
  100164. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100165. /** @hidden */
  100166. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100167. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100168. private _prepareWebGLTexture;
  100169. /** @hidden */
  100170. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100171. /** @hidden */
  100172. _releaseFramebufferObjects(texture: InternalTexture): void;
  100173. /** @hidden */
  100174. _releaseTexture(texture: InternalTexture): void;
  100175. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100176. protected _setProgram(program: WebGLProgram): void;
  100177. protected _boundUniforms: {
  100178. [key: number]: WebGLUniformLocation;
  100179. };
  100180. /**
  100181. * Binds an effect to the webGL context
  100182. * @param effect defines the effect to bind
  100183. */
  100184. bindSamplers(effect: Effect): void;
  100185. private _activateCurrentTexture;
  100186. /** @hidden */
  100187. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100188. /** @hidden */
  100189. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100190. /**
  100191. * Unbind all textures from the webGL context
  100192. */
  100193. unbindAllTextures(): void;
  100194. /**
  100195. * Sets a texture to the according uniform.
  100196. * @param channel The texture channel
  100197. * @param uniform The uniform to set
  100198. * @param texture The texture to apply
  100199. */
  100200. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100201. private _bindSamplerUniformToChannel;
  100202. private _getTextureWrapMode;
  100203. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100204. /**
  100205. * Sets an array of texture to the webGL context
  100206. * @param channel defines the channel where the texture array must be set
  100207. * @param uniform defines the associated uniform location
  100208. * @param textures defines the array of textures to bind
  100209. */
  100210. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100211. /** @hidden */
  100212. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100213. private _setTextureParameterFloat;
  100214. private _setTextureParameterInteger;
  100215. /**
  100216. * Unbind all vertex attributes from the webGL context
  100217. */
  100218. unbindAllAttributes(): void;
  100219. /**
  100220. * 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
  100221. */
  100222. releaseEffects(): void;
  100223. /**
  100224. * Dispose and release all associated resources
  100225. */
  100226. dispose(): void;
  100227. /**
  100228. * Attach a new callback raised when context lost event is fired
  100229. * @param callback defines the callback to call
  100230. */
  100231. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100232. /**
  100233. * Attach a new callback raised when context restored event is fired
  100234. * @param callback defines the callback to call
  100235. */
  100236. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100237. /**
  100238. * Get the current error code of the webGL context
  100239. * @returns the error code
  100240. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100241. */
  100242. getError(): number;
  100243. private _canRenderToFloatFramebuffer;
  100244. private _canRenderToHalfFloatFramebuffer;
  100245. private _canRenderToFramebuffer;
  100246. /** @hidden */
  100247. _getWebGLTextureType(type: number): number;
  100248. /** @hidden */
  100249. _getInternalFormat(format: number): number;
  100250. /** @hidden */
  100251. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100252. /** @hidden */
  100253. _getRGBAMultiSampleBufferFormat(type: number): number;
  100254. /** @hidden */
  100255. _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;
  100256. /**
  100257. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100258. * @returns true if the engine can be created
  100259. * @ignorenaming
  100260. */
  100261. static isSupported(): boolean;
  100262. /**
  100263. * Find the next highest power of two.
  100264. * @param x Number to start search from.
  100265. * @return Next highest power of two.
  100266. */
  100267. static CeilingPOT(x: number): number;
  100268. /**
  100269. * Find the next lowest power of two.
  100270. * @param x Number to start search from.
  100271. * @return Next lowest power of two.
  100272. */
  100273. static FloorPOT(x: number): number;
  100274. /**
  100275. * Find the nearest power of two.
  100276. * @param x Number to start search from.
  100277. * @return Next nearest power of two.
  100278. */
  100279. static NearestPOT(x: number): number;
  100280. /**
  100281. * Get the closest exponent of two
  100282. * @param value defines the value to approximate
  100283. * @param max defines the maximum value to return
  100284. * @param mode defines how to define the closest value
  100285. * @returns closest exponent of two of the given value
  100286. */
  100287. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100288. /**
  100289. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100290. * @param func - the function to be called
  100291. * @param requester - the object that will request the next frame. Falls back to window.
  100292. * @returns frame number
  100293. */
  100294. static QueueNewFrame(func: () => void, requester?: any): number;
  100295. /**
  100296. * Gets host document
  100297. * @returns the host document object
  100298. */
  100299. getHostDocument(): Document;
  100300. }
  100301. }
  100302. declare module BABYLON {
  100303. /**
  100304. * Class representing spherical harmonics coefficients to the 3rd degree
  100305. */
  100306. export class SphericalHarmonics {
  100307. /**
  100308. * Defines whether or not the harmonics have been prescaled for rendering.
  100309. */
  100310. preScaled: boolean;
  100311. /**
  100312. * The l0,0 coefficients of the spherical harmonics
  100313. */
  100314. l00: Vector3;
  100315. /**
  100316. * The l1,-1 coefficients of the spherical harmonics
  100317. */
  100318. l1_1: Vector3;
  100319. /**
  100320. * The l1,0 coefficients of the spherical harmonics
  100321. */
  100322. l10: Vector3;
  100323. /**
  100324. * The l1,1 coefficients of the spherical harmonics
  100325. */
  100326. l11: Vector3;
  100327. /**
  100328. * The l2,-2 coefficients of the spherical harmonics
  100329. */
  100330. l2_2: Vector3;
  100331. /**
  100332. * The l2,-1 coefficients of the spherical harmonics
  100333. */
  100334. l2_1: Vector3;
  100335. /**
  100336. * The l2,0 coefficients of the spherical harmonics
  100337. */
  100338. l20: Vector3;
  100339. /**
  100340. * The l2,1 coefficients of the spherical harmonics
  100341. */
  100342. l21: Vector3;
  100343. /**
  100344. * The l2,2 coefficients of the spherical harmonics
  100345. */
  100346. l22: Vector3;
  100347. /**
  100348. * Adds a light to the spherical harmonics
  100349. * @param direction the direction of the light
  100350. * @param color the color of the light
  100351. * @param deltaSolidAngle the delta solid angle of the light
  100352. */
  100353. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100354. /**
  100355. * Scales the spherical harmonics by the given amount
  100356. * @param scale the amount to scale
  100357. */
  100358. scaleInPlace(scale: number): void;
  100359. /**
  100360. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100361. *
  100362. * ```
  100363. * E_lm = A_l * L_lm
  100364. * ```
  100365. *
  100366. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100367. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100368. * the scaling factors are given in equation 9.
  100369. */
  100370. convertIncidentRadianceToIrradiance(): void;
  100371. /**
  100372. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100373. *
  100374. * ```
  100375. * L = (1/pi) * E * rho
  100376. * ```
  100377. *
  100378. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100379. */
  100380. convertIrradianceToLambertianRadiance(): void;
  100381. /**
  100382. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100383. * required operations at run time.
  100384. *
  100385. * This is simply done by scaling back the SH with Ylm constants parameter.
  100386. * The trigonometric part being applied by the shader at run time.
  100387. */
  100388. preScaleForRendering(): void;
  100389. /**
  100390. * Constructs a spherical harmonics from an array.
  100391. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100392. * @returns the spherical harmonics
  100393. */
  100394. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100395. /**
  100396. * Gets the spherical harmonics from polynomial
  100397. * @param polynomial the spherical polynomial
  100398. * @returns the spherical harmonics
  100399. */
  100400. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100401. }
  100402. /**
  100403. * Class representing spherical polynomial coefficients to the 3rd degree
  100404. */
  100405. export class SphericalPolynomial {
  100406. private _harmonics;
  100407. /**
  100408. * The spherical harmonics used to create the polynomials.
  100409. */
  100410. readonly preScaledHarmonics: SphericalHarmonics;
  100411. /**
  100412. * The x coefficients of the spherical polynomial
  100413. */
  100414. x: Vector3;
  100415. /**
  100416. * The y coefficients of the spherical polynomial
  100417. */
  100418. y: Vector3;
  100419. /**
  100420. * The z coefficients of the spherical polynomial
  100421. */
  100422. z: Vector3;
  100423. /**
  100424. * The xx coefficients of the spherical polynomial
  100425. */
  100426. xx: Vector3;
  100427. /**
  100428. * The yy coefficients of the spherical polynomial
  100429. */
  100430. yy: Vector3;
  100431. /**
  100432. * The zz coefficients of the spherical polynomial
  100433. */
  100434. zz: Vector3;
  100435. /**
  100436. * The xy coefficients of the spherical polynomial
  100437. */
  100438. xy: Vector3;
  100439. /**
  100440. * The yz coefficients of the spherical polynomial
  100441. */
  100442. yz: Vector3;
  100443. /**
  100444. * The zx coefficients of the spherical polynomial
  100445. */
  100446. zx: Vector3;
  100447. /**
  100448. * Adds an ambient color to the spherical polynomial
  100449. * @param color the color to add
  100450. */
  100451. addAmbient(color: Color3): void;
  100452. /**
  100453. * Scales the spherical polynomial by the given amount
  100454. * @param scale the amount to scale
  100455. */
  100456. scaleInPlace(scale: number): void;
  100457. /**
  100458. * Gets the spherical polynomial from harmonics
  100459. * @param harmonics the spherical harmonics
  100460. * @returns the spherical polynomial
  100461. */
  100462. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  100463. /**
  100464. * Constructs a spherical polynomial from an array.
  100465. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  100466. * @returns the spherical polynomial
  100467. */
  100468. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  100469. }
  100470. }
  100471. declare module BABYLON {
  100472. /**
  100473. * Defines the source of the internal texture
  100474. */
  100475. export enum InternalTextureSource {
  100476. /**
  100477. * The source of the texture data is unknown
  100478. */
  100479. Unknown = 0,
  100480. /**
  100481. * Texture data comes from an URL
  100482. */
  100483. Url = 1,
  100484. /**
  100485. * Texture data is only used for temporary storage
  100486. */
  100487. Temp = 2,
  100488. /**
  100489. * Texture data comes from raw data (ArrayBuffer)
  100490. */
  100491. Raw = 3,
  100492. /**
  100493. * Texture content is dynamic (video or dynamic texture)
  100494. */
  100495. Dynamic = 4,
  100496. /**
  100497. * Texture content is generated by rendering to it
  100498. */
  100499. RenderTarget = 5,
  100500. /**
  100501. * Texture content is part of a multi render target process
  100502. */
  100503. MultiRenderTarget = 6,
  100504. /**
  100505. * Texture data comes from a cube data file
  100506. */
  100507. Cube = 7,
  100508. /**
  100509. * Texture data comes from a raw cube data
  100510. */
  100511. CubeRaw = 8,
  100512. /**
  100513. * Texture data come from a prefiltered cube data file
  100514. */
  100515. CubePrefiltered = 9,
  100516. /**
  100517. * Texture content is raw 3D data
  100518. */
  100519. Raw3D = 10,
  100520. /**
  100521. * Texture content is raw 2D array data
  100522. */
  100523. Raw2DArray = 11,
  100524. /**
  100525. * Texture content is a depth texture
  100526. */
  100527. Depth = 12,
  100528. /**
  100529. * Texture data comes from a raw cube data encoded with RGBD
  100530. */
  100531. CubeRawRGBD = 13
  100532. }
  100533. /**
  100534. * Class used to store data associated with WebGL texture data for the engine
  100535. * This class should not be used directly
  100536. */
  100537. export class InternalTexture {
  100538. /** @hidden */
  100539. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  100540. /**
  100541. * Defines if the texture is ready
  100542. */
  100543. isReady: boolean;
  100544. /**
  100545. * Defines if the texture is a cube texture
  100546. */
  100547. isCube: boolean;
  100548. /**
  100549. * Defines if the texture contains 3D data
  100550. */
  100551. is3D: boolean;
  100552. /**
  100553. * Defines if the texture contains 2D array data
  100554. */
  100555. is2DArray: boolean;
  100556. /**
  100557. * Defines if the texture contains multiview data
  100558. */
  100559. isMultiview: boolean;
  100560. /**
  100561. * Gets the URL used to load this texture
  100562. */
  100563. url: string;
  100564. /**
  100565. * Gets the sampling mode of the texture
  100566. */
  100567. samplingMode: number;
  100568. /**
  100569. * Gets a boolean indicating if the texture needs mipmaps generation
  100570. */
  100571. generateMipMaps: boolean;
  100572. /**
  100573. * Gets the number of samples used by the texture (WebGL2+ only)
  100574. */
  100575. samples: number;
  100576. /**
  100577. * Gets the type of the texture (int, float...)
  100578. */
  100579. type: number;
  100580. /**
  100581. * Gets the format of the texture (RGB, RGBA...)
  100582. */
  100583. format: number;
  100584. /**
  100585. * Observable called when the texture is loaded
  100586. */
  100587. onLoadedObservable: Observable<InternalTexture>;
  100588. /**
  100589. * Gets the width of the texture
  100590. */
  100591. width: number;
  100592. /**
  100593. * Gets the height of the texture
  100594. */
  100595. height: number;
  100596. /**
  100597. * Gets the depth of the texture
  100598. */
  100599. depth: number;
  100600. /**
  100601. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  100602. */
  100603. baseWidth: number;
  100604. /**
  100605. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  100606. */
  100607. baseHeight: number;
  100608. /**
  100609. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  100610. */
  100611. baseDepth: number;
  100612. /**
  100613. * Gets a boolean indicating if the texture is inverted on Y axis
  100614. */
  100615. invertY: boolean;
  100616. /** @hidden */
  100617. _invertVScale: boolean;
  100618. /** @hidden */
  100619. _associatedChannel: number;
  100620. /** @hidden */
  100621. _source: InternalTextureSource;
  100622. /** @hidden */
  100623. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100624. /** @hidden */
  100625. _bufferView: Nullable<ArrayBufferView>;
  100626. /** @hidden */
  100627. _bufferViewArray: Nullable<ArrayBufferView[]>;
  100628. /** @hidden */
  100629. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  100630. /** @hidden */
  100631. _size: number;
  100632. /** @hidden */
  100633. _extension: string;
  100634. /** @hidden */
  100635. _files: Nullable<string[]>;
  100636. /** @hidden */
  100637. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  100638. /** @hidden */
  100639. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  100640. /** @hidden */
  100641. _framebuffer: Nullable<WebGLFramebuffer>;
  100642. /** @hidden */
  100643. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  100644. /** @hidden */
  100645. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  100646. /** @hidden */
  100647. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  100648. /** @hidden */
  100649. _attachments: Nullable<number[]>;
  100650. /** @hidden */
  100651. _cachedCoordinatesMode: Nullable<number>;
  100652. /** @hidden */
  100653. _cachedWrapU: Nullable<number>;
  100654. /** @hidden */
  100655. _cachedWrapV: Nullable<number>;
  100656. /** @hidden */
  100657. _cachedWrapR: Nullable<number>;
  100658. /** @hidden */
  100659. _cachedAnisotropicFilteringLevel: Nullable<number>;
  100660. /** @hidden */
  100661. _isDisabled: boolean;
  100662. /** @hidden */
  100663. _compression: Nullable<string>;
  100664. /** @hidden */
  100665. _generateStencilBuffer: boolean;
  100666. /** @hidden */
  100667. _generateDepthBuffer: boolean;
  100668. /** @hidden */
  100669. _comparisonFunction: number;
  100670. /** @hidden */
  100671. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  100672. /** @hidden */
  100673. _lodGenerationScale: number;
  100674. /** @hidden */
  100675. _lodGenerationOffset: number;
  100676. /** @hidden */
  100677. _colorTextureArray: Nullable<WebGLTexture>;
  100678. /** @hidden */
  100679. _depthStencilTextureArray: Nullable<WebGLTexture>;
  100680. /** @hidden */
  100681. _lodTextureHigh: Nullable<BaseTexture>;
  100682. /** @hidden */
  100683. _lodTextureMid: Nullable<BaseTexture>;
  100684. /** @hidden */
  100685. _lodTextureLow: Nullable<BaseTexture>;
  100686. /** @hidden */
  100687. _isRGBD: boolean;
  100688. /** @hidden */
  100689. _linearSpecularLOD: boolean;
  100690. /** @hidden */
  100691. _irradianceTexture: Nullable<BaseTexture>;
  100692. /** @hidden */
  100693. _webGLTexture: Nullable<WebGLTexture>;
  100694. /** @hidden */
  100695. _references: number;
  100696. private _engine;
  100697. /**
  100698. * Gets the Engine the texture belongs to.
  100699. * @returns The babylon engine
  100700. */
  100701. getEngine(): ThinEngine;
  100702. /**
  100703. * Gets the data source type of the texture
  100704. */
  100705. readonly source: InternalTextureSource;
  100706. /**
  100707. * Creates a new InternalTexture
  100708. * @param engine defines the engine to use
  100709. * @param source defines the type of data that will be used
  100710. * @param delayAllocation if the texture allocation should be delayed (default: false)
  100711. */
  100712. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  100713. /**
  100714. * Increments the number of references (ie. the number of Texture that point to it)
  100715. */
  100716. incrementReferences(): void;
  100717. /**
  100718. * Change the size of the texture (not the size of the content)
  100719. * @param width defines the new width
  100720. * @param height defines the new height
  100721. * @param depth defines the new depth (1 by default)
  100722. */
  100723. updateSize(width: int, height: int, depth?: int): void;
  100724. /** @hidden */
  100725. _rebuild(): void;
  100726. /** @hidden */
  100727. _swapAndDie(target: InternalTexture): void;
  100728. /**
  100729. * Dispose the current allocated resources
  100730. */
  100731. dispose(): void;
  100732. }
  100733. }
  100734. declare module BABYLON {
  100735. /**
  100736. * Class used to work with sound analyzer using fast fourier transform (FFT)
  100737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100738. */
  100739. export class Analyser {
  100740. /**
  100741. * Gets or sets the smoothing
  100742. * @ignorenaming
  100743. */
  100744. SMOOTHING: number;
  100745. /**
  100746. * Gets or sets the FFT table size
  100747. * @ignorenaming
  100748. */
  100749. FFT_SIZE: number;
  100750. /**
  100751. * Gets or sets the bar graph amplitude
  100752. * @ignorenaming
  100753. */
  100754. BARGRAPHAMPLITUDE: number;
  100755. /**
  100756. * Gets or sets the position of the debug canvas
  100757. * @ignorenaming
  100758. */
  100759. DEBUGCANVASPOS: {
  100760. x: number;
  100761. y: number;
  100762. };
  100763. /**
  100764. * Gets or sets the debug canvas size
  100765. * @ignorenaming
  100766. */
  100767. DEBUGCANVASSIZE: {
  100768. width: number;
  100769. height: number;
  100770. };
  100771. private _byteFreqs;
  100772. private _byteTime;
  100773. private _floatFreqs;
  100774. private _webAudioAnalyser;
  100775. private _debugCanvas;
  100776. private _debugCanvasContext;
  100777. private _scene;
  100778. private _registerFunc;
  100779. private _audioEngine;
  100780. /**
  100781. * Creates a new analyser
  100782. * @param scene defines hosting scene
  100783. */
  100784. constructor(scene: Scene);
  100785. /**
  100786. * Get the number of data values you will have to play with for the visualization
  100787. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  100788. * @returns a number
  100789. */
  100790. getFrequencyBinCount(): number;
  100791. /**
  100792. * Gets the current frequency data as a byte array
  100793. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100794. * @returns a Uint8Array
  100795. */
  100796. getByteFrequencyData(): Uint8Array;
  100797. /**
  100798. * Gets the current waveform as a byte array
  100799. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  100800. * @returns a Uint8Array
  100801. */
  100802. getByteTimeDomainData(): Uint8Array;
  100803. /**
  100804. * Gets the current frequency data as a float array
  100805. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  100806. * @returns a Float32Array
  100807. */
  100808. getFloatFrequencyData(): Float32Array;
  100809. /**
  100810. * Renders the debug canvas
  100811. */
  100812. drawDebugCanvas(): void;
  100813. /**
  100814. * Stops rendering the debug canvas and removes it
  100815. */
  100816. stopDebugCanvas(): void;
  100817. /**
  100818. * Connects two audio nodes
  100819. * @param inputAudioNode defines first node to connect
  100820. * @param outputAudioNode defines second node to connect
  100821. */
  100822. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  100823. /**
  100824. * Releases all associated resources
  100825. */
  100826. dispose(): void;
  100827. }
  100828. }
  100829. declare module BABYLON {
  100830. /**
  100831. * This represents an audio engine and it is responsible
  100832. * to play, synchronize and analyse sounds throughout the application.
  100833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100834. */
  100835. export interface IAudioEngine extends IDisposable {
  100836. /**
  100837. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100838. */
  100839. readonly canUseWebAudio: boolean;
  100840. /**
  100841. * Gets the current AudioContext if available.
  100842. */
  100843. readonly audioContext: Nullable<AudioContext>;
  100844. /**
  100845. * The master gain node defines the global audio volume of your audio engine.
  100846. */
  100847. readonly masterGain: GainNode;
  100848. /**
  100849. * Gets whether or not mp3 are supported by your browser.
  100850. */
  100851. readonly isMP3supported: boolean;
  100852. /**
  100853. * Gets whether or not ogg are supported by your browser.
  100854. */
  100855. readonly isOGGsupported: boolean;
  100856. /**
  100857. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100858. * @ignoreNaming
  100859. */
  100860. WarnedWebAudioUnsupported: boolean;
  100861. /**
  100862. * Defines if the audio engine relies on a custom unlocked button.
  100863. * In this case, the embedded button will not be displayed.
  100864. */
  100865. useCustomUnlockedButton: boolean;
  100866. /**
  100867. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  100868. */
  100869. readonly unlocked: boolean;
  100870. /**
  100871. * Event raised when audio has been unlocked on the browser.
  100872. */
  100873. onAudioUnlockedObservable: Observable<AudioEngine>;
  100874. /**
  100875. * Event raised when audio has been locked on the browser.
  100876. */
  100877. onAudioLockedObservable: Observable<AudioEngine>;
  100878. /**
  100879. * Flags the audio engine in Locked state.
  100880. * This happens due to new browser policies preventing audio to autoplay.
  100881. */
  100882. lock(): void;
  100883. /**
  100884. * Unlocks the audio engine once a user action has been done on the dom.
  100885. * This is helpful to resume play once browser policies have been satisfied.
  100886. */
  100887. unlock(): void;
  100888. }
  100889. /**
  100890. * This represents the default audio engine used in babylon.
  100891. * It is responsible to play, synchronize and analyse sounds throughout the application.
  100892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100893. */
  100894. export class AudioEngine implements IAudioEngine {
  100895. private _audioContext;
  100896. private _audioContextInitialized;
  100897. private _muteButton;
  100898. private _hostElement;
  100899. /**
  100900. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  100901. */
  100902. canUseWebAudio: boolean;
  100903. /**
  100904. * The master gain node defines the global audio volume of your audio engine.
  100905. */
  100906. masterGain: GainNode;
  100907. /**
  100908. * Defines if Babylon should emit a warning if WebAudio is not supported.
  100909. * @ignoreNaming
  100910. */
  100911. WarnedWebAudioUnsupported: boolean;
  100912. /**
  100913. * Gets whether or not mp3 are supported by your browser.
  100914. */
  100915. isMP3supported: boolean;
  100916. /**
  100917. * Gets whether or not ogg are supported by your browser.
  100918. */
  100919. isOGGsupported: boolean;
  100920. /**
  100921. * Gets whether audio has been unlocked on the device.
  100922. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  100923. * a user interaction has happened.
  100924. */
  100925. unlocked: boolean;
  100926. /**
  100927. * Defines if the audio engine relies on a custom unlocked button.
  100928. * In this case, the embedded button will not be displayed.
  100929. */
  100930. useCustomUnlockedButton: boolean;
  100931. /**
  100932. * Event raised when audio has been unlocked on the browser.
  100933. */
  100934. onAudioUnlockedObservable: Observable<AudioEngine>;
  100935. /**
  100936. * Event raised when audio has been locked on the browser.
  100937. */
  100938. onAudioLockedObservable: Observable<AudioEngine>;
  100939. /**
  100940. * Gets the current AudioContext if available.
  100941. */
  100942. readonly audioContext: Nullable<AudioContext>;
  100943. private _connectedAnalyser;
  100944. /**
  100945. * Instantiates a new audio engine.
  100946. *
  100947. * There should be only one per page as some browsers restrict the number
  100948. * of audio contexts you can create.
  100949. * @param hostElement defines the host element where to display the mute icon if necessary
  100950. */
  100951. constructor(hostElement?: Nullable<HTMLElement>);
  100952. /**
  100953. * Flags the audio engine in Locked state.
  100954. * This happens due to new browser policies preventing audio to autoplay.
  100955. */
  100956. lock(): void;
  100957. /**
  100958. * Unlocks the audio engine once a user action has been done on the dom.
  100959. * This is helpful to resume play once browser policies have been satisfied.
  100960. */
  100961. unlock(): void;
  100962. private _resumeAudioContext;
  100963. private _initializeAudioContext;
  100964. private _tryToRun;
  100965. private _triggerRunningState;
  100966. private _triggerSuspendedState;
  100967. private _displayMuteButton;
  100968. private _moveButtonToTopLeft;
  100969. private _onResize;
  100970. private _hideMuteButton;
  100971. /**
  100972. * Destroy and release the resources associated with the audio ccontext.
  100973. */
  100974. dispose(): void;
  100975. /**
  100976. * Gets the global volume sets on the master gain.
  100977. * @returns the global volume if set or -1 otherwise
  100978. */
  100979. getGlobalVolume(): number;
  100980. /**
  100981. * Sets the global volume of your experience (sets on the master gain).
  100982. * @param newVolume Defines the new global volume of the application
  100983. */
  100984. setGlobalVolume(newVolume: number): void;
  100985. /**
  100986. * Connect the audio engine to an audio analyser allowing some amazing
  100987. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  100988. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  100989. * @param analyser The analyser to connect to the engine
  100990. */
  100991. connectToAnalyser(analyser: Analyser): void;
  100992. }
  100993. }
  100994. declare module BABYLON {
  100995. /**
  100996. * Interface used to present a loading screen while loading a scene
  100997. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100998. */
  100999. export interface ILoadingScreen {
  101000. /**
  101001. * Function called to display the loading screen
  101002. */
  101003. displayLoadingUI: () => void;
  101004. /**
  101005. * Function called to hide the loading screen
  101006. */
  101007. hideLoadingUI: () => void;
  101008. /**
  101009. * Gets or sets the color to use for the background
  101010. */
  101011. loadingUIBackgroundColor: string;
  101012. /**
  101013. * Gets or sets the text to display while loading
  101014. */
  101015. loadingUIText: string;
  101016. }
  101017. /**
  101018. * Class used for the default loading screen
  101019. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101020. */
  101021. export class DefaultLoadingScreen implements ILoadingScreen {
  101022. private _renderingCanvas;
  101023. private _loadingText;
  101024. private _loadingDivBackgroundColor;
  101025. private _loadingDiv;
  101026. private _loadingTextDiv;
  101027. /** Gets or sets the logo url to use for the default loading screen */
  101028. static DefaultLogoUrl: string;
  101029. /** Gets or sets the spinner url to use for the default loading screen */
  101030. static DefaultSpinnerUrl: string;
  101031. /**
  101032. * Creates a new default loading screen
  101033. * @param _renderingCanvas defines the canvas used to render the scene
  101034. * @param _loadingText defines the default text to display
  101035. * @param _loadingDivBackgroundColor defines the default background color
  101036. */
  101037. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101038. /**
  101039. * Function called to display the loading screen
  101040. */
  101041. displayLoadingUI(): void;
  101042. /**
  101043. * Function called to hide the loading screen
  101044. */
  101045. hideLoadingUI(): void;
  101046. /**
  101047. * Gets or sets the text to display while loading
  101048. */
  101049. loadingUIText: string;
  101050. /**
  101051. * Gets or sets the color to use for the background
  101052. */
  101053. loadingUIBackgroundColor: string;
  101054. private _resizeLoadingUI;
  101055. }
  101056. }
  101057. declare module BABYLON {
  101058. /**
  101059. * Interface for any object that can request an animation frame
  101060. */
  101061. export interface ICustomAnimationFrameRequester {
  101062. /**
  101063. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101064. */
  101065. renderFunction?: Function;
  101066. /**
  101067. * Called to request the next frame to render to
  101068. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101069. */
  101070. requestAnimationFrame: Function;
  101071. /**
  101072. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101073. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101074. */
  101075. requestID?: number;
  101076. }
  101077. }
  101078. declare module BABYLON {
  101079. /**
  101080. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101081. */
  101082. export class PerformanceMonitor {
  101083. private _enabled;
  101084. private _rollingFrameTime;
  101085. private _lastFrameTimeMs;
  101086. /**
  101087. * constructor
  101088. * @param frameSampleSize The number of samples required to saturate the sliding window
  101089. */
  101090. constructor(frameSampleSize?: number);
  101091. /**
  101092. * Samples current frame
  101093. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101094. */
  101095. sampleFrame(timeMs?: number): void;
  101096. /**
  101097. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101098. */
  101099. readonly averageFrameTime: number;
  101100. /**
  101101. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101102. */
  101103. readonly averageFrameTimeVariance: number;
  101104. /**
  101105. * Returns the frame time of the most recent frame
  101106. */
  101107. readonly instantaneousFrameTime: number;
  101108. /**
  101109. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101110. */
  101111. readonly averageFPS: number;
  101112. /**
  101113. * Returns the average framerate in frames per second using the most recent frame time
  101114. */
  101115. readonly instantaneousFPS: number;
  101116. /**
  101117. * Returns true if enough samples have been taken to completely fill the sliding window
  101118. */
  101119. readonly isSaturated: boolean;
  101120. /**
  101121. * Enables contributions to the sliding window sample set
  101122. */
  101123. enable(): void;
  101124. /**
  101125. * Disables contributions to the sliding window sample set
  101126. * Samples will not be interpolated over the disabled period
  101127. */
  101128. disable(): void;
  101129. /**
  101130. * Returns true if sampling is enabled
  101131. */
  101132. readonly isEnabled: boolean;
  101133. /**
  101134. * Resets performance monitor
  101135. */
  101136. reset(): void;
  101137. }
  101138. /**
  101139. * RollingAverage
  101140. *
  101141. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101142. */
  101143. export class RollingAverage {
  101144. /**
  101145. * Current average
  101146. */
  101147. average: number;
  101148. /**
  101149. * Current variance
  101150. */
  101151. variance: number;
  101152. protected _samples: Array<number>;
  101153. protected _sampleCount: number;
  101154. protected _pos: number;
  101155. protected _m2: number;
  101156. /**
  101157. * constructor
  101158. * @param length The number of samples required to saturate the sliding window
  101159. */
  101160. constructor(length: number);
  101161. /**
  101162. * Adds a sample to the sample set
  101163. * @param v The sample value
  101164. */
  101165. add(v: number): void;
  101166. /**
  101167. * Returns previously added values or null if outside of history or outside the sliding window domain
  101168. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101169. * @return Value previously recorded with add() or null if outside of range
  101170. */
  101171. history(i: number): number;
  101172. /**
  101173. * Returns true if enough samples have been taken to completely fill the sliding window
  101174. * @return true if sample-set saturated
  101175. */
  101176. isSaturated(): boolean;
  101177. /**
  101178. * Resets the rolling average (equivalent to 0 samples taken so far)
  101179. */
  101180. reset(): void;
  101181. /**
  101182. * Wraps a value around the sample range boundaries
  101183. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101184. * @return Wrapped position in sample range
  101185. */
  101186. protected _wrapPosition(i: number): number;
  101187. }
  101188. }
  101189. declare module BABYLON {
  101190. /**
  101191. * This class is used to track a performance counter which is number based.
  101192. * The user has access to many properties which give statistics of different nature.
  101193. *
  101194. * The implementer can track two kinds of Performance Counter: time and count.
  101195. * 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.
  101196. * 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.
  101197. */
  101198. export class PerfCounter {
  101199. /**
  101200. * Gets or sets a global boolean to turn on and off all the counters
  101201. */
  101202. static Enabled: boolean;
  101203. /**
  101204. * Returns the smallest value ever
  101205. */
  101206. readonly min: number;
  101207. /**
  101208. * Returns the biggest value ever
  101209. */
  101210. readonly max: number;
  101211. /**
  101212. * Returns the average value since the performance counter is running
  101213. */
  101214. readonly average: number;
  101215. /**
  101216. * Returns the average value of the last second the counter was monitored
  101217. */
  101218. readonly lastSecAverage: number;
  101219. /**
  101220. * Returns the current value
  101221. */
  101222. readonly current: number;
  101223. /**
  101224. * Gets the accumulated total
  101225. */
  101226. readonly total: number;
  101227. /**
  101228. * Gets the total value count
  101229. */
  101230. readonly count: number;
  101231. /**
  101232. * Creates a new counter
  101233. */
  101234. constructor();
  101235. /**
  101236. * Call this method to start monitoring a new frame.
  101237. * 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.
  101238. */
  101239. fetchNewFrame(): void;
  101240. /**
  101241. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101242. * @param newCount the count value to add to the monitored count
  101243. * @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.
  101244. */
  101245. addCount(newCount: number, fetchResult: boolean): void;
  101246. /**
  101247. * Start monitoring this performance counter
  101248. */
  101249. beginMonitoring(): void;
  101250. /**
  101251. * Compute the time lapsed since the previous beginMonitoring() call.
  101252. * @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
  101253. */
  101254. endMonitoring(newFrame?: boolean): void;
  101255. private _fetchResult;
  101256. private _startMonitoringTime;
  101257. private _min;
  101258. private _max;
  101259. private _average;
  101260. private _current;
  101261. private _totalValueCount;
  101262. private _totalAccumulated;
  101263. private _lastSecAverage;
  101264. private _lastSecAccumulated;
  101265. private _lastSecTime;
  101266. private _lastSecValueCount;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. /**
  101271. * Defines the interface used by display changed events
  101272. */
  101273. export interface IDisplayChangedEventArgs {
  101274. /** Gets the vrDisplay object (if any) */
  101275. vrDisplay: Nullable<any>;
  101276. /** Gets a boolean indicating if webVR is supported */
  101277. vrSupported: boolean;
  101278. }
  101279. /**
  101280. * Defines the interface used by objects containing a viewport (like a camera)
  101281. */
  101282. interface IViewportOwnerLike {
  101283. /**
  101284. * Gets or sets the viewport
  101285. */
  101286. viewport: IViewportLike;
  101287. }
  101288. /**
  101289. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101290. */
  101291. export class Engine extends ThinEngine {
  101292. /** Defines that alpha blending is disabled */
  101293. static readonly ALPHA_DISABLE: number;
  101294. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101295. static readonly ALPHA_ADD: number;
  101296. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101297. static readonly ALPHA_COMBINE: number;
  101298. /** Defines that alpha blending to DEST - SRC * DEST */
  101299. static readonly ALPHA_SUBTRACT: number;
  101300. /** Defines that alpha blending to SRC * DEST */
  101301. static readonly ALPHA_MULTIPLY: number;
  101302. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101303. static readonly ALPHA_MAXIMIZED: number;
  101304. /** Defines that alpha blending to SRC + DEST */
  101305. static readonly ALPHA_ONEONE: number;
  101306. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101307. static readonly ALPHA_PREMULTIPLIED: number;
  101308. /**
  101309. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101310. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101311. */
  101312. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101313. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101314. static readonly ALPHA_INTERPOLATE: number;
  101315. /**
  101316. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101317. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101318. */
  101319. static readonly ALPHA_SCREENMODE: number;
  101320. /** Defines that the ressource is not delayed*/
  101321. static readonly DELAYLOADSTATE_NONE: number;
  101322. /** Defines that the ressource was successfully delay loaded */
  101323. static readonly DELAYLOADSTATE_LOADED: number;
  101324. /** Defines that the ressource is currently delay loading */
  101325. static readonly DELAYLOADSTATE_LOADING: number;
  101326. /** Defines that the ressource is delayed and has not started loading */
  101327. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101328. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101329. static readonly NEVER: number;
  101330. /** 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 */
  101331. static readonly ALWAYS: number;
  101332. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101333. static readonly LESS: number;
  101334. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101335. static readonly EQUAL: number;
  101336. /** 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 */
  101337. static readonly LEQUAL: number;
  101338. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101339. static readonly GREATER: number;
  101340. /** 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 */
  101341. static readonly GEQUAL: number;
  101342. /** 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 */
  101343. static readonly NOTEQUAL: number;
  101344. /** Passed to stencilOperation to specify that stencil value must be kept */
  101345. static readonly KEEP: number;
  101346. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101347. static readonly REPLACE: number;
  101348. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101349. static readonly INCR: number;
  101350. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101351. static readonly DECR: number;
  101352. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101353. static readonly INVERT: number;
  101354. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101355. static readonly INCR_WRAP: number;
  101356. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101357. static readonly DECR_WRAP: number;
  101358. /** Texture is not repeating outside of 0..1 UVs */
  101359. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101360. /** Texture is repeating outside of 0..1 UVs */
  101361. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101362. /** Texture is repeating and mirrored */
  101363. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101364. /** ALPHA */
  101365. static readonly TEXTUREFORMAT_ALPHA: number;
  101366. /** LUMINANCE */
  101367. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101368. /** LUMINANCE_ALPHA */
  101369. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101370. /** RGB */
  101371. static readonly TEXTUREFORMAT_RGB: number;
  101372. /** RGBA */
  101373. static readonly TEXTUREFORMAT_RGBA: number;
  101374. /** RED */
  101375. static readonly TEXTUREFORMAT_RED: number;
  101376. /** RED (2nd reference) */
  101377. static readonly TEXTUREFORMAT_R: number;
  101378. /** RG */
  101379. static readonly TEXTUREFORMAT_RG: number;
  101380. /** RED_INTEGER */
  101381. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101382. /** RED_INTEGER (2nd reference) */
  101383. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101384. /** RG_INTEGER */
  101385. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101386. /** RGB_INTEGER */
  101387. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101388. /** RGBA_INTEGER */
  101389. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101390. /** UNSIGNED_BYTE */
  101391. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101392. /** UNSIGNED_BYTE (2nd reference) */
  101393. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101394. /** FLOAT */
  101395. static readonly TEXTURETYPE_FLOAT: number;
  101396. /** HALF_FLOAT */
  101397. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101398. /** BYTE */
  101399. static readonly TEXTURETYPE_BYTE: number;
  101400. /** SHORT */
  101401. static readonly TEXTURETYPE_SHORT: number;
  101402. /** UNSIGNED_SHORT */
  101403. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101404. /** INT */
  101405. static readonly TEXTURETYPE_INT: number;
  101406. /** UNSIGNED_INT */
  101407. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101408. /** UNSIGNED_SHORT_4_4_4_4 */
  101409. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101410. /** UNSIGNED_SHORT_5_5_5_1 */
  101411. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101412. /** UNSIGNED_SHORT_5_6_5 */
  101413. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101414. /** UNSIGNED_INT_2_10_10_10_REV */
  101415. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101416. /** UNSIGNED_INT_24_8 */
  101417. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101418. /** UNSIGNED_INT_10F_11F_11F_REV */
  101419. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101420. /** UNSIGNED_INT_5_9_9_9_REV */
  101421. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101422. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101423. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101424. /** nearest is mag = nearest and min = nearest and mip = linear */
  101425. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101426. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101427. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  101428. /** Trilinear is mag = linear and min = linear and mip = linear */
  101429. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  101430. /** nearest is mag = nearest and min = nearest and mip = linear */
  101431. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  101432. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101433. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  101434. /** Trilinear is mag = linear and min = linear and mip = linear */
  101435. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  101436. /** mag = nearest and min = nearest and mip = nearest */
  101437. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  101438. /** mag = nearest and min = linear and mip = nearest */
  101439. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  101440. /** mag = nearest and min = linear and mip = linear */
  101441. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  101442. /** mag = nearest and min = linear and mip = none */
  101443. static readonly TEXTURE_NEAREST_LINEAR: number;
  101444. /** mag = nearest and min = nearest and mip = none */
  101445. static readonly TEXTURE_NEAREST_NEAREST: number;
  101446. /** mag = linear and min = nearest and mip = nearest */
  101447. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  101448. /** mag = linear and min = nearest and mip = linear */
  101449. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  101450. /** mag = linear and min = linear and mip = none */
  101451. static readonly TEXTURE_LINEAR_LINEAR: number;
  101452. /** mag = linear and min = nearest and mip = none */
  101453. static readonly TEXTURE_LINEAR_NEAREST: number;
  101454. /** Explicit coordinates mode */
  101455. static readonly TEXTURE_EXPLICIT_MODE: number;
  101456. /** Spherical coordinates mode */
  101457. static readonly TEXTURE_SPHERICAL_MODE: number;
  101458. /** Planar coordinates mode */
  101459. static readonly TEXTURE_PLANAR_MODE: number;
  101460. /** Cubic coordinates mode */
  101461. static readonly TEXTURE_CUBIC_MODE: number;
  101462. /** Projection coordinates mode */
  101463. static readonly TEXTURE_PROJECTION_MODE: number;
  101464. /** Skybox coordinates mode */
  101465. static readonly TEXTURE_SKYBOX_MODE: number;
  101466. /** Inverse Cubic coordinates mode */
  101467. static readonly TEXTURE_INVCUBIC_MODE: number;
  101468. /** Equirectangular coordinates mode */
  101469. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  101470. /** Equirectangular Fixed coordinates mode */
  101471. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  101472. /** Equirectangular Fixed Mirrored coordinates mode */
  101473. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101474. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  101475. static readonly SCALEMODE_FLOOR: number;
  101476. /** Defines that texture rescaling will look for the nearest power of 2 size */
  101477. static readonly SCALEMODE_NEAREST: number;
  101478. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  101479. static readonly SCALEMODE_CEILING: number;
  101480. /**
  101481. * Returns the current npm package of the sdk
  101482. */
  101483. static readonly NpmPackage: string;
  101484. /**
  101485. * Returns the current version of the framework
  101486. */
  101487. static readonly Version: string;
  101488. /** Gets the list of created engines */
  101489. static readonly Instances: Engine[];
  101490. /**
  101491. * Gets the latest created engine
  101492. */
  101493. static readonly LastCreatedEngine: Nullable<Engine>;
  101494. /**
  101495. * Gets the latest created scene
  101496. */
  101497. static readonly LastCreatedScene: Nullable<Scene>;
  101498. /**
  101499. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  101500. * @param flag defines which part of the materials must be marked as dirty
  101501. * @param predicate defines a predicate used to filter which materials should be affected
  101502. */
  101503. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101504. /**
  101505. * Method called to create the default loading screen.
  101506. * This can be overriden in your own app.
  101507. * @param canvas The rendering canvas element
  101508. * @returns The loading screen
  101509. */
  101510. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  101511. /**
  101512. * Method called to create the default rescale post process on each engine.
  101513. */
  101514. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  101515. /**
  101516. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  101517. **/
  101518. enableOfflineSupport: boolean;
  101519. /**
  101520. * 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)
  101521. **/
  101522. disableManifestCheck: boolean;
  101523. /**
  101524. * Gets the list of created scenes
  101525. */
  101526. scenes: Scene[];
  101527. /**
  101528. * Event raised when a new scene is created
  101529. */
  101530. onNewSceneAddedObservable: Observable<Scene>;
  101531. /**
  101532. * Gets the list of created postprocesses
  101533. */
  101534. postProcesses: PostProcess[];
  101535. /**
  101536. * Gets a boolean indicating if the pointer is currently locked
  101537. */
  101538. isPointerLock: boolean;
  101539. /**
  101540. * Observable event triggered each time the rendering canvas is resized
  101541. */
  101542. onResizeObservable: Observable<Engine>;
  101543. /**
  101544. * Observable event triggered each time the canvas loses focus
  101545. */
  101546. onCanvasBlurObservable: Observable<Engine>;
  101547. /**
  101548. * Observable event triggered each time the canvas gains focus
  101549. */
  101550. onCanvasFocusObservable: Observable<Engine>;
  101551. /**
  101552. * Observable event triggered each time the canvas receives pointerout event
  101553. */
  101554. onCanvasPointerOutObservable: Observable<PointerEvent>;
  101555. /**
  101556. * Observable raised when the engine begins a new frame
  101557. */
  101558. onBeginFrameObservable: Observable<Engine>;
  101559. /**
  101560. * If set, will be used to request the next animation frame for the render loop
  101561. */
  101562. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  101563. /**
  101564. * Observable raised when the engine ends the current frame
  101565. */
  101566. onEndFrameObservable: Observable<Engine>;
  101567. /**
  101568. * Observable raised when the engine is about to compile a shader
  101569. */
  101570. onBeforeShaderCompilationObservable: Observable<Engine>;
  101571. /**
  101572. * Observable raised when the engine has jsut compiled a shader
  101573. */
  101574. onAfterShaderCompilationObservable: Observable<Engine>;
  101575. /**
  101576. * Gets the audio engine
  101577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101578. * @ignorenaming
  101579. */
  101580. static audioEngine: IAudioEngine;
  101581. /**
  101582. * Default AudioEngine factory responsible of creating the Audio Engine.
  101583. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  101584. */
  101585. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  101586. /**
  101587. * Default offline support factory responsible of creating a tool used to store data locally.
  101588. * By default, this will create a Database object if the workload has been embedded.
  101589. */
  101590. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  101591. private _loadingScreen;
  101592. private _pointerLockRequested;
  101593. private _dummyFramebuffer;
  101594. private _rescalePostProcess;
  101595. /** @hidden */
  101596. protected _alphaMode: number;
  101597. /** @hidden */
  101598. protected _alphaEquation: number;
  101599. private _deterministicLockstep;
  101600. private _lockstepMaxSteps;
  101601. private _timeStep;
  101602. protected readonly _supportsHardwareTextureRescaling: boolean;
  101603. private _fps;
  101604. private _deltaTime;
  101605. /** @hidden */
  101606. _drawCalls: PerfCounter;
  101607. /**
  101608. * Turn this value on if you want to pause FPS computation when in background
  101609. */
  101610. disablePerformanceMonitorInBackground: boolean;
  101611. private _performanceMonitor;
  101612. /**
  101613. * Gets the performance monitor attached to this engine
  101614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  101615. */
  101616. readonly performanceMonitor: PerformanceMonitor;
  101617. private _onFocus;
  101618. private _onBlur;
  101619. private _onCanvasPointerOut;
  101620. private _onCanvasBlur;
  101621. private _onCanvasFocus;
  101622. private _onFullscreenChange;
  101623. private _onPointerLockChange;
  101624. /**
  101625. * Gets the HTML element used to attach event listeners
  101626. * @returns a HTML element
  101627. */
  101628. getInputElement(): Nullable<HTMLElement>;
  101629. /**
  101630. * Creates a new engine
  101631. * @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
  101632. * @param antialias defines enable antialiasing (default: false)
  101633. * @param options defines further options to be sent to the getContext() function
  101634. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101635. */
  101636. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101637. /**
  101638. * Gets current aspect ratio
  101639. * @param viewportOwner defines the camera to use to get the aspect ratio
  101640. * @param useScreen defines if screen size must be used (or the current render target if any)
  101641. * @returns a number defining the aspect ratio
  101642. */
  101643. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  101644. /**
  101645. * Gets current screen aspect ratio
  101646. * @returns a number defining the aspect ratio
  101647. */
  101648. getScreenAspectRatio(): number;
  101649. /**
  101650. * Gets the client rect of the HTML canvas attached with the current webGL context
  101651. * @returns a client rectanglee
  101652. */
  101653. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  101654. /**
  101655. * Gets the client rect of the HTML element used for events
  101656. * @returns a client rectanglee
  101657. */
  101658. getInputElementClientRect(): Nullable<ClientRect>;
  101659. /**
  101660. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  101661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101662. * @returns true if engine is in deterministic lock step mode
  101663. */
  101664. isDeterministicLockStep(): boolean;
  101665. /**
  101666. * Gets the max steps when engine is running in deterministic lock step
  101667. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101668. * @returns the max steps
  101669. */
  101670. getLockstepMaxSteps(): number;
  101671. /**
  101672. * Returns the time in ms between steps when using deterministic lock step.
  101673. * @returns time step in (ms)
  101674. */
  101675. getTimeStep(): number;
  101676. /**
  101677. * Force the mipmap generation for the given render target texture
  101678. * @param texture defines the render target texture to use
  101679. */
  101680. generateMipMapsForCubemap(texture: InternalTexture): void;
  101681. /** States */
  101682. /**
  101683. * Set various states to the webGL context
  101684. * @param culling defines backface culling state
  101685. * @param zOffset defines the value to apply to zOffset (0 by default)
  101686. * @param force defines if states must be applied even if cache is up to date
  101687. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  101688. */
  101689. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  101690. /**
  101691. * Set the z offset to apply to current rendering
  101692. * @param value defines the offset to apply
  101693. */
  101694. setZOffset(value: number): void;
  101695. /**
  101696. * Gets the current value of the zOffset
  101697. * @returns the current zOffset state
  101698. */
  101699. getZOffset(): number;
  101700. /**
  101701. * Enable or disable depth buffering
  101702. * @param enable defines the state to set
  101703. */
  101704. setDepthBuffer(enable: boolean): void;
  101705. /**
  101706. * Gets a boolean indicating if depth writing is enabled
  101707. * @returns the current depth writing state
  101708. */
  101709. getDepthWrite(): boolean;
  101710. /**
  101711. * Enable or disable depth writing
  101712. * @param enable defines the state to set
  101713. */
  101714. setDepthWrite(enable: boolean): void;
  101715. /**
  101716. * Enable or disable color writing
  101717. * @param enable defines the state to set
  101718. */
  101719. setColorWrite(enable: boolean): void;
  101720. /**
  101721. * Gets a boolean indicating if color writing is enabled
  101722. * @returns the current color writing state
  101723. */
  101724. getColorWrite(): boolean;
  101725. /**
  101726. * Sets alpha constants used by some alpha blending modes
  101727. * @param r defines the red component
  101728. * @param g defines the green component
  101729. * @param b defines the blue component
  101730. * @param a defines the alpha component
  101731. */
  101732. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101733. /**
  101734. * Sets the current alpha mode
  101735. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101736. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101737. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101738. */
  101739. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101740. /**
  101741. * Gets the current alpha mode
  101742. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101743. * @returns the current alpha mode
  101744. */
  101745. getAlphaMode(): number;
  101746. /**
  101747. * Sets the current alpha equation
  101748. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101749. */
  101750. setAlphaEquation(equation: number): void;
  101751. /**
  101752. * Gets the current alpha equation.
  101753. * @returns the current alpha equation
  101754. */
  101755. getAlphaEquation(): number;
  101756. /**
  101757. * Gets a boolean indicating if stencil buffer is enabled
  101758. * @returns the current stencil buffer state
  101759. */
  101760. getStencilBuffer(): boolean;
  101761. /**
  101762. * Enable or disable the stencil buffer
  101763. * @param enable defines if the stencil buffer must be enabled or disabled
  101764. */
  101765. setStencilBuffer(enable: boolean): void;
  101766. /**
  101767. * Gets the current stencil mask
  101768. * @returns a number defining the new stencil mask to use
  101769. */
  101770. getStencilMask(): number;
  101771. /**
  101772. * Sets the current stencil mask
  101773. * @param mask defines the new stencil mask to use
  101774. */
  101775. setStencilMask(mask: number): void;
  101776. /**
  101777. * Gets the current stencil function
  101778. * @returns a number defining the stencil function to use
  101779. */
  101780. getStencilFunction(): number;
  101781. /**
  101782. * Gets the current stencil reference value
  101783. * @returns a number defining the stencil reference value to use
  101784. */
  101785. getStencilFunctionReference(): number;
  101786. /**
  101787. * Gets the current stencil mask
  101788. * @returns a number defining the stencil mask to use
  101789. */
  101790. getStencilFunctionMask(): number;
  101791. /**
  101792. * Sets the current stencil function
  101793. * @param stencilFunc defines the new stencil function to use
  101794. */
  101795. setStencilFunction(stencilFunc: number): void;
  101796. /**
  101797. * Sets the current stencil reference
  101798. * @param reference defines the new stencil reference to use
  101799. */
  101800. setStencilFunctionReference(reference: number): void;
  101801. /**
  101802. * Sets the current stencil mask
  101803. * @param mask defines the new stencil mask to use
  101804. */
  101805. setStencilFunctionMask(mask: number): void;
  101806. /**
  101807. * Gets the current stencil operation when stencil fails
  101808. * @returns a number defining stencil operation to use when stencil fails
  101809. */
  101810. getStencilOperationFail(): number;
  101811. /**
  101812. * Gets the current stencil operation when depth fails
  101813. * @returns a number defining stencil operation to use when depth fails
  101814. */
  101815. getStencilOperationDepthFail(): number;
  101816. /**
  101817. * Gets the current stencil operation when stencil passes
  101818. * @returns a number defining stencil operation to use when stencil passes
  101819. */
  101820. getStencilOperationPass(): number;
  101821. /**
  101822. * Sets the stencil operation to use when stencil fails
  101823. * @param operation defines the stencil operation to use when stencil fails
  101824. */
  101825. setStencilOperationFail(operation: number): void;
  101826. /**
  101827. * Sets the stencil operation to use when depth fails
  101828. * @param operation defines the stencil operation to use when depth fails
  101829. */
  101830. setStencilOperationDepthFail(operation: number): void;
  101831. /**
  101832. * Sets the stencil operation to use when stencil passes
  101833. * @param operation defines the stencil operation to use when stencil passes
  101834. */
  101835. setStencilOperationPass(operation: number): void;
  101836. /**
  101837. * Sets a boolean indicating if the dithering state is enabled or disabled
  101838. * @param value defines the dithering state
  101839. */
  101840. setDitheringState(value: boolean): void;
  101841. /**
  101842. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  101843. * @param value defines the rasterizer state
  101844. */
  101845. setRasterizerState(value: boolean): void;
  101846. /**
  101847. * Gets the current depth function
  101848. * @returns a number defining the depth function
  101849. */
  101850. getDepthFunction(): Nullable<number>;
  101851. /**
  101852. * Sets the current depth function
  101853. * @param depthFunc defines the function to use
  101854. */
  101855. setDepthFunction(depthFunc: number): void;
  101856. /**
  101857. * Sets the current depth function to GREATER
  101858. */
  101859. setDepthFunctionToGreater(): void;
  101860. /**
  101861. * Sets the current depth function to GEQUAL
  101862. */
  101863. setDepthFunctionToGreaterOrEqual(): void;
  101864. /**
  101865. * Sets the current depth function to LESS
  101866. */
  101867. setDepthFunctionToLess(): void;
  101868. /**
  101869. * Sets the current depth function to LEQUAL
  101870. */
  101871. setDepthFunctionToLessOrEqual(): void;
  101872. private _cachedStencilBuffer;
  101873. private _cachedStencilFunction;
  101874. private _cachedStencilMask;
  101875. private _cachedStencilOperationPass;
  101876. private _cachedStencilOperationFail;
  101877. private _cachedStencilOperationDepthFail;
  101878. private _cachedStencilReference;
  101879. /**
  101880. * Caches the the state of the stencil buffer
  101881. */
  101882. cacheStencilState(): void;
  101883. /**
  101884. * Restores the state of the stencil buffer
  101885. */
  101886. restoreStencilState(): void;
  101887. /**
  101888. * Directly set the WebGL Viewport
  101889. * @param x defines the x coordinate of the viewport (in screen space)
  101890. * @param y defines the y coordinate of the viewport (in screen space)
  101891. * @param width defines the width of the viewport (in screen space)
  101892. * @param height defines the height of the viewport (in screen space)
  101893. * @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
  101894. */
  101895. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  101896. /**
  101897. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  101898. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101899. * @param y defines the y-coordinate of the corner of the clear rectangle
  101900. * @param width defines the width of the clear rectangle
  101901. * @param height defines the height of the clear rectangle
  101902. * @param clearColor defines the clear color
  101903. */
  101904. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  101905. /**
  101906. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  101907. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  101908. * @param y defines the y-coordinate of the corner of the clear rectangle
  101909. * @param width defines the width of the clear rectangle
  101910. * @param height defines the height of the clear rectangle
  101911. */
  101912. enableScissor(x: number, y: number, width: number, height: number): void;
  101913. /**
  101914. * Disable previously set scissor test rectangle
  101915. */
  101916. disableScissor(): void;
  101917. protected _reportDrawCall(): void;
  101918. /**
  101919. * Initializes a webVR display and starts listening to display change events
  101920. * The onVRDisplayChangedObservable will be notified upon these changes
  101921. * @returns The onVRDisplayChangedObservable
  101922. */
  101923. initWebVR(): Observable<IDisplayChangedEventArgs>;
  101924. /** @hidden */
  101925. _prepareVRComponent(): void;
  101926. /** @hidden */
  101927. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  101928. /** @hidden */
  101929. _submitVRFrame(): void;
  101930. /**
  101931. * Call this function to leave webVR mode
  101932. * Will do nothing if webVR is not supported or if there is no webVR device
  101933. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101934. */
  101935. disableVR(): void;
  101936. /**
  101937. * Gets a boolean indicating that the system is in VR mode and is presenting
  101938. * @returns true if VR mode is engaged
  101939. */
  101940. isVRPresenting(): boolean;
  101941. /** @hidden */
  101942. _requestVRFrame(): void;
  101943. /** @hidden */
  101944. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101945. /**
  101946. * Gets the source code of the vertex shader associated with a specific webGL program
  101947. * @param program defines the program to use
  101948. * @returns a string containing the source code of the vertex shader associated with the program
  101949. */
  101950. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  101951. /**
  101952. * Gets the source code of the fragment shader associated with a specific webGL program
  101953. * @param program defines the program to use
  101954. * @returns a string containing the source code of the fragment shader associated with the program
  101955. */
  101956. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  101957. /**
  101958. * Reads pixels from the current frame buffer. Please note that this function can be slow
  101959. * @param x defines the x coordinate of the rectangle where pixels must be read
  101960. * @param y defines the y coordinate of the rectangle where pixels must be read
  101961. * @param width defines the width of the rectangle where pixels must be read
  101962. * @param height defines the height of the rectangle where pixels must be read
  101963. * @returns a Uint8Array containing RGBA colors
  101964. */
  101965. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  101966. /**
  101967. * Sets a depth stencil texture from a render target to the according uniform.
  101968. * @param channel The texture channel
  101969. * @param uniform The uniform to set
  101970. * @param texture The render target texture containing the depth stencil texture to apply
  101971. */
  101972. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  101973. /**
  101974. * Sets a texture to the webGL context from a postprocess
  101975. * @param channel defines the channel to use
  101976. * @param postProcess defines the source postprocess
  101977. */
  101978. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  101979. /**
  101980. * Binds the output of the passed in post process to the texture channel specified
  101981. * @param channel The channel the texture should be bound to
  101982. * @param postProcess The post process which's output should be bound
  101983. */
  101984. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  101985. /** @hidden */
  101986. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  101987. protected _rebuildBuffers(): void;
  101988. /** @hidden */
  101989. _renderFrame(): void;
  101990. _renderLoop(): void;
  101991. /** @hidden */
  101992. _renderViews(): boolean;
  101993. /**
  101994. * Toggle full screen mode
  101995. * @param requestPointerLock defines if a pointer lock should be requested from the user
  101996. */
  101997. switchFullscreen(requestPointerLock: boolean): void;
  101998. /**
  101999. * Enters full screen mode
  102000. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102001. */
  102002. enterFullscreen(requestPointerLock: boolean): void;
  102003. /**
  102004. * Exits full screen mode
  102005. */
  102006. exitFullscreen(): void;
  102007. /**
  102008. * Enters Pointerlock mode
  102009. */
  102010. enterPointerlock(): void;
  102011. /**
  102012. * Exits Pointerlock mode
  102013. */
  102014. exitPointerlock(): void;
  102015. /**
  102016. * Begin a new frame
  102017. */
  102018. beginFrame(): void;
  102019. /**
  102020. * Enf the current frame
  102021. */
  102022. endFrame(): void;
  102023. resize(): void;
  102024. /**
  102025. * Set the compressed texture format to use, based on the formats you have, and the formats
  102026. * supported by the hardware / browser.
  102027. *
  102028. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102029. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102030. * to API arguments needed to compressed textures. This puts the burden on the container
  102031. * generator to house the arcane code for determining these for current & future formats.
  102032. *
  102033. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102034. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102035. *
  102036. * Note: The result of this call is not taken into account when a texture is base64.
  102037. *
  102038. * @param formatsAvailable defines the list of those format families you have created
  102039. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102040. *
  102041. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102042. * @returns The extension selected.
  102043. */
  102044. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102045. /**
  102046. * Force a specific size of the canvas
  102047. * @param width defines the new canvas' width
  102048. * @param height defines the new canvas' height
  102049. */
  102050. setSize(width: number, height: number): void;
  102051. /**
  102052. * Updates a dynamic vertex buffer.
  102053. * @param vertexBuffer the vertex buffer to update
  102054. * @param data the data used to update the vertex buffer
  102055. * @param byteOffset the byte offset of the data
  102056. * @param byteLength the byte length of the data
  102057. */
  102058. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102060. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102061. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102062. _releaseTexture(texture: InternalTexture): void;
  102063. /**
  102064. * @hidden
  102065. * Rescales a texture
  102066. * @param source input texutre
  102067. * @param destination destination texture
  102068. * @param scene scene to use to render the resize
  102069. * @param internalFormat format to use when resizing
  102070. * @param onComplete callback to be called when resize has completed
  102071. */
  102072. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102073. /**
  102074. * Gets the current framerate
  102075. * @returns a number representing the framerate
  102076. */
  102077. getFps(): number;
  102078. /**
  102079. * Gets the time spent between current and previous frame
  102080. * @returns a number representing the delta time in ms
  102081. */
  102082. getDeltaTime(): number;
  102083. private _measureFps;
  102084. /** @hidden */
  102085. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102086. /**
  102087. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102088. * @param renderTarget The render target to set the frame buffer for
  102089. */
  102090. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102091. /**
  102092. * Update a dynamic index buffer
  102093. * @param indexBuffer defines the target index buffer
  102094. * @param indices defines the data to update
  102095. * @param offset defines the offset in the target index buffer where update should start
  102096. */
  102097. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102098. /**
  102099. * Updates the sample count of a render target texture
  102100. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102101. * @param texture defines the texture to update
  102102. * @param samples defines the sample count to set
  102103. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102104. */
  102105. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102106. /**
  102107. * Updates a depth texture Comparison Mode and Function.
  102108. * If the comparison Function is equal to 0, the mode will be set to none.
  102109. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102110. * @param texture The texture to set the comparison function for
  102111. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102112. */
  102113. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102114. /**
  102115. * Creates a webGL buffer to use with instanciation
  102116. * @param capacity defines the size of the buffer
  102117. * @returns the webGL buffer
  102118. */
  102119. createInstancesBuffer(capacity: number): DataBuffer;
  102120. /**
  102121. * Delete a webGL buffer used with instanciation
  102122. * @param buffer defines the webGL buffer to delete
  102123. */
  102124. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102125. /** @hidden */
  102126. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102127. dispose(): void;
  102128. private _disableTouchAction;
  102129. /**
  102130. * Display the loading screen
  102131. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102132. */
  102133. displayLoadingUI(): void;
  102134. /**
  102135. * Hide the loading screen
  102136. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102137. */
  102138. hideLoadingUI(): void;
  102139. /**
  102140. * Gets the current loading screen object
  102141. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102142. */
  102143. /**
  102144. * Sets the current loading screen object
  102145. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102146. */
  102147. loadingScreen: ILoadingScreen;
  102148. /**
  102149. * Sets the current loading screen text
  102150. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102151. */
  102152. loadingUIText: string;
  102153. /**
  102154. * Sets the current loading screen background color
  102155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102156. */
  102157. loadingUIBackgroundColor: string;
  102158. /** Pointerlock and fullscreen */
  102159. /**
  102160. * Ask the browser to promote the current element to pointerlock mode
  102161. * @param element defines the DOM element to promote
  102162. */
  102163. static _RequestPointerlock(element: HTMLElement): void;
  102164. /**
  102165. * Asks the browser to exit pointerlock mode
  102166. */
  102167. static _ExitPointerlock(): void;
  102168. /**
  102169. * Ask the browser to promote the current element to fullscreen rendering mode
  102170. * @param element defines the DOM element to promote
  102171. */
  102172. static _RequestFullscreen(element: HTMLElement): void;
  102173. /**
  102174. * Asks the browser to exit fullscreen mode
  102175. */
  102176. static _ExitFullscreen(): void;
  102177. }
  102178. }
  102179. declare module BABYLON {
  102180. /**
  102181. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102182. * during the life time of the application.
  102183. */
  102184. export class EngineStore {
  102185. /** Gets the list of created engines */
  102186. static Instances: Engine[];
  102187. /** @hidden */
  102188. static _LastCreatedScene: Nullable<Scene>;
  102189. /**
  102190. * Gets the latest created engine
  102191. */
  102192. static readonly LastCreatedEngine: Nullable<Engine>;
  102193. /**
  102194. * Gets the latest created scene
  102195. */
  102196. static readonly LastCreatedScene: Nullable<Scene>;
  102197. /**
  102198. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102199. * @ignorenaming
  102200. */
  102201. static UseFallbackTexture: boolean;
  102202. /**
  102203. * Texture content used if a texture cannot loaded
  102204. * @ignorenaming
  102205. */
  102206. static FallbackTexture: string;
  102207. }
  102208. }
  102209. declare module BABYLON {
  102210. /**
  102211. * Helper class that provides a small promise polyfill
  102212. */
  102213. export class PromisePolyfill {
  102214. /**
  102215. * Static function used to check if the polyfill is required
  102216. * If this is the case then the function will inject the polyfill to window.Promise
  102217. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102218. */
  102219. static Apply(force?: boolean): void;
  102220. }
  102221. }
  102222. declare module BABYLON {
  102223. /**
  102224. * Interface for screenshot methods with describe argument called `size` as object with options
  102225. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102226. */
  102227. export interface IScreenshotSize {
  102228. /**
  102229. * number in pixels for canvas height
  102230. */
  102231. height?: number;
  102232. /**
  102233. * multiplier allowing render at a higher or lower resolution
  102234. * If value is defined then height and width will be ignored and taken from camera
  102235. */
  102236. precision?: number;
  102237. /**
  102238. * number in pixels for canvas width
  102239. */
  102240. width?: number;
  102241. }
  102242. }
  102243. declare module BABYLON {
  102244. interface IColor4Like {
  102245. r: float;
  102246. g: float;
  102247. b: float;
  102248. a: float;
  102249. }
  102250. /**
  102251. * Class containing a set of static utilities functions
  102252. */
  102253. export class Tools {
  102254. /**
  102255. * Gets or sets the base URL to use to load assets
  102256. */
  102257. static BaseUrl: string;
  102258. /**
  102259. * Enable/Disable Custom HTTP Request Headers globally.
  102260. * default = false
  102261. * @see CustomRequestHeaders
  102262. */
  102263. static UseCustomRequestHeaders: boolean;
  102264. /**
  102265. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102266. * i.e. when loading files, where the server/service expects an Authorization header
  102267. */
  102268. static CustomRequestHeaders: {
  102269. [key: string]: string;
  102270. };
  102271. /**
  102272. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102273. */
  102274. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102275. /**
  102276. * Default behaviour for cors in the application.
  102277. * It can be a string if the expected behavior is identical in the entire app.
  102278. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102279. */
  102280. static CorsBehavior: string | ((url: string | string[]) => string);
  102281. /**
  102282. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102283. * @ignorenaming
  102284. */
  102285. static UseFallbackTexture: boolean;
  102286. /**
  102287. * Use this object to register external classes like custom textures or material
  102288. * to allow the laoders to instantiate them
  102289. */
  102290. static RegisteredExternalClasses: {
  102291. [key: string]: Object;
  102292. };
  102293. /**
  102294. * Texture content used if a texture cannot loaded
  102295. * @ignorenaming
  102296. */
  102297. static fallbackTexture: string;
  102298. /**
  102299. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102300. * @param u defines the coordinate on X axis
  102301. * @param v defines the coordinate on Y axis
  102302. * @param width defines the width of the source data
  102303. * @param height defines the height of the source data
  102304. * @param pixels defines the source byte array
  102305. * @param color defines the output color
  102306. */
  102307. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102308. /**
  102309. * Interpolates between a and b via alpha
  102310. * @param a The lower value (returned when alpha = 0)
  102311. * @param b The upper value (returned when alpha = 1)
  102312. * @param alpha The interpolation-factor
  102313. * @return The mixed value
  102314. */
  102315. static Mix(a: number, b: number, alpha: number): number;
  102316. /**
  102317. * Tries to instantiate a new object from a given class name
  102318. * @param className defines the class name to instantiate
  102319. * @returns the new object or null if the system was not able to do the instantiation
  102320. */
  102321. static Instantiate(className: string): any;
  102322. /**
  102323. * Provides a slice function that will work even on IE
  102324. * @param data defines the array to slice
  102325. * @param start defines the start of the data (optional)
  102326. * @param end defines the end of the data (optional)
  102327. * @returns the new sliced array
  102328. */
  102329. static Slice<T>(data: T, start?: number, end?: number): T;
  102330. /**
  102331. * Polyfill for setImmediate
  102332. * @param action defines the action to execute after the current execution block
  102333. */
  102334. static SetImmediate(action: () => void): void;
  102335. /**
  102336. * Function indicating if a number is an exponent of 2
  102337. * @param value defines the value to test
  102338. * @returns true if the value is an exponent of 2
  102339. */
  102340. static IsExponentOfTwo(value: number): boolean;
  102341. private static _tmpFloatArray;
  102342. /**
  102343. * Returns the nearest 32-bit single precision float representation of a Number
  102344. * @param value A Number. If the parameter is of a different type, it will get converted
  102345. * to a number or to NaN if it cannot be converted
  102346. * @returns number
  102347. */
  102348. static FloatRound(value: number): number;
  102349. /**
  102350. * Extracts the filename from a path
  102351. * @param path defines the path to use
  102352. * @returns the filename
  102353. */
  102354. static GetFilename(path: string): string;
  102355. /**
  102356. * Extracts the "folder" part of a path (everything before the filename).
  102357. * @param uri The URI to extract the info from
  102358. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102359. * @returns The "folder" part of the path
  102360. */
  102361. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102362. /**
  102363. * Extracts text content from a DOM element hierarchy
  102364. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102365. */
  102366. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102367. /**
  102368. * Convert an angle in radians to degrees
  102369. * @param angle defines the angle to convert
  102370. * @returns the angle in degrees
  102371. */
  102372. static ToDegrees(angle: number): number;
  102373. /**
  102374. * Convert an angle in degrees to radians
  102375. * @param angle defines the angle to convert
  102376. * @returns the angle in radians
  102377. */
  102378. static ToRadians(angle: number): number;
  102379. /**
  102380. * Returns an array if obj is not an array
  102381. * @param obj defines the object to evaluate as an array
  102382. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102383. * @returns either obj directly if obj is an array or a new array containing obj
  102384. */
  102385. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102386. /**
  102387. * Gets the pointer prefix to use
  102388. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102389. */
  102390. static GetPointerPrefix(): string;
  102391. /**
  102392. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102393. * @param url define the url we are trying
  102394. * @param element define the dom element where to configure the cors policy
  102395. */
  102396. static SetCorsBehavior(url: string | string[], element: {
  102397. crossOrigin: string | null;
  102398. }): void;
  102399. /**
  102400. * Removes unwanted characters from an url
  102401. * @param url defines the url to clean
  102402. * @returns the cleaned url
  102403. */
  102404. static CleanUrl(url: string): string;
  102405. /**
  102406. * Gets or sets a function used to pre-process url before using them to load assets
  102407. */
  102408. static PreprocessUrl: (url: string) => string;
  102409. /**
  102410. * Loads an image as an HTMLImageElement.
  102411. * @param input url string, ArrayBuffer, or Blob to load
  102412. * @param onLoad callback called when the image successfully loads
  102413. * @param onError callback called when the image fails to load
  102414. * @param offlineProvider offline provider for caching
  102415. * @param mimeType optional mime type
  102416. * @returns the HTMLImageElement of the loaded image
  102417. */
  102418. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102419. /**
  102420. * Loads a file from a url
  102421. * @param url url string, ArrayBuffer, or Blob to load
  102422. * @param onSuccess callback called when the file successfully loads
  102423. * @param onProgress callback called while file is loading (if the server supports this mode)
  102424. * @param offlineProvider defines the offline provider for caching
  102425. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102426. * @param onError callback called when the file fails to load
  102427. * @returns a file request object
  102428. */
  102429. 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;
  102430. /**
  102431. * Loads a file from a url
  102432. * @param url the file url to load
  102433. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102434. */
  102435. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102436. /**
  102437. * Load a script (identified by an url). When the url returns, the
  102438. * content of this file is added into a new script element, attached to the DOM (body element)
  102439. * @param scriptUrl defines the url of the script to laod
  102440. * @param onSuccess defines the callback called when the script is loaded
  102441. * @param onError defines the callback to call if an error occurs
  102442. * @param scriptId defines the id of the script element
  102443. */
  102444. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102445. /**
  102446. * Load an asynchronous script (identified by an url). When the url returns, the
  102447. * content of this file is added into a new script element, attached to the DOM (body element)
  102448. * @param scriptUrl defines the url of the script to laod
  102449. * @param scriptId defines the id of the script element
  102450. * @returns a promise request object
  102451. */
  102452. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102453. /**
  102454. * Loads a file from a blob
  102455. * @param fileToLoad defines the blob to use
  102456. * @param callback defines the callback to call when data is loaded
  102457. * @param progressCallback defines the callback to call during loading process
  102458. * @returns a file request object
  102459. */
  102460. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102461. /**
  102462. * Reads a file from a File object
  102463. * @param file defines the file to load
  102464. * @param onSuccess defines the callback to call when data is loaded
  102465. * @param onProgress defines the callback to call during loading process
  102466. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  102467. * @param onError defines the callback to call when an error occurs
  102468. * @returns a file request object
  102469. */
  102470. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  102471. /**
  102472. * Creates a data url from a given string content
  102473. * @param content defines the content to convert
  102474. * @returns the new data url link
  102475. */
  102476. static FileAsURL(content: string): string;
  102477. /**
  102478. * Format the given number to a specific decimal format
  102479. * @param value defines the number to format
  102480. * @param decimals defines the number of decimals to use
  102481. * @returns the formatted string
  102482. */
  102483. static Format(value: number, decimals?: number): string;
  102484. /**
  102485. * Tries to copy an object by duplicating every property
  102486. * @param source defines the source object
  102487. * @param destination defines the target object
  102488. * @param doNotCopyList defines a list of properties to avoid
  102489. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  102490. */
  102491. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  102492. /**
  102493. * Gets a boolean indicating if the given object has no own property
  102494. * @param obj defines the object to test
  102495. * @returns true if object has no own property
  102496. */
  102497. static IsEmpty(obj: any): boolean;
  102498. /**
  102499. * Function used to register events at window level
  102500. * @param windowElement defines the Window object to use
  102501. * @param events defines the events to register
  102502. */
  102503. static RegisterTopRootEvents(windowElement: Window, events: {
  102504. name: string;
  102505. handler: Nullable<(e: FocusEvent) => any>;
  102506. }[]): void;
  102507. /**
  102508. * Function used to unregister events from window level
  102509. * @param windowElement defines the Window object to use
  102510. * @param events defines the events to unregister
  102511. */
  102512. static UnregisterTopRootEvents(windowElement: Window, events: {
  102513. name: string;
  102514. handler: Nullable<(e: FocusEvent) => any>;
  102515. }[]): void;
  102516. /**
  102517. * @ignore
  102518. */
  102519. static _ScreenshotCanvas: HTMLCanvasElement;
  102520. /**
  102521. * Dumps the current bound framebuffer
  102522. * @param width defines the rendering width
  102523. * @param height defines the rendering height
  102524. * @param engine defines the hosting engine
  102525. * @param successCallback defines the callback triggered once the data are available
  102526. * @param mimeType defines the mime type of the result
  102527. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  102528. */
  102529. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102530. /**
  102531. * Converts the canvas data to blob.
  102532. * This acts as a polyfill for browsers not supporting the to blob function.
  102533. * @param canvas Defines the canvas to extract the data from
  102534. * @param successCallback Defines the callback triggered once the data are available
  102535. * @param mimeType Defines the mime type of the result
  102536. */
  102537. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  102538. /**
  102539. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  102540. * @param successCallback defines the callback triggered once the data are available
  102541. * @param mimeType defines the mime type of the result
  102542. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  102543. */
  102544. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  102545. /**
  102546. * Downloads a blob in the browser
  102547. * @param blob defines the blob to download
  102548. * @param fileName defines the name of the downloaded file
  102549. */
  102550. static Download(blob: Blob, fileName: string): void;
  102551. /**
  102552. * Captures a screenshot of the current rendering
  102553. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102554. * @param engine defines the rendering engine
  102555. * @param camera defines the source camera
  102556. * @param size This parameter can be set to a single number or to an object with the
  102557. * following (optional) properties: precision, width, height. If a single number is passed,
  102558. * it will be used for both width and height. If an object is passed, the screenshot size
  102559. * will be derived from the parameters. The precision property is a multiplier allowing
  102560. * rendering at a higher or lower resolution
  102561. * @param successCallback defines the callback receives a single parameter which contains the
  102562. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102563. * src parameter of an <img> to display it
  102564. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102565. * Check your browser for supported MIME types
  102566. */
  102567. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  102568. /**
  102569. * Captures a screenshot of the current rendering
  102570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102571. * @param engine defines the rendering engine
  102572. * @param camera defines the source camera
  102573. * @param size This parameter can be set to a single number or to an object with the
  102574. * following (optional) properties: precision, width, height. If a single number is passed,
  102575. * it will be used for both width and height. If an object is passed, the screenshot size
  102576. * will be derived from the parameters. The precision property is a multiplier allowing
  102577. * rendering at a higher or lower resolution
  102578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102579. * Check your browser for supported MIME types
  102580. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102581. * to the src parameter of an <img> to display it
  102582. */
  102583. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  102584. /**
  102585. * Generates an image screenshot from the specified camera.
  102586. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102587. * @param engine The engine to use for rendering
  102588. * @param camera The camera to use for rendering
  102589. * @param size This parameter can be set to a single number or to an object with the
  102590. * following (optional) properties: precision, width, height. If a single number is passed,
  102591. * it will be used for both width and height. If an object is passed, the screenshot size
  102592. * will be derived from the parameters. The precision property is a multiplier allowing
  102593. * rendering at a higher or lower resolution
  102594. * @param successCallback The callback receives a single parameter which contains the
  102595. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102596. * src parameter of an <img> to display it
  102597. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102598. * Check your browser for supported MIME types
  102599. * @param samples Texture samples (default: 1)
  102600. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102601. * @param fileName A name for for the downloaded file.
  102602. */
  102603. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  102604. /**
  102605. * Generates an image screenshot from the specified camera.
  102606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102607. * @param engine The engine to use for rendering
  102608. * @param camera The camera to use for rendering
  102609. * @param size This parameter can be set to a single number or to an object with the
  102610. * following (optional) properties: precision, width, height. If a single number is passed,
  102611. * it will be used for both width and height. If an object is passed, the screenshot size
  102612. * will be derived from the parameters. The precision property is a multiplier allowing
  102613. * rendering at a higher or lower resolution
  102614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102615. * Check your browser for supported MIME types
  102616. * @param samples Texture samples (default: 1)
  102617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102618. * @param fileName A name for for the downloaded file.
  102619. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  102620. * to the src parameter of an <img> to display it
  102621. */
  102622. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  102623. /**
  102624. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102625. * Be aware Math.random() could cause collisions, but:
  102626. * "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"
  102627. * @returns a pseudo random id
  102628. */
  102629. static RandomId(): string;
  102630. /**
  102631. * Test if the given uri is a base64 string
  102632. * @param uri The uri to test
  102633. * @return True if the uri is a base64 string or false otherwise
  102634. */
  102635. static IsBase64(uri: string): boolean;
  102636. /**
  102637. * Decode the given base64 uri.
  102638. * @param uri The uri to decode
  102639. * @return The decoded base64 data.
  102640. */
  102641. static DecodeBase64(uri: string): ArrayBuffer;
  102642. /**
  102643. * Gets the absolute url.
  102644. * @param url the input url
  102645. * @return the absolute url
  102646. */
  102647. static GetAbsoluteUrl(url: string): string;
  102648. /**
  102649. * No log
  102650. */
  102651. static readonly NoneLogLevel: number;
  102652. /**
  102653. * Only message logs
  102654. */
  102655. static readonly MessageLogLevel: number;
  102656. /**
  102657. * Only warning logs
  102658. */
  102659. static readonly WarningLogLevel: number;
  102660. /**
  102661. * Only error logs
  102662. */
  102663. static readonly ErrorLogLevel: number;
  102664. /**
  102665. * All logs
  102666. */
  102667. static readonly AllLogLevel: number;
  102668. /**
  102669. * Gets a value indicating the number of loading errors
  102670. * @ignorenaming
  102671. */
  102672. static readonly errorsCount: number;
  102673. /**
  102674. * Callback called when a new log is added
  102675. */
  102676. static OnNewCacheEntry: (entry: string) => void;
  102677. /**
  102678. * Log a message to the console
  102679. * @param message defines the message to log
  102680. */
  102681. static Log(message: string): void;
  102682. /**
  102683. * Write a warning message to the console
  102684. * @param message defines the message to log
  102685. */
  102686. static Warn(message: string): void;
  102687. /**
  102688. * Write an error message to the console
  102689. * @param message defines the message to log
  102690. */
  102691. static Error(message: string): void;
  102692. /**
  102693. * Gets current log cache (list of logs)
  102694. */
  102695. static readonly LogCache: string;
  102696. /**
  102697. * Clears the log cache
  102698. */
  102699. static ClearLogCache(): void;
  102700. /**
  102701. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  102702. */
  102703. static LogLevels: number;
  102704. /**
  102705. * Checks if the window object exists
  102706. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  102707. */
  102708. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  102709. /**
  102710. * No performance log
  102711. */
  102712. static readonly PerformanceNoneLogLevel: number;
  102713. /**
  102714. * Use user marks to log performance
  102715. */
  102716. static readonly PerformanceUserMarkLogLevel: number;
  102717. /**
  102718. * Log performance to the console
  102719. */
  102720. static readonly PerformanceConsoleLogLevel: number;
  102721. private static _performance;
  102722. /**
  102723. * Sets the current performance log level
  102724. */
  102725. static PerformanceLogLevel: number;
  102726. private static _StartPerformanceCounterDisabled;
  102727. private static _EndPerformanceCounterDisabled;
  102728. private static _StartUserMark;
  102729. private static _EndUserMark;
  102730. private static _StartPerformanceConsole;
  102731. private static _EndPerformanceConsole;
  102732. /**
  102733. * Starts a performance counter
  102734. */
  102735. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102736. /**
  102737. * Ends a specific performance coutner
  102738. */
  102739. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  102740. /**
  102741. * Gets either window.performance.now() if supported or Date.now() else
  102742. */
  102743. static readonly Now: number;
  102744. /**
  102745. * This method will return the name of the class used to create the instance of the given object.
  102746. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  102747. * @param object the object to get the class name from
  102748. * @param isType defines if the object is actually a type
  102749. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  102750. */
  102751. static GetClassName(object: any, isType?: boolean): string;
  102752. /**
  102753. * Gets the first element of an array satisfying a given predicate
  102754. * @param array defines the array to browse
  102755. * @param predicate defines the predicate to use
  102756. * @returns null if not found or the element
  102757. */
  102758. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  102759. /**
  102760. * This method will return the name of the full name of the class, including its owning module (if any).
  102761. * 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).
  102762. * @param object the object to get the class name from
  102763. * @param isType defines if the object is actually a type
  102764. * @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.
  102765. * @ignorenaming
  102766. */
  102767. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  102768. /**
  102769. * Returns a promise that resolves after the given amount of time.
  102770. * @param delay Number of milliseconds to delay
  102771. * @returns Promise that resolves after the given amount of time
  102772. */
  102773. static DelayAsync(delay: number): Promise<void>;
  102774. }
  102775. /**
  102776. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  102777. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  102778. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  102779. * @param name The name of the class, case should be preserved
  102780. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  102781. */
  102782. export function className(name: string, module?: string): (target: Object) => void;
  102783. /**
  102784. * An implementation of a loop for asynchronous functions.
  102785. */
  102786. export class AsyncLoop {
  102787. /**
  102788. * Defines the number of iterations for the loop
  102789. */
  102790. iterations: number;
  102791. /**
  102792. * Defines the current index of the loop.
  102793. */
  102794. index: number;
  102795. private _done;
  102796. private _fn;
  102797. private _successCallback;
  102798. /**
  102799. * Constructor.
  102800. * @param iterations the number of iterations.
  102801. * @param func the function to run each iteration
  102802. * @param successCallback the callback that will be called upon succesful execution
  102803. * @param offset starting offset.
  102804. */
  102805. constructor(
  102806. /**
  102807. * Defines the number of iterations for the loop
  102808. */
  102809. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  102810. /**
  102811. * Execute the next iteration. Must be called after the last iteration was finished.
  102812. */
  102813. executeNext(): void;
  102814. /**
  102815. * Break the loop and run the success callback.
  102816. */
  102817. breakLoop(): void;
  102818. /**
  102819. * Create and run an async loop.
  102820. * @param iterations the number of iterations.
  102821. * @param fn the function to run each iteration
  102822. * @param successCallback the callback that will be called upon succesful execution
  102823. * @param offset starting offset.
  102824. * @returns the created async loop object
  102825. */
  102826. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  102827. /**
  102828. * A for-loop that will run a given number of iterations synchronous and the rest async.
  102829. * @param iterations total number of iterations
  102830. * @param syncedIterations number of synchronous iterations in each async iteration.
  102831. * @param fn the function to call each iteration.
  102832. * @param callback a success call back that will be called when iterating stops.
  102833. * @param breakFunction a break condition (optional)
  102834. * @param timeout timeout settings for the setTimeout function. default - 0.
  102835. * @returns the created async loop object
  102836. */
  102837. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  102838. }
  102839. }
  102840. declare module BABYLON {
  102841. /**
  102842. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102843. * The underlying implementation relies on an associative array to ensure the best performances.
  102844. * The value can be anything including 'null' but except 'undefined'
  102845. */
  102846. export class StringDictionary<T> {
  102847. /**
  102848. * This will clear this dictionary and copy the content from the 'source' one.
  102849. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102850. * @param source the dictionary to take the content from and copy to this dictionary
  102851. */
  102852. copyFrom(source: StringDictionary<T>): void;
  102853. /**
  102854. * Get a value based from its key
  102855. * @param key the given key to get the matching value from
  102856. * @return the value if found, otherwise undefined is returned
  102857. */
  102858. get(key: string): T | undefined;
  102859. /**
  102860. * Get a value from its key or add it if it doesn't exist.
  102861. * This method will ensure you that a given key/data will be present in the dictionary.
  102862. * @param key the given key to get the matching value from
  102863. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102864. * The factory will only be invoked if there's no data for the given key.
  102865. * @return the value corresponding to the key.
  102866. */
  102867. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  102868. /**
  102869. * Get a value from its key if present in the dictionary otherwise add it
  102870. * @param key the key to get the value from
  102871. * @param val if there's no such key/value pair in the dictionary add it with this value
  102872. * @return the value corresponding to the key
  102873. */
  102874. getOrAdd(key: string, val: T): T;
  102875. /**
  102876. * Check if there's a given key in the dictionary
  102877. * @param key the key to check for
  102878. * @return true if the key is present, false otherwise
  102879. */
  102880. contains(key: string): boolean;
  102881. /**
  102882. * Add a new key and its corresponding value
  102883. * @param key the key to add
  102884. * @param value the value corresponding to the key
  102885. * @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
  102886. */
  102887. add(key: string, value: T): boolean;
  102888. /**
  102889. * Update a specific value associated to a key
  102890. * @param key defines the key to use
  102891. * @param value defines the value to store
  102892. * @returns true if the value was updated (or false if the key was not found)
  102893. */
  102894. set(key: string, value: T): boolean;
  102895. /**
  102896. * Get the element of the given key and remove it from the dictionary
  102897. * @param key defines the key to search
  102898. * @returns the value associated with the key or null if not found
  102899. */
  102900. getAndRemove(key: string): Nullable<T>;
  102901. /**
  102902. * Remove a key/value from the dictionary.
  102903. * @param key the key to remove
  102904. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102905. */
  102906. remove(key: string): boolean;
  102907. /**
  102908. * Clear the whole content of the dictionary
  102909. */
  102910. clear(): void;
  102911. /**
  102912. * Gets the current count
  102913. */
  102914. readonly count: number;
  102915. /**
  102916. * Execute a callback on each key/val of the dictionary.
  102917. * Note that you can remove any element in this dictionary in the callback implementation
  102918. * @param callback the callback to execute on a given key/value pair
  102919. */
  102920. forEach(callback: (key: string, val: T) => void): void;
  102921. /**
  102922. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102923. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102924. * Note that you can remove any element in this dictionary in the callback implementation
  102925. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102926. * @returns the first item
  102927. */
  102928. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  102929. private _count;
  102930. private _data;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /** @hidden */
  102935. export interface ICollisionCoordinator {
  102936. createCollider(): Collider;
  102937. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102938. init(scene: Scene): void;
  102939. }
  102940. /** @hidden */
  102941. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  102942. private _scene;
  102943. private _scaledPosition;
  102944. private _scaledVelocity;
  102945. private _finalPosition;
  102946. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  102947. createCollider(): Collider;
  102948. init(scene: Scene): void;
  102949. private _collideWithWorld;
  102950. }
  102951. }
  102952. declare module BABYLON {
  102953. /**
  102954. * Class used to manage all inputs for the scene.
  102955. */
  102956. export class InputManager {
  102957. /** The distance in pixel that you have to move to prevent some events */
  102958. static DragMovementThreshold: number;
  102959. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  102960. static LongPressDelay: number;
  102961. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  102962. static DoubleClickDelay: number;
  102963. /** If you need to check double click without raising a single click at first click, enable this flag */
  102964. static ExclusiveDoubleClickMode: boolean;
  102965. private _wheelEventName;
  102966. private _onPointerMove;
  102967. private _onPointerDown;
  102968. private _onPointerUp;
  102969. private _initClickEvent;
  102970. private _initActionManager;
  102971. private _delayedSimpleClick;
  102972. private _delayedSimpleClickTimeout;
  102973. private _previousDelayedSimpleClickTimeout;
  102974. private _meshPickProceed;
  102975. private _previousButtonPressed;
  102976. private _currentPickResult;
  102977. private _previousPickResult;
  102978. private _totalPointersPressed;
  102979. private _doubleClickOccured;
  102980. private _pointerOverMesh;
  102981. private _pickedDownMesh;
  102982. private _pickedUpMesh;
  102983. private _pointerX;
  102984. private _pointerY;
  102985. private _unTranslatedPointerX;
  102986. private _unTranslatedPointerY;
  102987. private _startingPointerPosition;
  102988. private _previousStartingPointerPosition;
  102989. private _startingPointerTime;
  102990. private _previousStartingPointerTime;
  102991. private _pointerCaptures;
  102992. private _onKeyDown;
  102993. private _onKeyUp;
  102994. private _onCanvasFocusObserver;
  102995. private _onCanvasBlurObserver;
  102996. private _scene;
  102997. /**
  102998. * Creates a new InputManager
  102999. * @param scene defines the hosting scene
  103000. */
  103001. constructor(scene: Scene);
  103002. /**
  103003. * Gets the mesh that is currently under the pointer
  103004. */
  103005. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103006. /**
  103007. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103008. */
  103009. readonly unTranslatedPointer: Vector2;
  103010. /**
  103011. * Gets or sets the current on-screen X position of the pointer
  103012. */
  103013. pointerX: number;
  103014. /**
  103015. * Gets or sets the current on-screen Y position of the pointer
  103016. */
  103017. pointerY: number;
  103018. private _updatePointerPosition;
  103019. private _processPointerMove;
  103020. private _setRayOnPointerInfo;
  103021. private _checkPrePointerObservable;
  103022. /**
  103023. * Use this method to simulate a pointer move on a mesh
  103024. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103025. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103026. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103027. */
  103028. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103029. /**
  103030. * Use this method to simulate a pointer down on a mesh
  103031. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103032. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103033. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103034. */
  103035. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103036. private _processPointerDown;
  103037. /** @hidden */
  103038. _isPointerSwiping(): boolean;
  103039. /**
  103040. * Use this method to simulate a pointer up on a mesh
  103041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103044. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103045. */
  103046. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103047. private _processPointerUp;
  103048. /**
  103049. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103050. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103051. * @returns true if the pointer was captured
  103052. */
  103053. isPointerCaptured(pointerId?: number): boolean;
  103054. /**
  103055. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103056. * @param attachUp defines if you want to attach events to pointerup
  103057. * @param attachDown defines if you want to attach events to pointerdown
  103058. * @param attachMove defines if you want to attach events to pointermove
  103059. */
  103060. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103061. /**
  103062. * Detaches all event handlers
  103063. */
  103064. detachControl(): void;
  103065. /**
  103066. * Force the value of meshUnderPointer
  103067. * @param mesh defines the mesh to use
  103068. */
  103069. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103070. /**
  103071. * Gets the mesh under the pointer
  103072. * @returns a Mesh or null if no mesh is under the pointer
  103073. */
  103074. getPointerOverMesh(): Nullable<AbstractMesh>;
  103075. }
  103076. }
  103077. declare module BABYLON {
  103078. /**
  103079. * Helper class used to generate session unique ID
  103080. */
  103081. export class UniqueIdGenerator {
  103082. private static _UniqueIdCounter;
  103083. /**
  103084. * Gets an unique (relatively to the current scene) Id
  103085. */
  103086. static readonly UniqueId: number;
  103087. }
  103088. }
  103089. declare module BABYLON {
  103090. /**
  103091. * This class defines the direct association between an animation and a target
  103092. */
  103093. export class TargetedAnimation {
  103094. /**
  103095. * Animation to perform
  103096. */
  103097. animation: Animation;
  103098. /**
  103099. * Target to animate
  103100. */
  103101. target: any;
  103102. /**
  103103. * Serialize the object
  103104. * @returns the JSON object representing the current entity
  103105. */
  103106. serialize(): any;
  103107. }
  103108. /**
  103109. * Use this class to create coordinated animations on multiple targets
  103110. */
  103111. export class AnimationGroup implements IDisposable {
  103112. /** The name of the animation group */
  103113. name: string;
  103114. private _scene;
  103115. private _targetedAnimations;
  103116. private _animatables;
  103117. private _from;
  103118. private _to;
  103119. private _isStarted;
  103120. private _isPaused;
  103121. private _speedRatio;
  103122. private _loopAnimation;
  103123. /**
  103124. * Gets or sets the unique id of the node
  103125. */
  103126. uniqueId: number;
  103127. /**
  103128. * This observable will notify when one animation have ended
  103129. */
  103130. onAnimationEndObservable: Observable<TargetedAnimation>;
  103131. /**
  103132. * Observer raised when one animation loops
  103133. */
  103134. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103135. /**
  103136. * Observer raised when all animations have looped
  103137. */
  103138. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103139. /**
  103140. * This observable will notify when all animations have ended.
  103141. */
  103142. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103143. /**
  103144. * This observable will notify when all animations have paused.
  103145. */
  103146. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103147. /**
  103148. * This observable will notify when all animations are playing.
  103149. */
  103150. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103151. /**
  103152. * Gets the first frame
  103153. */
  103154. readonly from: number;
  103155. /**
  103156. * Gets the last frame
  103157. */
  103158. readonly to: number;
  103159. /**
  103160. * Define if the animations are started
  103161. */
  103162. readonly isStarted: boolean;
  103163. /**
  103164. * Gets a value indicating that the current group is playing
  103165. */
  103166. readonly isPlaying: boolean;
  103167. /**
  103168. * Gets or sets the speed ratio to use for all animations
  103169. */
  103170. /**
  103171. * Gets or sets the speed ratio to use for all animations
  103172. */
  103173. speedRatio: number;
  103174. /**
  103175. * Gets or sets if all animations should loop or not
  103176. */
  103177. loopAnimation: boolean;
  103178. /**
  103179. * Gets the targeted animations for this animation group
  103180. */
  103181. readonly targetedAnimations: Array<TargetedAnimation>;
  103182. /**
  103183. * returning the list of animatables controlled by this animation group.
  103184. */
  103185. readonly animatables: Array<Animatable>;
  103186. /**
  103187. * Instantiates a new Animation Group.
  103188. * This helps managing several animations at once.
  103189. * @see http://doc.babylonjs.com/how_to/group
  103190. * @param name Defines the name of the group
  103191. * @param scene Defines the scene the group belongs to
  103192. */
  103193. constructor(
  103194. /** The name of the animation group */
  103195. name: string, scene?: Nullable<Scene>);
  103196. /**
  103197. * Add an animation (with its target) in the group
  103198. * @param animation defines the animation we want to add
  103199. * @param target defines the target of the animation
  103200. * @returns the TargetedAnimation object
  103201. */
  103202. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103203. /**
  103204. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103205. * It can add constant keys at begin or end
  103206. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103207. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103208. * @returns the animation group
  103209. */
  103210. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103211. private _animationLoopCount;
  103212. private _animationLoopFlags;
  103213. private _processLoop;
  103214. /**
  103215. * Start all animations on given targets
  103216. * @param loop defines if animations must loop
  103217. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103218. * @param from defines the from key (optional)
  103219. * @param to defines the to key (optional)
  103220. * @returns the current animation group
  103221. */
  103222. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103223. /**
  103224. * Pause all animations
  103225. * @returns the animation group
  103226. */
  103227. pause(): AnimationGroup;
  103228. /**
  103229. * Play all animations to initial state
  103230. * This function will start() the animations if they were not started or will restart() them if they were paused
  103231. * @param loop defines if animations must loop
  103232. * @returns the animation group
  103233. */
  103234. play(loop?: boolean): AnimationGroup;
  103235. /**
  103236. * Reset all animations to initial state
  103237. * @returns the animation group
  103238. */
  103239. reset(): AnimationGroup;
  103240. /**
  103241. * Restart animations from key 0
  103242. * @returns the animation group
  103243. */
  103244. restart(): AnimationGroup;
  103245. /**
  103246. * Stop all animations
  103247. * @returns the animation group
  103248. */
  103249. stop(): AnimationGroup;
  103250. /**
  103251. * Set animation weight for all animatables
  103252. * @param weight defines the weight to use
  103253. * @return the animationGroup
  103254. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103255. */
  103256. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103257. /**
  103258. * Synchronize and normalize all animatables with a source animatable
  103259. * @param root defines the root animatable to synchronize with
  103260. * @return the animationGroup
  103261. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103262. */
  103263. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103264. /**
  103265. * Goes to a specific frame in this animation group
  103266. * @param frame the frame number to go to
  103267. * @return the animationGroup
  103268. */
  103269. goToFrame(frame: number): AnimationGroup;
  103270. /**
  103271. * Dispose all associated resources
  103272. */
  103273. dispose(): void;
  103274. private _checkAnimationGroupEnded;
  103275. /**
  103276. * Clone the current animation group and returns a copy
  103277. * @param newName defines the name of the new group
  103278. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103279. * @returns the new aniamtion group
  103280. */
  103281. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103282. /**
  103283. * Serializes the animationGroup to an object
  103284. * @returns Serialized object
  103285. */
  103286. serialize(): any;
  103287. /**
  103288. * Returns a new AnimationGroup object parsed from the source provided.
  103289. * @param parsedAnimationGroup defines the source
  103290. * @param scene defines the scene that will receive the animationGroup
  103291. * @returns a new AnimationGroup
  103292. */
  103293. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103294. /**
  103295. * Returns the string "AnimationGroup"
  103296. * @returns "AnimationGroup"
  103297. */
  103298. getClassName(): string;
  103299. /**
  103300. * Creates a detailled string about the object
  103301. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103302. * @returns a string representing the object
  103303. */
  103304. toString(fullDetails?: boolean): string;
  103305. }
  103306. }
  103307. declare module BABYLON {
  103308. /**
  103309. * Define an interface for all classes that will hold resources
  103310. */
  103311. export interface IDisposable {
  103312. /**
  103313. * Releases all held resources
  103314. */
  103315. dispose(): void;
  103316. }
  103317. /** Interface defining initialization parameters for Scene class */
  103318. export interface SceneOptions {
  103319. /**
  103320. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103321. * It will improve performance when the number of geometries becomes important.
  103322. */
  103323. useGeometryUniqueIdsMap?: boolean;
  103324. /**
  103325. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103326. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103327. */
  103328. useMaterialMeshMap?: boolean;
  103329. /**
  103330. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103331. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103332. */
  103333. useClonedMeshhMap?: boolean;
  103334. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103335. virtual?: boolean;
  103336. }
  103337. /**
  103338. * Represents a scene to be rendered by the engine.
  103339. * @see http://doc.babylonjs.com/features/scene
  103340. */
  103341. export class Scene extends AbstractScene implements IAnimatable {
  103342. /** The fog is deactivated */
  103343. static readonly FOGMODE_NONE: number;
  103344. /** The fog density is following an exponential function */
  103345. static readonly FOGMODE_EXP: number;
  103346. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103347. static readonly FOGMODE_EXP2: number;
  103348. /** The fog density is following a linear function. */
  103349. static readonly FOGMODE_LINEAR: number;
  103350. /**
  103351. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103352. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103353. */
  103354. static MinDeltaTime: number;
  103355. /**
  103356. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103358. */
  103359. static MaxDeltaTime: number;
  103360. /**
  103361. * Factory used to create the default material.
  103362. * @param name The name of the material to create
  103363. * @param scene The scene to create the material for
  103364. * @returns The default material
  103365. */
  103366. static DefaultMaterialFactory(scene: Scene): Material;
  103367. /**
  103368. * Factory used to create the a collision coordinator.
  103369. * @returns The collision coordinator
  103370. */
  103371. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103372. /** @hidden */
  103373. _inputManager: InputManager;
  103374. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103375. cameraToUseForPointers: Nullable<Camera>;
  103376. /** @hidden */
  103377. readonly _isScene: boolean;
  103378. /**
  103379. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103380. */
  103381. autoClear: boolean;
  103382. /**
  103383. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103384. */
  103385. autoClearDepthAndStencil: boolean;
  103386. /**
  103387. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103388. */
  103389. clearColor: Color4;
  103390. /**
  103391. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103392. */
  103393. ambientColor: Color3;
  103394. /**
  103395. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103396. * It should only be one of the following (if not the default embedded one):
  103397. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103398. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103399. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103400. * The material properties need to be setup according to the type of texture in use.
  103401. */
  103402. environmentBRDFTexture: BaseTexture;
  103403. /** @hidden */
  103404. protected _environmentTexture: Nullable<BaseTexture>;
  103405. /**
  103406. * Texture used in all pbr material as the reflection texture.
  103407. * As in the majority of the scene they are the same (exception for multi room and so on),
  103408. * this is easier to reference from here than from all the materials.
  103409. */
  103410. /**
  103411. * Texture used in all pbr material as the reflection texture.
  103412. * As in the majority of the scene they are the same (exception for multi room and so on),
  103413. * this is easier to set here than in all the materials.
  103414. */
  103415. environmentTexture: Nullable<BaseTexture>;
  103416. /** @hidden */
  103417. protected _environmentIntensity: number;
  103418. /**
  103419. * Intensity of the environment in all pbr material.
  103420. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103421. * As in the majority of the scene they are the same (exception for multi room and so on),
  103422. * this is easier to reference from here than from all the materials.
  103423. */
  103424. /**
  103425. * Intensity of the environment in all pbr material.
  103426. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103427. * As in the majority of the scene they are the same (exception for multi room and so on),
  103428. * this is easier to set here than in all the materials.
  103429. */
  103430. environmentIntensity: number;
  103431. /** @hidden */
  103432. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103433. /**
  103434. * Default image processing configuration used either in the rendering
  103435. * Forward main pass or through the imageProcessingPostProcess if present.
  103436. * As in the majority of the scene they are the same (exception for multi camera),
  103437. * this is easier to reference from here than from all the materials and post process.
  103438. *
  103439. * No setter as we it is a shared configuration, you can set the values instead.
  103440. */
  103441. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103442. private _forceWireframe;
  103443. /**
  103444. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103445. */
  103446. forceWireframe: boolean;
  103447. private _forcePointsCloud;
  103448. /**
  103449. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103450. */
  103451. forcePointsCloud: boolean;
  103452. /**
  103453. * Gets or sets the active clipplane 1
  103454. */
  103455. clipPlane: Nullable<Plane>;
  103456. /**
  103457. * Gets or sets the active clipplane 2
  103458. */
  103459. clipPlane2: Nullable<Plane>;
  103460. /**
  103461. * Gets or sets the active clipplane 3
  103462. */
  103463. clipPlane3: Nullable<Plane>;
  103464. /**
  103465. * Gets or sets the active clipplane 4
  103466. */
  103467. clipPlane4: Nullable<Plane>;
  103468. /**
  103469. * Gets or sets a boolean indicating if animations are enabled
  103470. */
  103471. animationsEnabled: boolean;
  103472. private _animationPropertiesOverride;
  103473. /**
  103474. * Gets or sets the animation properties override
  103475. */
  103476. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  103477. /**
  103478. * Gets or sets a boolean indicating if a constant deltatime has to be used
  103479. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  103480. */
  103481. useConstantAnimationDeltaTime: boolean;
  103482. /**
  103483. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  103484. * Please note that it requires to run a ray cast through the scene on every frame
  103485. */
  103486. constantlyUpdateMeshUnderPointer: boolean;
  103487. /**
  103488. * Defines the HTML cursor to use when hovering over interactive elements
  103489. */
  103490. hoverCursor: string;
  103491. /**
  103492. * Defines the HTML default cursor to use (empty by default)
  103493. */
  103494. defaultCursor: string;
  103495. /**
  103496. * Defines wether cursors are handled by the scene.
  103497. */
  103498. doNotHandleCursors: boolean;
  103499. /**
  103500. * This is used to call preventDefault() on pointer down
  103501. * in order to block unwanted artifacts like system double clicks
  103502. */
  103503. preventDefaultOnPointerDown: boolean;
  103504. /**
  103505. * This is used to call preventDefault() on pointer up
  103506. * in order to block unwanted artifacts like system double clicks
  103507. */
  103508. preventDefaultOnPointerUp: boolean;
  103509. /**
  103510. * Gets or sets user defined metadata
  103511. */
  103512. metadata: any;
  103513. /**
  103514. * For internal use only. Please do not use.
  103515. */
  103516. reservedDataStore: any;
  103517. /**
  103518. * Gets the name of the plugin used to load this scene (null by default)
  103519. */
  103520. loadingPluginName: string;
  103521. /**
  103522. * Use this array to add regular expressions used to disable offline support for specific urls
  103523. */
  103524. disableOfflineSupportExceptionRules: RegExp[];
  103525. /**
  103526. * An event triggered when the scene is disposed.
  103527. */
  103528. onDisposeObservable: Observable<Scene>;
  103529. private _onDisposeObserver;
  103530. /** Sets a function to be executed when this scene is disposed. */
  103531. onDispose: () => void;
  103532. /**
  103533. * An event triggered before rendering the scene (right after animations and physics)
  103534. */
  103535. onBeforeRenderObservable: Observable<Scene>;
  103536. private _onBeforeRenderObserver;
  103537. /** Sets a function to be executed before rendering this scene */
  103538. beforeRender: Nullable<() => void>;
  103539. /**
  103540. * An event triggered after rendering the scene
  103541. */
  103542. onAfterRenderObservable: Observable<Scene>;
  103543. /**
  103544. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  103545. */
  103546. onAfterRenderCameraObservable: Observable<Camera>;
  103547. private _onAfterRenderObserver;
  103548. /** Sets a function to be executed after rendering this scene */
  103549. afterRender: Nullable<() => void>;
  103550. /**
  103551. * An event triggered before animating the scene
  103552. */
  103553. onBeforeAnimationsObservable: Observable<Scene>;
  103554. /**
  103555. * An event triggered after animations processing
  103556. */
  103557. onAfterAnimationsObservable: Observable<Scene>;
  103558. /**
  103559. * An event triggered before draw calls are ready to be sent
  103560. */
  103561. onBeforeDrawPhaseObservable: Observable<Scene>;
  103562. /**
  103563. * An event triggered after draw calls have been sent
  103564. */
  103565. onAfterDrawPhaseObservable: Observable<Scene>;
  103566. /**
  103567. * An event triggered when the scene is ready
  103568. */
  103569. onReadyObservable: Observable<Scene>;
  103570. /**
  103571. * An event triggered before rendering a camera
  103572. */
  103573. onBeforeCameraRenderObservable: Observable<Camera>;
  103574. private _onBeforeCameraRenderObserver;
  103575. /** Sets a function to be executed before rendering a camera*/
  103576. beforeCameraRender: () => void;
  103577. /**
  103578. * An event triggered after rendering a camera
  103579. */
  103580. onAfterCameraRenderObservable: Observable<Camera>;
  103581. private _onAfterCameraRenderObserver;
  103582. /** Sets a function to be executed after rendering a camera*/
  103583. afterCameraRender: () => void;
  103584. /**
  103585. * An event triggered when active meshes evaluation is about to start
  103586. */
  103587. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  103588. /**
  103589. * An event triggered when active meshes evaluation is done
  103590. */
  103591. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  103592. /**
  103593. * An event triggered when particles rendering is about to start
  103594. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103595. */
  103596. onBeforeParticlesRenderingObservable: Observable<Scene>;
  103597. /**
  103598. * An event triggered when particles rendering is done
  103599. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  103600. */
  103601. onAfterParticlesRenderingObservable: Observable<Scene>;
  103602. /**
  103603. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  103604. */
  103605. onDataLoadedObservable: Observable<Scene>;
  103606. /**
  103607. * An event triggered when a camera is created
  103608. */
  103609. onNewCameraAddedObservable: Observable<Camera>;
  103610. /**
  103611. * An event triggered when a camera is removed
  103612. */
  103613. onCameraRemovedObservable: Observable<Camera>;
  103614. /**
  103615. * An event triggered when a light is created
  103616. */
  103617. onNewLightAddedObservable: Observable<Light>;
  103618. /**
  103619. * An event triggered when a light is removed
  103620. */
  103621. onLightRemovedObservable: Observable<Light>;
  103622. /**
  103623. * An event triggered when a geometry is created
  103624. */
  103625. onNewGeometryAddedObservable: Observable<Geometry>;
  103626. /**
  103627. * An event triggered when a geometry is removed
  103628. */
  103629. onGeometryRemovedObservable: Observable<Geometry>;
  103630. /**
  103631. * An event triggered when a transform node is created
  103632. */
  103633. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  103634. /**
  103635. * An event triggered when a transform node is removed
  103636. */
  103637. onTransformNodeRemovedObservable: Observable<TransformNode>;
  103638. /**
  103639. * An event triggered when a mesh is created
  103640. */
  103641. onNewMeshAddedObservable: Observable<AbstractMesh>;
  103642. /**
  103643. * An event triggered when a mesh is removed
  103644. */
  103645. onMeshRemovedObservable: Observable<AbstractMesh>;
  103646. /**
  103647. * An event triggered when a skeleton is created
  103648. */
  103649. onNewSkeletonAddedObservable: Observable<Skeleton>;
  103650. /**
  103651. * An event triggered when a skeleton is removed
  103652. */
  103653. onSkeletonRemovedObservable: Observable<Skeleton>;
  103654. /**
  103655. * An event triggered when a material is created
  103656. */
  103657. onNewMaterialAddedObservable: Observable<Material>;
  103658. /**
  103659. * An event triggered when a material is removed
  103660. */
  103661. onMaterialRemovedObservable: Observable<Material>;
  103662. /**
  103663. * An event triggered when a texture is created
  103664. */
  103665. onNewTextureAddedObservable: Observable<BaseTexture>;
  103666. /**
  103667. * An event triggered when a texture is removed
  103668. */
  103669. onTextureRemovedObservable: Observable<BaseTexture>;
  103670. /**
  103671. * An event triggered when render targets are about to be rendered
  103672. * Can happen multiple times per frame.
  103673. */
  103674. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  103675. /**
  103676. * An event triggered when render targets were rendered.
  103677. * Can happen multiple times per frame.
  103678. */
  103679. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  103680. /**
  103681. * An event triggered before calculating deterministic simulation step
  103682. */
  103683. onBeforeStepObservable: Observable<Scene>;
  103684. /**
  103685. * An event triggered after calculating deterministic simulation step
  103686. */
  103687. onAfterStepObservable: Observable<Scene>;
  103688. /**
  103689. * An event triggered when the activeCamera property is updated
  103690. */
  103691. onActiveCameraChanged: Observable<Scene>;
  103692. /**
  103693. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  103694. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103695. * 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)
  103696. */
  103697. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103698. /**
  103699. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  103700. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  103701. * 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)
  103702. */
  103703. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  103704. /**
  103705. * This Observable will when a mesh has been imported into the scene.
  103706. */
  103707. onMeshImportedObservable: Observable<AbstractMesh>;
  103708. /**
  103709. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  103710. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  103711. */
  103712. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  103713. /** @hidden */
  103714. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  103715. /**
  103716. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  103717. */
  103718. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  103719. /**
  103720. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  103721. */
  103722. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  103723. /**
  103724. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  103725. */
  103726. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  103727. /** Callback called when a pointer move is detected */
  103728. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103729. /** Callback called when a pointer down is detected */
  103730. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  103731. /** Callback called when a pointer up is detected */
  103732. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  103733. /** Callback called when a pointer pick is detected */
  103734. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  103735. /**
  103736. * 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).
  103737. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  103738. */
  103739. onPrePointerObservable: Observable<PointerInfoPre>;
  103740. /**
  103741. * Observable event triggered each time an input event is received from the rendering canvas
  103742. */
  103743. onPointerObservable: Observable<PointerInfo>;
  103744. /**
  103745. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  103746. */
  103747. readonly unTranslatedPointer: Vector2;
  103748. /**
  103749. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  103750. */
  103751. static DragMovementThreshold: number;
  103752. /**
  103753. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  103754. */
  103755. static LongPressDelay: number;
  103756. /**
  103757. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  103758. */
  103759. static DoubleClickDelay: number;
  103760. /** If you need to check double click without raising a single click at first click, enable this flag */
  103761. static ExclusiveDoubleClickMode: boolean;
  103762. /** @hidden */
  103763. _mirroredCameraPosition: Nullable<Vector3>;
  103764. /**
  103765. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  103766. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  103767. */
  103768. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  103769. /**
  103770. * Observable event triggered each time an keyboard event is received from the hosting window
  103771. */
  103772. onKeyboardObservable: Observable<KeyboardInfo>;
  103773. private _useRightHandedSystem;
  103774. /**
  103775. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  103776. */
  103777. useRightHandedSystem: boolean;
  103778. private _timeAccumulator;
  103779. private _currentStepId;
  103780. private _currentInternalStep;
  103781. /**
  103782. * Sets the step Id used by deterministic lock step
  103783. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103784. * @param newStepId defines the step Id
  103785. */
  103786. setStepId(newStepId: number): void;
  103787. /**
  103788. * Gets the step Id used by deterministic lock step
  103789. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103790. * @returns the step Id
  103791. */
  103792. getStepId(): number;
  103793. /**
  103794. * Gets the internal step used by deterministic lock step
  103795. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103796. * @returns the internal step
  103797. */
  103798. getInternalStep(): number;
  103799. private _fogEnabled;
  103800. /**
  103801. * Gets or sets a boolean indicating if fog is enabled on this scene
  103802. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103803. * (Default is true)
  103804. */
  103805. fogEnabled: boolean;
  103806. private _fogMode;
  103807. /**
  103808. * Gets or sets the fog mode to use
  103809. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103810. * | mode | value |
  103811. * | --- | --- |
  103812. * | FOGMODE_NONE | 0 |
  103813. * | FOGMODE_EXP | 1 |
  103814. * | FOGMODE_EXP2 | 2 |
  103815. * | FOGMODE_LINEAR | 3 |
  103816. */
  103817. fogMode: number;
  103818. /**
  103819. * Gets or sets the fog color to use
  103820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103821. * (Default is Color3(0.2, 0.2, 0.3))
  103822. */
  103823. fogColor: Color3;
  103824. /**
  103825. * Gets or sets the fog density to use
  103826. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103827. * (Default is 0.1)
  103828. */
  103829. fogDensity: number;
  103830. /**
  103831. * Gets or sets the fog start distance to use
  103832. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103833. * (Default is 0)
  103834. */
  103835. fogStart: number;
  103836. /**
  103837. * Gets or sets the fog end distance to use
  103838. * @see http://doc.babylonjs.com/babylon101/environment#fog
  103839. * (Default is 1000)
  103840. */
  103841. fogEnd: number;
  103842. private _shadowsEnabled;
  103843. /**
  103844. * Gets or sets a boolean indicating if shadows are enabled on this scene
  103845. */
  103846. shadowsEnabled: boolean;
  103847. private _lightsEnabled;
  103848. /**
  103849. * Gets or sets a boolean indicating if lights are enabled on this scene
  103850. */
  103851. lightsEnabled: boolean;
  103852. /** All of the active cameras added to this scene. */
  103853. activeCameras: Camera[];
  103854. /** @hidden */
  103855. _activeCamera: Nullable<Camera>;
  103856. /** Gets or sets the current active camera */
  103857. activeCamera: Nullable<Camera>;
  103858. private _defaultMaterial;
  103859. /** The default material used on meshes when no material is affected */
  103860. /** The default material used on meshes when no material is affected */
  103861. defaultMaterial: Material;
  103862. private _texturesEnabled;
  103863. /**
  103864. * Gets or sets a boolean indicating if textures are enabled on this scene
  103865. */
  103866. texturesEnabled: boolean;
  103867. /**
  103868. * Gets or sets a boolean indicating if particles are enabled on this scene
  103869. */
  103870. particlesEnabled: boolean;
  103871. /**
  103872. * Gets or sets a boolean indicating if sprites are enabled on this scene
  103873. */
  103874. spritesEnabled: boolean;
  103875. private _skeletonsEnabled;
  103876. /**
  103877. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  103878. */
  103879. skeletonsEnabled: boolean;
  103880. /**
  103881. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  103882. */
  103883. lensFlaresEnabled: boolean;
  103884. /**
  103885. * Gets or sets a boolean indicating if collisions are enabled on this scene
  103886. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103887. */
  103888. collisionsEnabled: boolean;
  103889. private _collisionCoordinator;
  103890. /** @hidden */
  103891. readonly collisionCoordinator: ICollisionCoordinator;
  103892. /**
  103893. * Defines the gravity applied to this scene (used only for collisions)
  103894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103895. */
  103896. gravity: Vector3;
  103897. /**
  103898. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  103899. */
  103900. postProcessesEnabled: boolean;
  103901. /**
  103902. * The list of postprocesses added to the scene
  103903. */
  103904. postProcesses: PostProcess[];
  103905. /**
  103906. * Gets the current postprocess manager
  103907. */
  103908. postProcessManager: PostProcessManager;
  103909. /**
  103910. * Gets or sets a boolean indicating if render targets are enabled on this scene
  103911. */
  103912. renderTargetsEnabled: boolean;
  103913. /**
  103914. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  103915. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  103916. */
  103917. dumpNextRenderTargets: boolean;
  103918. /**
  103919. * The list of user defined render targets added to the scene
  103920. */
  103921. customRenderTargets: RenderTargetTexture[];
  103922. /**
  103923. * Defines if texture loading must be delayed
  103924. * If true, textures will only be loaded when they need to be rendered
  103925. */
  103926. useDelayedTextureLoading: boolean;
  103927. /**
  103928. * Gets the list of meshes imported to the scene through SceneLoader
  103929. */
  103930. importedMeshesFiles: String[];
  103931. /**
  103932. * Gets or sets a boolean indicating if probes are enabled on this scene
  103933. */
  103934. probesEnabled: boolean;
  103935. /**
  103936. * Gets or sets the current offline provider to use to store scene data
  103937. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  103938. */
  103939. offlineProvider: IOfflineProvider;
  103940. /**
  103941. * Gets or sets the action manager associated with the scene
  103942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103943. */
  103944. actionManager: AbstractActionManager;
  103945. private _meshesForIntersections;
  103946. /**
  103947. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  103948. */
  103949. proceduralTexturesEnabled: boolean;
  103950. private _engine;
  103951. private _totalVertices;
  103952. /** @hidden */
  103953. _activeIndices: PerfCounter;
  103954. /** @hidden */
  103955. _activeParticles: PerfCounter;
  103956. /** @hidden */
  103957. _activeBones: PerfCounter;
  103958. private _animationRatio;
  103959. /** @hidden */
  103960. _animationTimeLast: number;
  103961. /** @hidden */
  103962. _animationTime: number;
  103963. /**
  103964. * Gets or sets a general scale for animation speed
  103965. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  103966. */
  103967. animationTimeScale: number;
  103968. /** @hidden */
  103969. _cachedMaterial: Nullable<Material>;
  103970. /** @hidden */
  103971. _cachedEffect: Nullable<Effect>;
  103972. /** @hidden */
  103973. _cachedVisibility: Nullable<number>;
  103974. private _renderId;
  103975. private _frameId;
  103976. private _executeWhenReadyTimeoutId;
  103977. private _intermediateRendering;
  103978. private _viewUpdateFlag;
  103979. private _projectionUpdateFlag;
  103980. /** @hidden */
  103981. _toBeDisposed: Nullable<IDisposable>[];
  103982. private _activeRequests;
  103983. /** @hidden */
  103984. _pendingData: any[];
  103985. private _isDisposed;
  103986. /**
  103987. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  103988. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  103989. */
  103990. dispatchAllSubMeshesOfActiveMeshes: boolean;
  103991. private _activeMeshes;
  103992. private _processedMaterials;
  103993. private _renderTargets;
  103994. /** @hidden */
  103995. _activeParticleSystems: SmartArray<IParticleSystem>;
  103996. private _activeSkeletons;
  103997. private _softwareSkinnedMeshes;
  103998. private _renderingManager;
  103999. /** @hidden */
  104000. _activeAnimatables: Animatable[];
  104001. private _transformMatrix;
  104002. private _sceneUbo;
  104003. /** @hidden */
  104004. _viewMatrix: Matrix;
  104005. private _projectionMatrix;
  104006. /** @hidden */
  104007. _forcedViewPosition: Nullable<Vector3>;
  104008. /** @hidden */
  104009. _frustumPlanes: Plane[];
  104010. /**
  104011. * Gets the list of frustum planes (built from the active camera)
  104012. */
  104013. readonly frustumPlanes: Plane[];
  104014. /**
  104015. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104016. * This is useful if there are more lights that the maximum simulteanous authorized
  104017. */
  104018. requireLightSorting: boolean;
  104019. /** @hidden */
  104020. readonly useMaterialMeshMap: boolean;
  104021. /** @hidden */
  104022. readonly useClonedMeshhMap: boolean;
  104023. private _externalData;
  104024. private _uid;
  104025. /**
  104026. * @hidden
  104027. * Backing store of defined scene components.
  104028. */
  104029. _components: ISceneComponent[];
  104030. /**
  104031. * @hidden
  104032. * Backing store of defined scene components.
  104033. */
  104034. _serializableComponents: ISceneSerializableComponent[];
  104035. /**
  104036. * List of components to register on the next registration step.
  104037. */
  104038. private _transientComponents;
  104039. /**
  104040. * Registers the transient components if needed.
  104041. */
  104042. private _registerTransientComponents;
  104043. /**
  104044. * @hidden
  104045. * Add a component to the scene.
  104046. * Note that the ccomponent could be registered on th next frame if this is called after
  104047. * the register component stage.
  104048. * @param component Defines the component to add to the scene
  104049. */
  104050. _addComponent(component: ISceneComponent): void;
  104051. /**
  104052. * @hidden
  104053. * Gets a component from the scene.
  104054. * @param name defines the name of the component to retrieve
  104055. * @returns the component or null if not present
  104056. */
  104057. _getComponent(name: string): Nullable<ISceneComponent>;
  104058. /**
  104059. * @hidden
  104060. * Defines the actions happening before camera updates.
  104061. */
  104062. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104063. /**
  104064. * @hidden
  104065. * Defines the actions happening before clear the canvas.
  104066. */
  104067. _beforeClearStage: Stage<SimpleStageAction>;
  104068. /**
  104069. * @hidden
  104070. * Defines the actions when collecting render targets for the frame.
  104071. */
  104072. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104073. /**
  104074. * @hidden
  104075. * Defines the actions happening for one camera in the frame.
  104076. */
  104077. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104078. /**
  104079. * @hidden
  104080. * Defines the actions happening during the per mesh ready checks.
  104081. */
  104082. _isReadyForMeshStage: Stage<MeshStageAction>;
  104083. /**
  104084. * @hidden
  104085. * Defines the actions happening before evaluate active mesh checks.
  104086. */
  104087. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104088. /**
  104089. * @hidden
  104090. * Defines the actions happening during the evaluate sub mesh checks.
  104091. */
  104092. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104093. /**
  104094. * @hidden
  104095. * Defines the actions happening during the active mesh stage.
  104096. */
  104097. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104098. /**
  104099. * @hidden
  104100. * Defines the actions happening during the per camera render target step.
  104101. */
  104102. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104103. /**
  104104. * @hidden
  104105. * Defines the actions happening just before the active camera is drawing.
  104106. */
  104107. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104108. /**
  104109. * @hidden
  104110. * Defines the actions happening just before a render target is drawing.
  104111. */
  104112. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104113. /**
  104114. * @hidden
  104115. * Defines the actions happening just before a rendering group is drawing.
  104116. */
  104117. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104118. /**
  104119. * @hidden
  104120. * Defines the actions happening just before a mesh is drawing.
  104121. */
  104122. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104123. /**
  104124. * @hidden
  104125. * Defines the actions happening just after a mesh has been drawn.
  104126. */
  104127. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104128. /**
  104129. * @hidden
  104130. * Defines the actions happening just after a rendering group has been drawn.
  104131. */
  104132. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104133. /**
  104134. * @hidden
  104135. * Defines the actions happening just after the active camera has been drawn.
  104136. */
  104137. _afterCameraDrawStage: Stage<CameraStageAction>;
  104138. /**
  104139. * @hidden
  104140. * Defines the actions happening just after a render target has been drawn.
  104141. */
  104142. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104143. /**
  104144. * @hidden
  104145. * Defines the actions happening just after rendering all cameras and computing intersections.
  104146. */
  104147. _afterRenderStage: Stage<SimpleStageAction>;
  104148. /**
  104149. * @hidden
  104150. * Defines the actions happening when a pointer move event happens.
  104151. */
  104152. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104153. /**
  104154. * @hidden
  104155. * Defines the actions happening when a pointer down event happens.
  104156. */
  104157. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104158. /**
  104159. * @hidden
  104160. * Defines the actions happening when a pointer up event happens.
  104161. */
  104162. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104163. /**
  104164. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104165. */
  104166. private geometriesByUniqueId;
  104167. /**
  104168. * Creates a new Scene
  104169. * @param engine defines the engine to use to render this scene
  104170. * @param options defines the scene options
  104171. */
  104172. constructor(engine: Engine, options?: SceneOptions);
  104173. /**
  104174. * Gets a string idenfifying the name of the class
  104175. * @returns "Scene" string
  104176. */
  104177. getClassName(): string;
  104178. private _defaultMeshCandidates;
  104179. /**
  104180. * @hidden
  104181. */
  104182. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104183. private _defaultSubMeshCandidates;
  104184. /**
  104185. * @hidden
  104186. */
  104187. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104188. /**
  104189. * Sets the default candidate providers for the scene.
  104190. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104191. * and getCollidingSubMeshCandidates to their default function
  104192. */
  104193. setDefaultCandidateProviders(): void;
  104194. /**
  104195. * Gets the mesh that is currently under the pointer
  104196. */
  104197. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104198. /**
  104199. * Gets or sets the current on-screen X position of the pointer
  104200. */
  104201. pointerX: number;
  104202. /**
  104203. * Gets or sets the current on-screen Y position of the pointer
  104204. */
  104205. pointerY: number;
  104206. /**
  104207. * Gets the cached material (ie. the latest rendered one)
  104208. * @returns the cached material
  104209. */
  104210. getCachedMaterial(): Nullable<Material>;
  104211. /**
  104212. * Gets the cached effect (ie. the latest rendered one)
  104213. * @returns the cached effect
  104214. */
  104215. getCachedEffect(): Nullable<Effect>;
  104216. /**
  104217. * Gets the cached visibility state (ie. the latest rendered one)
  104218. * @returns the cached visibility state
  104219. */
  104220. getCachedVisibility(): Nullable<number>;
  104221. /**
  104222. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104223. * @param material defines the current material
  104224. * @param effect defines the current effect
  104225. * @param visibility defines the current visibility state
  104226. * @returns true if one parameter is not cached
  104227. */
  104228. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104229. /**
  104230. * Gets the engine associated with the scene
  104231. * @returns an Engine
  104232. */
  104233. getEngine(): Engine;
  104234. /**
  104235. * Gets the total number of vertices rendered per frame
  104236. * @returns the total number of vertices rendered per frame
  104237. */
  104238. getTotalVertices(): number;
  104239. /**
  104240. * Gets the performance counter for total vertices
  104241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104242. */
  104243. readonly totalVerticesPerfCounter: PerfCounter;
  104244. /**
  104245. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104246. * @returns the total number of active indices rendered per frame
  104247. */
  104248. getActiveIndices(): number;
  104249. /**
  104250. * Gets the performance counter for active indices
  104251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104252. */
  104253. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104254. /**
  104255. * Gets the total number of active particles rendered per frame
  104256. * @returns the total number of active particles rendered per frame
  104257. */
  104258. getActiveParticles(): number;
  104259. /**
  104260. * Gets the performance counter for active particles
  104261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104262. */
  104263. readonly activeParticlesPerfCounter: PerfCounter;
  104264. /**
  104265. * Gets the total number of active bones rendered per frame
  104266. * @returns the total number of active bones rendered per frame
  104267. */
  104268. getActiveBones(): number;
  104269. /**
  104270. * Gets the performance counter for active bones
  104271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104272. */
  104273. readonly activeBonesPerfCounter: PerfCounter;
  104274. /**
  104275. * Gets the array of active meshes
  104276. * @returns an array of AbstractMesh
  104277. */
  104278. getActiveMeshes(): SmartArray<AbstractMesh>;
  104279. /**
  104280. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104281. * @returns a number
  104282. */
  104283. getAnimationRatio(): number;
  104284. /**
  104285. * Gets an unique Id for the current render phase
  104286. * @returns a number
  104287. */
  104288. getRenderId(): number;
  104289. /**
  104290. * Gets an unique Id for the current frame
  104291. * @returns a number
  104292. */
  104293. getFrameId(): number;
  104294. /** Call this function if you want to manually increment the render Id*/
  104295. incrementRenderId(): void;
  104296. private _createUbo;
  104297. /**
  104298. * Use this method to simulate a pointer move on a mesh
  104299. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104300. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104301. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104302. * @returns the current scene
  104303. */
  104304. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104305. /**
  104306. * Use this method to simulate a pointer down on a mesh
  104307. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104308. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104309. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104310. * @returns the current scene
  104311. */
  104312. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104313. /**
  104314. * Use this method to simulate a pointer up on a mesh
  104315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104318. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104319. * @returns the current scene
  104320. */
  104321. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104322. /**
  104323. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104324. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104325. * @returns true if the pointer was captured
  104326. */
  104327. isPointerCaptured(pointerId?: number): boolean;
  104328. /**
  104329. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104330. * @param attachUp defines if you want to attach events to pointerup
  104331. * @param attachDown defines if you want to attach events to pointerdown
  104332. * @param attachMove defines if you want to attach events to pointermove
  104333. */
  104334. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104335. /** Detaches all event handlers*/
  104336. detachControl(): void;
  104337. /**
  104338. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104339. * Delay loaded resources are not taking in account
  104340. * @return true if all required resources are ready
  104341. */
  104342. isReady(): boolean;
  104343. /** Resets all cached information relative to material (including effect and visibility) */
  104344. resetCachedMaterial(): void;
  104345. /**
  104346. * Registers a function to be called before every frame render
  104347. * @param func defines the function to register
  104348. */
  104349. registerBeforeRender(func: () => void): void;
  104350. /**
  104351. * Unregisters a function called before every frame render
  104352. * @param func defines the function to unregister
  104353. */
  104354. unregisterBeforeRender(func: () => void): void;
  104355. /**
  104356. * Registers a function to be called after every frame render
  104357. * @param func defines the function to register
  104358. */
  104359. registerAfterRender(func: () => void): void;
  104360. /**
  104361. * Unregisters a function called after every frame render
  104362. * @param func defines the function to unregister
  104363. */
  104364. unregisterAfterRender(func: () => void): void;
  104365. private _executeOnceBeforeRender;
  104366. /**
  104367. * The provided function will run before render once and will be disposed afterwards.
  104368. * A timeout delay can be provided so that the function will be executed in N ms.
  104369. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104370. * @param func The function to be executed.
  104371. * @param timeout optional delay in ms
  104372. */
  104373. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104374. /** @hidden */
  104375. _addPendingData(data: any): void;
  104376. /** @hidden */
  104377. _removePendingData(data: any): void;
  104378. /**
  104379. * Returns the number of items waiting to be loaded
  104380. * @returns the number of items waiting to be loaded
  104381. */
  104382. getWaitingItemsCount(): number;
  104383. /**
  104384. * Returns a boolean indicating if the scene is still loading data
  104385. */
  104386. readonly isLoading: boolean;
  104387. /**
  104388. * Registers a function to be executed when the scene is ready
  104389. * @param {Function} func - the function to be executed
  104390. */
  104391. executeWhenReady(func: () => void): void;
  104392. /**
  104393. * Returns a promise that resolves when the scene is ready
  104394. * @returns A promise that resolves when the scene is ready
  104395. */
  104396. whenReadyAsync(): Promise<void>;
  104397. /** @hidden */
  104398. _checkIsReady(): void;
  104399. /**
  104400. * Gets all animatable attached to the scene
  104401. */
  104402. readonly animatables: Animatable[];
  104403. /**
  104404. * Resets the last animation time frame.
  104405. * Useful to override when animations start running when loading a scene for the first time.
  104406. */
  104407. resetLastAnimationTimeFrame(): void;
  104408. /**
  104409. * Gets the current view matrix
  104410. * @returns a Matrix
  104411. */
  104412. getViewMatrix(): Matrix;
  104413. /**
  104414. * Gets the current projection matrix
  104415. * @returns a Matrix
  104416. */
  104417. getProjectionMatrix(): Matrix;
  104418. /**
  104419. * Gets the current transform matrix
  104420. * @returns a Matrix made of View * Projection
  104421. */
  104422. getTransformMatrix(): Matrix;
  104423. /**
  104424. * Sets the current transform matrix
  104425. * @param viewL defines the View matrix to use
  104426. * @param projectionL defines the Projection matrix to use
  104427. * @param viewR defines the right View matrix to use (if provided)
  104428. * @param projectionR defines the right Projection matrix to use (if provided)
  104429. */
  104430. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104431. /**
  104432. * Gets the uniform buffer used to store scene data
  104433. * @returns a UniformBuffer
  104434. */
  104435. getSceneUniformBuffer(): UniformBuffer;
  104436. /**
  104437. * Gets an unique (relatively to the current scene) Id
  104438. * @returns an unique number for the scene
  104439. */
  104440. getUniqueId(): number;
  104441. /**
  104442. * Add a mesh to the list of scene's meshes
  104443. * @param newMesh defines the mesh to add
  104444. * @param recursive if all child meshes should also be added to the scene
  104445. */
  104446. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104447. /**
  104448. * Remove a mesh for the list of scene's meshes
  104449. * @param toRemove defines the mesh to remove
  104450. * @param recursive if all child meshes should also be removed from the scene
  104451. * @returns the index where the mesh was in the mesh list
  104452. */
  104453. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104454. /**
  104455. * Add a transform node to the list of scene's transform nodes
  104456. * @param newTransformNode defines the transform node to add
  104457. */
  104458. addTransformNode(newTransformNode: TransformNode): void;
  104459. /**
  104460. * Remove a transform node for the list of scene's transform nodes
  104461. * @param toRemove defines the transform node to remove
  104462. * @returns the index where the transform node was in the transform node list
  104463. */
  104464. removeTransformNode(toRemove: TransformNode): number;
  104465. /**
  104466. * Remove a skeleton for the list of scene's skeletons
  104467. * @param toRemove defines the skeleton to remove
  104468. * @returns the index where the skeleton was in the skeleton list
  104469. */
  104470. removeSkeleton(toRemove: Skeleton): number;
  104471. /**
  104472. * Remove a morph target for the list of scene's morph targets
  104473. * @param toRemove defines the morph target to remove
  104474. * @returns the index where the morph target was in the morph target list
  104475. */
  104476. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  104477. /**
  104478. * Remove a light for the list of scene's lights
  104479. * @param toRemove defines the light to remove
  104480. * @returns the index where the light was in the light list
  104481. */
  104482. removeLight(toRemove: Light): number;
  104483. /**
  104484. * Remove a camera for the list of scene's cameras
  104485. * @param toRemove defines the camera to remove
  104486. * @returns the index where the camera was in the camera list
  104487. */
  104488. removeCamera(toRemove: Camera): number;
  104489. /**
  104490. * Remove a particle system for the list of scene's particle systems
  104491. * @param toRemove defines the particle system to remove
  104492. * @returns the index where the particle system was in the particle system list
  104493. */
  104494. removeParticleSystem(toRemove: IParticleSystem): number;
  104495. /**
  104496. * Remove a animation for the list of scene's animations
  104497. * @param toRemove defines the animation to remove
  104498. * @returns the index where the animation was in the animation list
  104499. */
  104500. removeAnimation(toRemove: Animation): number;
  104501. /**
  104502. * Will stop the animation of the given target
  104503. * @param target - the target
  104504. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  104505. * @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)
  104506. */
  104507. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  104508. /**
  104509. * Removes the given animation group from this scene.
  104510. * @param toRemove The animation group to remove
  104511. * @returns The index of the removed animation group
  104512. */
  104513. removeAnimationGroup(toRemove: AnimationGroup): number;
  104514. /**
  104515. * Removes the given multi-material from this scene.
  104516. * @param toRemove The multi-material to remove
  104517. * @returns The index of the removed multi-material
  104518. */
  104519. removeMultiMaterial(toRemove: MultiMaterial): number;
  104520. /**
  104521. * Removes the given material from this scene.
  104522. * @param toRemove The material to remove
  104523. * @returns The index of the removed material
  104524. */
  104525. removeMaterial(toRemove: Material): number;
  104526. /**
  104527. * Removes the given action manager from this scene.
  104528. * @param toRemove The action manager to remove
  104529. * @returns The index of the removed action manager
  104530. */
  104531. removeActionManager(toRemove: AbstractActionManager): number;
  104532. /**
  104533. * Removes the given texture from this scene.
  104534. * @param toRemove The texture to remove
  104535. * @returns The index of the removed texture
  104536. */
  104537. removeTexture(toRemove: BaseTexture): number;
  104538. /**
  104539. * Adds the given light to this scene
  104540. * @param newLight The light to add
  104541. */
  104542. addLight(newLight: Light): void;
  104543. /**
  104544. * Sorts the list list based on light priorities
  104545. */
  104546. sortLightsByPriority(): void;
  104547. /**
  104548. * Adds the given camera to this scene
  104549. * @param newCamera The camera to add
  104550. */
  104551. addCamera(newCamera: Camera): void;
  104552. /**
  104553. * Adds the given skeleton to this scene
  104554. * @param newSkeleton The skeleton to add
  104555. */
  104556. addSkeleton(newSkeleton: Skeleton): void;
  104557. /**
  104558. * Adds the given particle system to this scene
  104559. * @param newParticleSystem The particle system to add
  104560. */
  104561. addParticleSystem(newParticleSystem: IParticleSystem): void;
  104562. /**
  104563. * Adds the given animation to this scene
  104564. * @param newAnimation The animation to add
  104565. */
  104566. addAnimation(newAnimation: Animation): void;
  104567. /**
  104568. * Adds the given animation group to this scene.
  104569. * @param newAnimationGroup The animation group to add
  104570. */
  104571. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  104572. /**
  104573. * Adds the given multi-material to this scene
  104574. * @param newMultiMaterial The multi-material to add
  104575. */
  104576. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  104577. /**
  104578. * Adds the given material to this scene
  104579. * @param newMaterial The material to add
  104580. */
  104581. addMaterial(newMaterial: Material): void;
  104582. /**
  104583. * Adds the given morph target to this scene
  104584. * @param newMorphTargetManager The morph target to add
  104585. */
  104586. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  104587. /**
  104588. * Adds the given geometry to this scene
  104589. * @param newGeometry The geometry to add
  104590. */
  104591. addGeometry(newGeometry: Geometry): void;
  104592. /**
  104593. * Adds the given action manager to this scene
  104594. * @param newActionManager The action manager to add
  104595. */
  104596. addActionManager(newActionManager: AbstractActionManager): void;
  104597. /**
  104598. * Adds the given texture to this scene.
  104599. * @param newTexture The texture to add
  104600. */
  104601. addTexture(newTexture: BaseTexture): void;
  104602. /**
  104603. * Switch active camera
  104604. * @param newCamera defines the new active camera
  104605. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  104606. */
  104607. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  104608. /**
  104609. * sets the active camera of the scene using its ID
  104610. * @param id defines the camera's ID
  104611. * @return the new active camera or null if none found.
  104612. */
  104613. setActiveCameraByID(id: string): Nullable<Camera>;
  104614. /**
  104615. * sets the active camera of the scene using its name
  104616. * @param name defines the camera's name
  104617. * @returns the new active camera or null if none found.
  104618. */
  104619. setActiveCameraByName(name: string): Nullable<Camera>;
  104620. /**
  104621. * get an animation group using its name
  104622. * @param name defines the material's name
  104623. * @return the animation group or null if none found.
  104624. */
  104625. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  104626. /**
  104627. * Get a material using its unique id
  104628. * @param uniqueId defines the material's unique id
  104629. * @return the material or null if none found.
  104630. */
  104631. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  104632. /**
  104633. * get a material using its id
  104634. * @param id defines the material's ID
  104635. * @return the material or null if none found.
  104636. */
  104637. getMaterialByID(id: string): Nullable<Material>;
  104638. /**
  104639. * Gets a the last added material using a given id
  104640. * @param id defines the material's ID
  104641. * @return the last material with the given id or null if none found.
  104642. */
  104643. getLastMaterialByID(id: string): Nullable<Material>;
  104644. /**
  104645. * Gets a material using its name
  104646. * @param name defines the material's name
  104647. * @return the material or null if none found.
  104648. */
  104649. getMaterialByName(name: string): Nullable<Material>;
  104650. /**
  104651. * Get a texture using its unique id
  104652. * @param uniqueId defines the texture's unique id
  104653. * @return the texture or null if none found.
  104654. */
  104655. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  104656. /**
  104657. * Gets a camera using its id
  104658. * @param id defines the id to look for
  104659. * @returns the camera or null if not found
  104660. */
  104661. getCameraByID(id: string): Nullable<Camera>;
  104662. /**
  104663. * Gets a camera using its unique id
  104664. * @param uniqueId defines the unique id to look for
  104665. * @returns the camera or null if not found
  104666. */
  104667. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  104668. /**
  104669. * Gets a camera using its name
  104670. * @param name defines the camera's name
  104671. * @return the camera or null if none found.
  104672. */
  104673. getCameraByName(name: string): Nullable<Camera>;
  104674. /**
  104675. * Gets a bone using its id
  104676. * @param id defines the bone's id
  104677. * @return the bone or null if not found
  104678. */
  104679. getBoneByID(id: string): Nullable<Bone>;
  104680. /**
  104681. * Gets a bone using its id
  104682. * @param name defines the bone's name
  104683. * @return the bone or null if not found
  104684. */
  104685. getBoneByName(name: string): Nullable<Bone>;
  104686. /**
  104687. * Gets a light node using its name
  104688. * @param name defines the the light's name
  104689. * @return the light or null if none found.
  104690. */
  104691. getLightByName(name: string): Nullable<Light>;
  104692. /**
  104693. * Gets a light node using its id
  104694. * @param id defines the light's id
  104695. * @return the light or null if none found.
  104696. */
  104697. getLightByID(id: string): Nullable<Light>;
  104698. /**
  104699. * Gets a light node using its scene-generated unique ID
  104700. * @param uniqueId defines the light's unique id
  104701. * @return the light or null if none found.
  104702. */
  104703. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  104704. /**
  104705. * Gets a particle system by id
  104706. * @param id defines the particle system id
  104707. * @return the corresponding system or null if none found
  104708. */
  104709. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  104710. /**
  104711. * Gets a geometry using its ID
  104712. * @param id defines the geometry's id
  104713. * @return the geometry or null if none found.
  104714. */
  104715. getGeometryByID(id: string): Nullable<Geometry>;
  104716. private _getGeometryByUniqueID;
  104717. /**
  104718. * Add a new geometry to this scene
  104719. * @param geometry defines the geometry to be added to the scene.
  104720. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  104721. * @return a boolean defining if the geometry was added or not
  104722. */
  104723. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  104724. /**
  104725. * Removes an existing geometry
  104726. * @param geometry defines the geometry to be removed from the scene
  104727. * @return a boolean defining if the geometry was removed or not
  104728. */
  104729. removeGeometry(geometry: Geometry): boolean;
  104730. /**
  104731. * Gets the list of geometries attached to the scene
  104732. * @returns an array of Geometry
  104733. */
  104734. getGeometries(): Geometry[];
  104735. /**
  104736. * Gets the first added mesh found of a given ID
  104737. * @param id defines the id to search for
  104738. * @return the mesh found or null if not found at all
  104739. */
  104740. getMeshByID(id: string): Nullable<AbstractMesh>;
  104741. /**
  104742. * Gets a list of meshes using their id
  104743. * @param id defines the id to search for
  104744. * @returns a list of meshes
  104745. */
  104746. getMeshesByID(id: string): Array<AbstractMesh>;
  104747. /**
  104748. * Gets the first added transform node found of a given ID
  104749. * @param id defines the id to search for
  104750. * @return the found transform node or null if not found at all.
  104751. */
  104752. getTransformNodeByID(id: string): Nullable<TransformNode>;
  104753. /**
  104754. * Gets a transform node with its auto-generated unique id
  104755. * @param uniqueId efines the unique id to search for
  104756. * @return the found transform node or null if not found at all.
  104757. */
  104758. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  104759. /**
  104760. * Gets a list of transform nodes using their id
  104761. * @param id defines the id to search for
  104762. * @returns a list of transform nodes
  104763. */
  104764. getTransformNodesByID(id: string): Array<TransformNode>;
  104765. /**
  104766. * Gets a mesh with its auto-generated unique id
  104767. * @param uniqueId defines the unique id to search for
  104768. * @return the found mesh or null if not found at all.
  104769. */
  104770. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  104771. /**
  104772. * Gets a the last added mesh using a given id
  104773. * @param id defines the id to search for
  104774. * @return the found mesh or null if not found at all.
  104775. */
  104776. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  104777. /**
  104778. * Gets a the last added node (Mesh, Camera, Light) using a given id
  104779. * @param id defines the id to search for
  104780. * @return the found node or null if not found at all
  104781. */
  104782. getLastEntryByID(id: string): Nullable<Node>;
  104783. /**
  104784. * Gets a node (Mesh, Camera, Light) using a given id
  104785. * @param id defines the id to search for
  104786. * @return the found node or null if not found at all
  104787. */
  104788. getNodeByID(id: string): Nullable<Node>;
  104789. /**
  104790. * Gets a node (Mesh, Camera, Light) using a given name
  104791. * @param name defines the name to search for
  104792. * @return the found node or null if not found at all.
  104793. */
  104794. getNodeByName(name: string): Nullable<Node>;
  104795. /**
  104796. * Gets a mesh using a given name
  104797. * @param name defines the name to search for
  104798. * @return the found mesh or null if not found at all.
  104799. */
  104800. getMeshByName(name: string): Nullable<AbstractMesh>;
  104801. /**
  104802. * Gets a transform node using a given name
  104803. * @param name defines the name to search for
  104804. * @return the found transform node or null if not found at all.
  104805. */
  104806. getTransformNodeByName(name: string): Nullable<TransformNode>;
  104807. /**
  104808. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  104809. * @param id defines the id to search for
  104810. * @return the found skeleton or null if not found at all.
  104811. */
  104812. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  104813. /**
  104814. * Gets a skeleton using a given auto generated unique id
  104815. * @param uniqueId defines the unique id to search for
  104816. * @return the found skeleton or null if not found at all.
  104817. */
  104818. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  104819. /**
  104820. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  104821. * @param id defines the id to search for
  104822. * @return the found skeleton or null if not found at all.
  104823. */
  104824. getSkeletonById(id: string): Nullable<Skeleton>;
  104825. /**
  104826. * Gets a skeleton using a given name
  104827. * @param name defines the name to search for
  104828. * @return the found skeleton or null if not found at all.
  104829. */
  104830. getSkeletonByName(name: string): Nullable<Skeleton>;
  104831. /**
  104832. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  104833. * @param id defines the id to search for
  104834. * @return the found morph target manager or null if not found at all.
  104835. */
  104836. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  104837. /**
  104838. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  104839. * @param id defines the id to search for
  104840. * @return the found morph target or null if not found at all.
  104841. */
  104842. getMorphTargetById(id: string): Nullable<MorphTarget>;
  104843. /**
  104844. * Gets a boolean indicating if the given mesh is active
  104845. * @param mesh defines the mesh to look for
  104846. * @returns true if the mesh is in the active list
  104847. */
  104848. isActiveMesh(mesh: AbstractMesh): boolean;
  104849. /**
  104850. * Return a unique id as a string which can serve as an identifier for the scene
  104851. */
  104852. readonly uid: string;
  104853. /**
  104854. * Add an externaly attached data from its key.
  104855. * This method call will fail and return false, if such key already exists.
  104856. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  104857. * @param key the unique key that identifies the data
  104858. * @param data the data object to associate to the key for this Engine instance
  104859. * @return true if no such key were already present and the data was added successfully, false otherwise
  104860. */
  104861. addExternalData<T>(key: string, data: T): boolean;
  104862. /**
  104863. * Get an externaly attached data from its key
  104864. * @param key the unique key that identifies the data
  104865. * @return the associated data, if present (can be null), or undefined if not present
  104866. */
  104867. getExternalData<T>(key: string): Nullable<T>;
  104868. /**
  104869. * Get an externaly attached data from its key, create it using a factory if it's not already present
  104870. * @param key the unique key that identifies the data
  104871. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  104872. * @return the associated data, can be null if the factory returned null.
  104873. */
  104874. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  104875. /**
  104876. * Remove an externaly attached data from the Engine instance
  104877. * @param key the unique key that identifies the data
  104878. * @return true if the data was successfully removed, false if it doesn't exist
  104879. */
  104880. removeExternalData(key: string): boolean;
  104881. private _evaluateSubMesh;
  104882. /**
  104883. * Clear the processed materials smart array preventing retention point in material dispose.
  104884. */
  104885. freeProcessedMaterials(): void;
  104886. private _preventFreeActiveMeshesAndRenderingGroups;
  104887. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  104888. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  104889. * when disposing several meshes in a row or a hierarchy of meshes.
  104890. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  104891. */
  104892. blockfreeActiveMeshesAndRenderingGroups: boolean;
  104893. /**
  104894. * Clear the active meshes smart array preventing retention point in mesh dispose.
  104895. */
  104896. freeActiveMeshes(): void;
  104897. /**
  104898. * Clear the info related to rendering groups preventing retention points during dispose.
  104899. */
  104900. freeRenderingGroups(): void;
  104901. /** @hidden */
  104902. _isInIntermediateRendering(): boolean;
  104903. /**
  104904. * Lambda returning the list of potentially active meshes.
  104905. */
  104906. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  104907. /**
  104908. * Lambda returning the list of potentially active sub meshes.
  104909. */
  104910. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  104911. /**
  104912. * Lambda returning the list of potentially intersecting sub meshes.
  104913. */
  104914. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  104915. /**
  104916. * Lambda returning the list of potentially colliding sub meshes.
  104917. */
  104918. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  104919. private _activeMeshesFrozen;
  104920. private _skipEvaluateActiveMeshesCompletely;
  104921. /**
  104922. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  104923. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  104924. * @returns the current scene
  104925. */
  104926. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  104927. /**
  104928. * Use this function to restart evaluating active meshes on every frame
  104929. * @returns the current scene
  104930. */
  104931. unfreezeActiveMeshes(): Scene;
  104932. private _evaluateActiveMeshes;
  104933. private _activeMesh;
  104934. /**
  104935. * Update the transform matrix to update from the current active camera
  104936. * @param force defines a boolean used to force the update even if cache is up to date
  104937. */
  104938. updateTransformMatrix(force?: boolean): void;
  104939. private _bindFrameBuffer;
  104940. /** @hidden */
  104941. _allowPostProcessClearColor: boolean;
  104942. /** @hidden */
  104943. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  104944. private _processSubCameras;
  104945. private _checkIntersections;
  104946. /** @hidden */
  104947. _advancePhysicsEngineStep(step: number): void;
  104948. /**
  104949. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  104950. */
  104951. getDeterministicFrameTime: () => number;
  104952. /** @hidden */
  104953. _animate(): void;
  104954. /** Execute all animations (for a frame) */
  104955. animate(): void;
  104956. /**
  104957. * Render the scene
  104958. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  104959. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  104960. */
  104961. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  104962. /**
  104963. * Freeze all materials
  104964. * A frozen material will not be updatable but should be faster to render
  104965. */
  104966. freezeMaterials(): void;
  104967. /**
  104968. * Unfreeze all materials
  104969. * A frozen material will not be updatable but should be faster to render
  104970. */
  104971. unfreezeMaterials(): void;
  104972. /**
  104973. * Releases all held ressources
  104974. */
  104975. dispose(): void;
  104976. /**
  104977. * Gets if the scene is already disposed
  104978. */
  104979. readonly isDisposed: boolean;
  104980. /**
  104981. * Call this function to reduce memory footprint of the scene.
  104982. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  104983. */
  104984. clearCachedVertexData(): void;
  104985. /**
  104986. * This function will remove the local cached buffer data from texture.
  104987. * It will save memory but will prevent the texture from being rebuilt
  104988. */
  104989. cleanCachedTextureBuffer(): void;
  104990. /**
  104991. * Get the world extend vectors with an optional filter
  104992. *
  104993. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  104994. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  104995. */
  104996. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  104997. min: Vector3;
  104998. max: Vector3;
  104999. };
  105000. /**
  105001. * Creates a ray that can be used to pick in the scene
  105002. * @param x defines the x coordinate of the origin (on-screen)
  105003. * @param y defines the y coordinate of the origin (on-screen)
  105004. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105005. * @param camera defines the camera to use for the picking
  105006. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105007. * @returns a Ray
  105008. */
  105009. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105010. /**
  105011. * Creates a ray that can be used to pick in the scene
  105012. * @param x defines the x coordinate of the origin (on-screen)
  105013. * @param y defines the y coordinate of the origin (on-screen)
  105014. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105015. * @param result defines the ray where to store the picking ray
  105016. * @param camera defines the camera to use for the picking
  105017. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105018. * @returns the current scene
  105019. */
  105020. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105021. /**
  105022. * Creates a ray that can be used to pick in the scene
  105023. * @param x defines the x coordinate of the origin (on-screen)
  105024. * @param y defines the y coordinate of the origin (on-screen)
  105025. * @param camera defines the camera to use for the picking
  105026. * @returns a Ray
  105027. */
  105028. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105029. /**
  105030. * Creates a ray that can be used to pick in the scene
  105031. * @param x defines the x coordinate of the origin (on-screen)
  105032. * @param y defines the y coordinate of the origin (on-screen)
  105033. * @param result defines the ray where to store the picking ray
  105034. * @param camera defines the camera to use for the picking
  105035. * @returns the current scene
  105036. */
  105037. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105038. /** Launch a ray to try to pick a mesh in the scene
  105039. * @param x position on screen
  105040. * @param y position on screen
  105041. * @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
  105042. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105043. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105044. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105045. * @returns a PickingInfo
  105046. */
  105047. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105048. /** Use the given ray to pick a mesh in the scene
  105049. * @param ray The ray to use to pick meshes
  105050. * @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
  105051. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105053. * @returns a PickingInfo
  105054. */
  105055. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105056. /**
  105057. * Launch a ray to try to pick a mesh in the scene
  105058. * @param x X position on screen
  105059. * @param y Y position on screen
  105060. * @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
  105061. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105062. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105063. * @returns an array of PickingInfo
  105064. */
  105065. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105066. /**
  105067. * Launch a ray to try to pick a mesh in the scene
  105068. * @param ray Ray to use
  105069. * @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
  105070. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105071. * @returns an array of PickingInfo
  105072. */
  105073. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105074. /**
  105075. * Force the value of meshUnderPointer
  105076. * @param mesh defines the mesh to use
  105077. */
  105078. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105079. /**
  105080. * Gets the mesh under the pointer
  105081. * @returns a Mesh or null if no mesh is under the pointer
  105082. */
  105083. getPointerOverMesh(): Nullable<AbstractMesh>;
  105084. /** @hidden */
  105085. _rebuildGeometries(): void;
  105086. /** @hidden */
  105087. _rebuildTextures(): void;
  105088. private _getByTags;
  105089. /**
  105090. * Get a list of meshes by tags
  105091. * @param tagsQuery defines the tags query to use
  105092. * @param forEach defines a predicate used to filter results
  105093. * @returns an array of Mesh
  105094. */
  105095. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105096. /**
  105097. * Get a list of cameras by tags
  105098. * @param tagsQuery defines the tags query to use
  105099. * @param forEach defines a predicate used to filter results
  105100. * @returns an array of Camera
  105101. */
  105102. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105103. /**
  105104. * Get a list of lights by tags
  105105. * @param tagsQuery defines the tags query to use
  105106. * @param forEach defines a predicate used to filter results
  105107. * @returns an array of Light
  105108. */
  105109. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105110. /**
  105111. * Get a list of materials by tags
  105112. * @param tagsQuery defines the tags query to use
  105113. * @param forEach defines a predicate used to filter results
  105114. * @returns an array of Material
  105115. */
  105116. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105117. /**
  105118. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105119. * This allowed control for front to back rendering or reversly depending of the special needs.
  105120. *
  105121. * @param renderingGroupId The rendering group id corresponding to its index
  105122. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105123. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105124. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105125. */
  105126. 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;
  105127. /**
  105128. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105129. *
  105130. * @param renderingGroupId The rendering group id corresponding to its index
  105131. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105132. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105133. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105134. */
  105135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105136. /**
  105137. * Gets the current auto clear configuration for one rendering group of the rendering
  105138. * manager.
  105139. * @param index the rendering group index to get the information for
  105140. * @returns The auto clear setup for the requested rendering group
  105141. */
  105142. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105143. private _blockMaterialDirtyMechanism;
  105144. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105145. blockMaterialDirtyMechanism: boolean;
  105146. /**
  105147. * Will flag all materials as dirty to trigger new shader compilation
  105148. * @param flag defines the flag used to specify which material part must be marked as dirty
  105149. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105150. */
  105151. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105152. /** @hidden */
  105153. _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;
  105154. /** @hidden */
  105155. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105156. /** @hidden */
  105157. _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;
  105158. /** @hidden */
  105159. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105160. /** @hidden */
  105161. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105162. /** @hidden */
  105163. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105164. }
  105165. }
  105166. declare module BABYLON {
  105167. /**
  105168. * Set of assets to keep when moving a scene into an asset container.
  105169. */
  105170. export class KeepAssets extends AbstractScene {
  105171. }
  105172. /**
  105173. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105174. */
  105175. export class InstantiatedEntries {
  105176. /**
  105177. * List of new root nodes (eg. nodes with no parent)
  105178. */
  105179. rootNodes: TransformNode[];
  105180. /**
  105181. * List of new skeletons
  105182. */
  105183. skeletons: Skeleton[];
  105184. /**
  105185. * List of new animation groups
  105186. */
  105187. animationGroups: AnimationGroup[];
  105188. }
  105189. /**
  105190. * Container with a set of assets that can be added or removed from a scene.
  105191. */
  105192. export class AssetContainer extends AbstractScene {
  105193. /**
  105194. * The scene the AssetContainer belongs to.
  105195. */
  105196. scene: Scene;
  105197. /**
  105198. * Instantiates an AssetContainer.
  105199. * @param scene The scene the AssetContainer belongs to.
  105200. */
  105201. constructor(scene: Scene);
  105202. /**
  105203. * Instantiate or clone all meshes and add the new ones to the scene.
  105204. * Skeletons and animation groups will all be cloned
  105205. * @param nameFunction defines an optional function used to get new names for clones
  105206. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105207. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105208. */
  105209. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105210. /**
  105211. * Adds all the assets from the container to the scene.
  105212. */
  105213. addAllToScene(): void;
  105214. /**
  105215. * Removes all the assets in the container from the scene
  105216. */
  105217. removeAllFromScene(): void;
  105218. /**
  105219. * Disposes all the assets in the container
  105220. */
  105221. dispose(): void;
  105222. private _moveAssets;
  105223. /**
  105224. * Removes all the assets contained in the scene and adds them to the container.
  105225. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105226. */
  105227. moveAllFromScene(keepAssets?: KeepAssets): void;
  105228. /**
  105229. * 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.
  105230. * @returns the root mesh
  105231. */
  105232. createRootMesh(): Mesh;
  105233. }
  105234. }
  105235. declare module BABYLON {
  105236. /**
  105237. * Defines how the parser contract is defined.
  105238. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105239. */
  105240. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105241. /**
  105242. * Defines how the individual parser contract is defined.
  105243. * These parser can parse an individual asset
  105244. */
  105245. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105246. /**
  105247. * Base class of the scene acting as a container for the different elements composing a scene.
  105248. * This class is dynamically extended by the different components of the scene increasing
  105249. * flexibility and reducing coupling
  105250. */
  105251. export abstract class AbstractScene {
  105252. /**
  105253. * Stores the list of available parsers in the application.
  105254. */
  105255. private static _BabylonFileParsers;
  105256. /**
  105257. * Stores the list of available individual parsers in the application.
  105258. */
  105259. private static _IndividualBabylonFileParsers;
  105260. /**
  105261. * Adds a parser in the list of available ones
  105262. * @param name Defines the name of the parser
  105263. * @param parser Defines the parser to add
  105264. */
  105265. static AddParser(name: string, parser: BabylonFileParser): void;
  105266. /**
  105267. * Gets a general parser from the list of avaialble ones
  105268. * @param name Defines the name of the parser
  105269. * @returns the requested parser or null
  105270. */
  105271. static GetParser(name: string): Nullable<BabylonFileParser>;
  105272. /**
  105273. * Adds n individual parser in the list of available ones
  105274. * @param name Defines the name of the parser
  105275. * @param parser Defines the parser to add
  105276. */
  105277. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105278. /**
  105279. * Gets an individual parser from the list of avaialble ones
  105280. * @param name Defines the name of the parser
  105281. * @returns the requested parser or null
  105282. */
  105283. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105284. /**
  105285. * Parser json data and populate both a scene and its associated container object
  105286. * @param jsonData Defines the data to parse
  105287. * @param scene Defines the scene to parse the data for
  105288. * @param container Defines the container attached to the parsing sequence
  105289. * @param rootUrl Defines the root url of the data
  105290. */
  105291. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105292. /**
  105293. * Gets the list of root nodes (ie. nodes with no parent)
  105294. */
  105295. rootNodes: Node[];
  105296. /** All of the cameras added to this scene
  105297. * @see http://doc.babylonjs.com/babylon101/cameras
  105298. */
  105299. cameras: Camera[];
  105300. /**
  105301. * All of the lights added to this scene
  105302. * @see http://doc.babylonjs.com/babylon101/lights
  105303. */
  105304. lights: Light[];
  105305. /**
  105306. * All of the (abstract) meshes added to this scene
  105307. */
  105308. meshes: AbstractMesh[];
  105309. /**
  105310. * The list of skeletons added to the scene
  105311. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105312. */
  105313. skeletons: Skeleton[];
  105314. /**
  105315. * All of the particle systems added to this scene
  105316. * @see http://doc.babylonjs.com/babylon101/particles
  105317. */
  105318. particleSystems: IParticleSystem[];
  105319. /**
  105320. * Gets a list of Animations associated with the scene
  105321. */
  105322. animations: Animation[];
  105323. /**
  105324. * All of the animation groups added to this scene
  105325. * @see http://doc.babylonjs.com/how_to/group
  105326. */
  105327. animationGroups: AnimationGroup[];
  105328. /**
  105329. * All of the multi-materials added to this scene
  105330. * @see http://doc.babylonjs.com/how_to/multi_materials
  105331. */
  105332. multiMaterials: MultiMaterial[];
  105333. /**
  105334. * All of the materials added to this scene
  105335. * In the context of a Scene, it is not supposed to be modified manually.
  105336. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105337. * Note also that the order of the Material within the array is not significant and might change.
  105338. * @see http://doc.babylonjs.com/babylon101/materials
  105339. */
  105340. materials: Material[];
  105341. /**
  105342. * The list of morph target managers added to the scene
  105343. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105344. */
  105345. morphTargetManagers: MorphTargetManager[];
  105346. /**
  105347. * The list of geometries used in the scene.
  105348. */
  105349. geometries: Geometry[];
  105350. /**
  105351. * All of the tranform nodes added to this scene
  105352. * In the context of a Scene, it is not supposed to be modified manually.
  105353. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105354. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105355. * @see http://doc.babylonjs.com/how_to/transformnode
  105356. */
  105357. transformNodes: TransformNode[];
  105358. /**
  105359. * ActionManagers available on the scene.
  105360. */
  105361. actionManagers: AbstractActionManager[];
  105362. /**
  105363. * Textures to keep.
  105364. */
  105365. textures: BaseTexture[];
  105366. /**
  105367. * Environment texture for the scene
  105368. */
  105369. environmentTexture: Nullable<BaseTexture>;
  105370. }
  105371. }
  105372. declare module BABYLON {
  105373. /**
  105374. * Interface used to define options for Sound class
  105375. */
  105376. export interface ISoundOptions {
  105377. /**
  105378. * Does the sound autoplay once loaded.
  105379. */
  105380. autoplay?: boolean;
  105381. /**
  105382. * Does the sound loop after it finishes playing once.
  105383. */
  105384. loop?: boolean;
  105385. /**
  105386. * Sound's volume
  105387. */
  105388. volume?: number;
  105389. /**
  105390. * Is it a spatial sound?
  105391. */
  105392. spatialSound?: boolean;
  105393. /**
  105394. * Maximum distance to hear that sound
  105395. */
  105396. maxDistance?: number;
  105397. /**
  105398. * Uses user defined attenuation function
  105399. */
  105400. useCustomAttenuation?: boolean;
  105401. /**
  105402. * Define the roll off factor of spatial sounds.
  105403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105404. */
  105405. rolloffFactor?: number;
  105406. /**
  105407. * Define the reference distance the sound should be heard perfectly.
  105408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105409. */
  105410. refDistance?: number;
  105411. /**
  105412. * Define the distance attenuation model the sound will follow.
  105413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105414. */
  105415. distanceModel?: string;
  105416. /**
  105417. * Defines the playback speed (1 by default)
  105418. */
  105419. playbackRate?: number;
  105420. /**
  105421. * Defines if the sound is from a streaming source
  105422. */
  105423. streaming?: boolean;
  105424. /**
  105425. * Defines an optional length (in seconds) inside the sound file
  105426. */
  105427. length?: number;
  105428. /**
  105429. * Defines an optional offset (in seconds) inside the sound file
  105430. */
  105431. offset?: number;
  105432. /**
  105433. * If true, URLs will not be required to state the audio file codec to use.
  105434. */
  105435. skipCodecCheck?: boolean;
  105436. }
  105437. /**
  105438. * Defines a sound that can be played in the application.
  105439. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105441. */
  105442. export class Sound {
  105443. /**
  105444. * The name of the sound in the scene.
  105445. */
  105446. name: string;
  105447. /**
  105448. * Does the sound autoplay once loaded.
  105449. */
  105450. autoplay: boolean;
  105451. /**
  105452. * Does the sound loop after it finishes playing once.
  105453. */
  105454. loop: boolean;
  105455. /**
  105456. * Does the sound use a custom attenuation curve to simulate the falloff
  105457. * happening when the source gets further away from the camera.
  105458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105459. */
  105460. useCustomAttenuation: boolean;
  105461. /**
  105462. * The sound track id this sound belongs to.
  105463. */
  105464. soundTrackId: number;
  105465. /**
  105466. * Is this sound currently played.
  105467. */
  105468. isPlaying: boolean;
  105469. /**
  105470. * Is this sound currently paused.
  105471. */
  105472. isPaused: boolean;
  105473. /**
  105474. * Does this sound enables spatial sound.
  105475. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105476. */
  105477. spatialSound: boolean;
  105478. /**
  105479. * Define the reference distance the sound should be heard perfectly.
  105480. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105481. */
  105482. refDistance: number;
  105483. /**
  105484. * Define the roll off factor of spatial sounds.
  105485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105486. */
  105487. rolloffFactor: number;
  105488. /**
  105489. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  105490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105491. */
  105492. maxDistance: number;
  105493. /**
  105494. * Define the distance attenuation model the sound will follow.
  105495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105496. */
  105497. distanceModel: string;
  105498. /**
  105499. * @hidden
  105500. * Back Compat
  105501. **/
  105502. onended: () => any;
  105503. /**
  105504. * Observable event when the current playing sound finishes.
  105505. */
  105506. onEndedObservable: Observable<Sound>;
  105507. private _panningModel;
  105508. private _playbackRate;
  105509. private _streaming;
  105510. private _startTime;
  105511. private _startOffset;
  105512. private _position;
  105513. /** @hidden */
  105514. _positionInEmitterSpace: boolean;
  105515. private _localDirection;
  105516. private _volume;
  105517. private _isReadyToPlay;
  105518. private _isDirectional;
  105519. private _readyToPlayCallback;
  105520. private _audioBuffer;
  105521. private _soundSource;
  105522. private _streamingSource;
  105523. private _soundPanner;
  105524. private _soundGain;
  105525. private _inputAudioNode;
  105526. private _outputAudioNode;
  105527. private _coneInnerAngle;
  105528. private _coneOuterAngle;
  105529. private _coneOuterGain;
  105530. private _scene;
  105531. private _connectedTransformNode;
  105532. private _customAttenuationFunction;
  105533. private _registerFunc;
  105534. private _isOutputConnected;
  105535. private _htmlAudioElement;
  105536. private _urlType;
  105537. private _length?;
  105538. private _offset?;
  105539. /** @hidden */
  105540. static _SceneComponentInitialization: (scene: Scene) => void;
  105541. /**
  105542. * Create a sound and attach it to a scene
  105543. * @param name Name of your sound
  105544. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  105545. * @param scene defines the scene the sound belongs to
  105546. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  105547. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  105548. */
  105549. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  105550. /**
  105551. * Release the sound and its associated resources
  105552. */
  105553. dispose(): void;
  105554. /**
  105555. * Gets if the sounds is ready to be played or not.
  105556. * @returns true if ready, otherwise false
  105557. */
  105558. isReady(): boolean;
  105559. private _soundLoaded;
  105560. /**
  105561. * Sets the data of the sound from an audiobuffer
  105562. * @param audioBuffer The audioBuffer containing the data
  105563. */
  105564. setAudioBuffer(audioBuffer: AudioBuffer): void;
  105565. /**
  105566. * Updates the current sounds options such as maxdistance, loop...
  105567. * @param options A JSON object containing values named as the object properties
  105568. */
  105569. updateOptions(options: ISoundOptions): void;
  105570. private _createSpatialParameters;
  105571. private _updateSpatialParameters;
  105572. /**
  105573. * Switch the panning model to HRTF:
  105574. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105576. */
  105577. switchPanningModelToHRTF(): void;
  105578. /**
  105579. * Switch the panning model to Equal Power:
  105580. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105582. */
  105583. switchPanningModelToEqualPower(): void;
  105584. private _switchPanningModel;
  105585. /**
  105586. * Connect this sound to a sound track audio node like gain...
  105587. * @param soundTrackAudioNode the sound track audio node to connect to
  105588. */
  105589. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  105590. /**
  105591. * Transform this sound into a directional source
  105592. * @param coneInnerAngle Size of the inner cone in degree
  105593. * @param coneOuterAngle Size of the outer cone in degree
  105594. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  105595. */
  105596. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  105597. /**
  105598. * Gets or sets the inner angle for the directional cone.
  105599. */
  105600. /**
  105601. * Gets or sets the inner angle for the directional cone.
  105602. */
  105603. directionalConeInnerAngle: number;
  105604. /**
  105605. * Gets or sets the outer angle for the directional cone.
  105606. */
  105607. /**
  105608. * Gets or sets the outer angle for the directional cone.
  105609. */
  105610. directionalConeOuterAngle: number;
  105611. /**
  105612. * Sets the position of the emitter if spatial sound is enabled
  105613. * @param newPosition Defines the new posisiton
  105614. */
  105615. setPosition(newPosition: Vector3): void;
  105616. /**
  105617. * Sets the local direction of the emitter if spatial sound is enabled
  105618. * @param newLocalDirection Defines the new local direction
  105619. */
  105620. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  105621. private _updateDirection;
  105622. /** @hidden */
  105623. updateDistanceFromListener(): void;
  105624. /**
  105625. * Sets a new custom attenuation function for the sound.
  105626. * @param callback Defines the function used for the attenuation
  105627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  105628. */
  105629. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  105630. /**
  105631. * Play the sound
  105632. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  105633. * @param offset (optional) Start the sound at a specific time in seconds
  105634. * @param length (optional) Sound duration (in seconds)
  105635. */
  105636. play(time?: number, offset?: number, length?: number): void;
  105637. private _onended;
  105638. /**
  105639. * Stop the sound
  105640. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  105641. */
  105642. stop(time?: number): void;
  105643. /**
  105644. * Put the sound in pause
  105645. */
  105646. pause(): void;
  105647. /**
  105648. * Sets a dedicated volume for this sounds
  105649. * @param newVolume Define the new volume of the sound
  105650. * @param time Define time for gradual change to new volume
  105651. */
  105652. setVolume(newVolume: number, time?: number): void;
  105653. /**
  105654. * Set the sound play back rate
  105655. * @param newPlaybackRate Define the playback rate the sound should be played at
  105656. */
  105657. setPlaybackRate(newPlaybackRate: number): void;
  105658. /**
  105659. * Gets the volume of the sound.
  105660. * @returns the volume of the sound
  105661. */
  105662. getVolume(): number;
  105663. /**
  105664. * Attach the sound to a dedicated mesh
  105665. * @param transformNode The transform node to connect the sound with
  105666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105667. */
  105668. attachToMesh(transformNode: TransformNode): void;
  105669. /**
  105670. * Detach the sound from the previously attached mesh
  105671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  105672. */
  105673. detachFromMesh(): void;
  105674. private _onRegisterAfterWorldMatrixUpdate;
  105675. /**
  105676. * Clone the current sound in the scene.
  105677. * @returns the new sound clone
  105678. */
  105679. clone(): Nullable<Sound>;
  105680. /**
  105681. * Gets the current underlying audio buffer containing the data
  105682. * @returns the audio buffer
  105683. */
  105684. getAudioBuffer(): Nullable<AudioBuffer>;
  105685. /**
  105686. * Serializes the Sound in a JSON representation
  105687. * @returns the JSON representation of the sound
  105688. */
  105689. serialize(): any;
  105690. /**
  105691. * Parse a JSON representation of a sound to innstantiate in a given scene
  105692. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  105693. * @param scene Define the scene the new parsed sound should be created in
  105694. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  105695. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  105696. * @returns the newly parsed sound
  105697. */
  105698. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  105699. }
  105700. }
  105701. declare module BABYLON {
  105702. /**
  105703. * This defines an action helpful to play a defined sound on a triggered action.
  105704. */
  105705. export class PlaySoundAction extends Action {
  105706. private _sound;
  105707. /**
  105708. * Instantiate the action
  105709. * @param triggerOptions defines the trigger options
  105710. * @param sound defines the sound to play
  105711. * @param condition defines the trigger related conditions
  105712. */
  105713. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105714. /** @hidden */
  105715. _prepare(): void;
  105716. /**
  105717. * Execute the action and play the sound.
  105718. */
  105719. execute(): void;
  105720. /**
  105721. * Serializes the actions and its related information.
  105722. * @param parent defines the object to serialize in
  105723. * @returns the serialized object
  105724. */
  105725. serialize(parent: any): any;
  105726. }
  105727. /**
  105728. * This defines an action helpful to stop a defined sound on a triggered action.
  105729. */
  105730. export class StopSoundAction extends Action {
  105731. private _sound;
  105732. /**
  105733. * Instantiate the action
  105734. * @param triggerOptions defines the trigger options
  105735. * @param sound defines the sound to stop
  105736. * @param condition defines the trigger related conditions
  105737. */
  105738. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  105739. /** @hidden */
  105740. _prepare(): void;
  105741. /**
  105742. * Execute the action and stop the sound.
  105743. */
  105744. execute(): void;
  105745. /**
  105746. * Serializes the actions and its related information.
  105747. * @param parent defines the object to serialize in
  105748. * @returns the serialized object
  105749. */
  105750. serialize(parent: any): any;
  105751. }
  105752. }
  105753. declare module BABYLON {
  105754. /**
  105755. * This defines an action responsible to change the value of a property
  105756. * by interpolating between its current value and the newly set one once triggered.
  105757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  105758. */
  105759. export class InterpolateValueAction extends Action {
  105760. /**
  105761. * Defines the path of the property where the value should be interpolated
  105762. */
  105763. propertyPath: string;
  105764. /**
  105765. * Defines the target value at the end of the interpolation.
  105766. */
  105767. value: any;
  105768. /**
  105769. * Defines the time it will take for the property to interpolate to the value.
  105770. */
  105771. duration: number;
  105772. /**
  105773. * Defines if the other scene animations should be stopped when the action has been triggered
  105774. */
  105775. stopOtherAnimations?: boolean;
  105776. /**
  105777. * Defines a callback raised once the interpolation animation has been done.
  105778. */
  105779. onInterpolationDone?: () => void;
  105780. /**
  105781. * Observable triggered once the interpolation animation has been done.
  105782. */
  105783. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  105784. private _target;
  105785. private _effectiveTarget;
  105786. private _property;
  105787. /**
  105788. * Instantiate the action
  105789. * @param triggerOptions defines the trigger options
  105790. * @param target defines the object containing the value to interpolate
  105791. * @param propertyPath defines the path to the property in the target object
  105792. * @param value defines the target value at the end of the interpolation
  105793. * @param duration deines the time it will take for the property to interpolate to the value.
  105794. * @param condition defines the trigger related conditions
  105795. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  105796. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  105797. */
  105798. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  105799. /** @hidden */
  105800. _prepare(): void;
  105801. /**
  105802. * Execute the action starts the value interpolation.
  105803. */
  105804. execute(): void;
  105805. /**
  105806. * Serializes the actions and its related information.
  105807. * @param parent defines the object to serialize in
  105808. * @returns the serialized object
  105809. */
  105810. serialize(parent: any): any;
  105811. }
  105812. }
  105813. declare module BABYLON {
  105814. /**
  105815. * Options allowed during the creation of a sound track.
  105816. */
  105817. export interface ISoundTrackOptions {
  105818. /**
  105819. * The volume the sound track should take during creation
  105820. */
  105821. volume?: number;
  105822. /**
  105823. * Define if the sound track is the main sound track of the scene
  105824. */
  105825. mainTrack?: boolean;
  105826. }
  105827. /**
  105828. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  105829. * It will be also used in a future release to apply effects on a specific track.
  105830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105831. */
  105832. export class SoundTrack {
  105833. /**
  105834. * The unique identifier of the sound track in the scene.
  105835. */
  105836. id: number;
  105837. /**
  105838. * The list of sounds included in the sound track.
  105839. */
  105840. soundCollection: Array<Sound>;
  105841. private _outputAudioNode;
  105842. private _scene;
  105843. private _connectedAnalyser;
  105844. private _options;
  105845. private _isInitialized;
  105846. /**
  105847. * Creates a new sound track.
  105848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  105849. * @param scene Define the scene the sound track belongs to
  105850. * @param options
  105851. */
  105852. constructor(scene: Scene, options?: ISoundTrackOptions);
  105853. private _initializeSoundTrackAudioGraph;
  105854. /**
  105855. * Release the sound track and its associated resources
  105856. */
  105857. dispose(): void;
  105858. /**
  105859. * Adds a sound to this sound track
  105860. * @param sound define the cound to add
  105861. * @ignoreNaming
  105862. */
  105863. AddSound(sound: Sound): void;
  105864. /**
  105865. * Removes a sound to this sound track
  105866. * @param sound define the cound to remove
  105867. * @ignoreNaming
  105868. */
  105869. RemoveSound(sound: Sound): void;
  105870. /**
  105871. * Set a global volume for the full sound track.
  105872. * @param newVolume Define the new volume of the sound track
  105873. */
  105874. setVolume(newVolume: number): void;
  105875. /**
  105876. * Switch the panning model to HRTF:
  105877. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  105878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105879. */
  105880. switchPanningModelToHRTF(): void;
  105881. /**
  105882. * Switch the panning model to Equal Power:
  105883. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  105884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105885. */
  105886. switchPanningModelToEqualPower(): void;
  105887. /**
  105888. * Connect the sound track to an audio analyser allowing some amazing
  105889. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105891. * @param analyser The analyser to connect to the engine
  105892. */
  105893. connectToAnalyser(analyser: Analyser): void;
  105894. }
  105895. }
  105896. declare module BABYLON {
  105897. interface AbstractScene {
  105898. /**
  105899. * The list of sounds used in the scene.
  105900. */
  105901. sounds: Nullable<Array<Sound>>;
  105902. }
  105903. interface Scene {
  105904. /**
  105905. * @hidden
  105906. * Backing field
  105907. */
  105908. _mainSoundTrack: SoundTrack;
  105909. /**
  105910. * The main sound track played by the scene.
  105911. * It cotains your primary collection of sounds.
  105912. */
  105913. mainSoundTrack: SoundTrack;
  105914. /**
  105915. * The list of sound tracks added to the scene
  105916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105917. */
  105918. soundTracks: Nullable<Array<SoundTrack>>;
  105919. /**
  105920. * Gets a sound using a given name
  105921. * @param name defines the name to search for
  105922. * @return the found sound or null if not found at all.
  105923. */
  105924. getSoundByName(name: string): Nullable<Sound>;
  105925. /**
  105926. * Gets or sets if audio support is enabled
  105927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105928. */
  105929. audioEnabled: boolean;
  105930. /**
  105931. * Gets or sets if audio will be output to headphones
  105932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105933. */
  105934. headphone: boolean;
  105935. /**
  105936. * Gets or sets custom audio listener position provider
  105937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105938. */
  105939. audioListenerPositionProvider: Nullable<() => Vector3>;
  105940. /**
  105941. * Gets or sets a refresh rate when using 3D audio positioning
  105942. */
  105943. audioPositioningRefreshRate: number;
  105944. }
  105945. /**
  105946. * Defines the sound scene component responsible to manage any sounds
  105947. * in a given scene.
  105948. */
  105949. export class AudioSceneComponent implements ISceneSerializableComponent {
  105950. /**
  105951. * The component name helpfull to identify the component in the list of scene components.
  105952. */
  105953. readonly name: string;
  105954. /**
  105955. * The scene the component belongs to.
  105956. */
  105957. scene: Scene;
  105958. private _audioEnabled;
  105959. /**
  105960. * Gets whether audio is enabled or not.
  105961. * Please use related enable/disable method to switch state.
  105962. */
  105963. readonly audioEnabled: boolean;
  105964. private _headphone;
  105965. /**
  105966. * Gets whether audio is outputing to headphone or not.
  105967. * Please use the according Switch methods to change output.
  105968. */
  105969. readonly headphone: boolean;
  105970. /**
  105971. * Gets or sets a refresh rate when using 3D audio positioning
  105972. */
  105973. audioPositioningRefreshRate: number;
  105974. private _audioListenerPositionProvider;
  105975. /**
  105976. * Gets the current audio listener position provider
  105977. */
  105978. /**
  105979. * Sets a custom listener position for all sounds in the scene
  105980. * By default, this is the position of the first active camera
  105981. */
  105982. audioListenerPositionProvider: Nullable<() => Vector3>;
  105983. /**
  105984. * Creates a new instance of the component for the given scene
  105985. * @param scene Defines the scene to register the component in
  105986. */
  105987. constructor(scene: Scene);
  105988. /**
  105989. * Registers the component in a given scene
  105990. */
  105991. register(): void;
  105992. /**
  105993. * Rebuilds the elements related to this component in case of
  105994. * context lost for instance.
  105995. */
  105996. rebuild(): void;
  105997. /**
  105998. * Serializes the component data to the specified json object
  105999. * @param serializationObject The object to serialize to
  106000. */
  106001. serialize(serializationObject: any): void;
  106002. /**
  106003. * Adds all the elements from the container to the scene
  106004. * @param container the container holding the elements
  106005. */
  106006. addFromContainer(container: AbstractScene): void;
  106007. /**
  106008. * Removes all the elements in the container from the scene
  106009. * @param container contains the elements to remove
  106010. * @param dispose if the removed element should be disposed (default: false)
  106011. */
  106012. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106013. /**
  106014. * Disposes the component and the associated ressources.
  106015. */
  106016. dispose(): void;
  106017. /**
  106018. * Disables audio in the associated scene.
  106019. */
  106020. disableAudio(): void;
  106021. /**
  106022. * Enables audio in the associated scene.
  106023. */
  106024. enableAudio(): void;
  106025. /**
  106026. * Switch audio to headphone output.
  106027. */
  106028. switchAudioModeForHeadphones(): void;
  106029. /**
  106030. * Switch audio to normal speakers.
  106031. */
  106032. switchAudioModeForNormalSpeakers(): void;
  106033. private _cachedCameraDirection;
  106034. private _cachedCameraPosition;
  106035. private _lastCheck;
  106036. private _afterRender;
  106037. }
  106038. }
  106039. declare module BABYLON {
  106040. /**
  106041. * Wraps one or more Sound objects and selects one with random weight for playback.
  106042. */
  106043. export class WeightedSound {
  106044. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106045. loop: boolean;
  106046. private _coneInnerAngle;
  106047. private _coneOuterAngle;
  106048. private _volume;
  106049. /** A Sound is currently playing. */
  106050. isPlaying: boolean;
  106051. /** A Sound is currently paused. */
  106052. isPaused: boolean;
  106053. private _sounds;
  106054. private _weights;
  106055. private _currentIndex?;
  106056. /**
  106057. * Creates a new WeightedSound from the list of sounds given.
  106058. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106059. * @param sounds Array of Sounds that will be selected from.
  106060. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106061. */
  106062. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106063. /**
  106064. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106065. */
  106066. /**
  106067. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106068. */
  106069. directionalConeInnerAngle: number;
  106070. /**
  106071. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106072. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106073. */
  106074. /**
  106075. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106076. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106077. */
  106078. directionalConeOuterAngle: number;
  106079. /**
  106080. * Playback volume.
  106081. */
  106082. /**
  106083. * Playback volume.
  106084. */
  106085. volume: number;
  106086. private _onended;
  106087. /**
  106088. * Suspend playback
  106089. */
  106090. pause(): void;
  106091. /**
  106092. * Stop playback
  106093. */
  106094. stop(): void;
  106095. /**
  106096. * Start playback.
  106097. * @param startOffset Position the clip head at a specific time in seconds.
  106098. */
  106099. play(startOffset?: number): void;
  106100. }
  106101. }
  106102. declare module BABYLON {
  106103. /**
  106104. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106106. */
  106107. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106108. /**
  106109. * Gets the name of the behavior.
  106110. */
  106111. readonly name: string;
  106112. /**
  106113. * The easing function used by animations
  106114. */
  106115. static EasingFunction: BackEase;
  106116. /**
  106117. * The easing mode used by animations
  106118. */
  106119. static EasingMode: number;
  106120. /**
  106121. * The duration of the animation, in milliseconds
  106122. */
  106123. transitionDuration: number;
  106124. /**
  106125. * Length of the distance animated by the transition when lower radius is reached
  106126. */
  106127. lowerRadiusTransitionRange: number;
  106128. /**
  106129. * Length of the distance animated by the transition when upper radius is reached
  106130. */
  106131. upperRadiusTransitionRange: number;
  106132. private _autoTransitionRange;
  106133. /**
  106134. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106135. */
  106136. /**
  106137. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106138. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106139. */
  106140. autoTransitionRange: boolean;
  106141. private _attachedCamera;
  106142. private _onAfterCheckInputsObserver;
  106143. private _onMeshTargetChangedObserver;
  106144. /**
  106145. * Initializes the behavior.
  106146. */
  106147. init(): void;
  106148. /**
  106149. * Attaches the behavior to its arc rotate camera.
  106150. * @param camera Defines the camera to attach the behavior to
  106151. */
  106152. attach(camera: ArcRotateCamera): void;
  106153. /**
  106154. * Detaches the behavior from its current arc rotate camera.
  106155. */
  106156. detach(): void;
  106157. private _radiusIsAnimating;
  106158. private _radiusBounceTransition;
  106159. private _animatables;
  106160. private _cachedWheelPrecision;
  106161. /**
  106162. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106163. * @param radiusLimit The limit to check against.
  106164. * @return Bool to indicate if at limit.
  106165. */
  106166. private _isRadiusAtLimit;
  106167. /**
  106168. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106169. * @param radiusDelta The delta by which to animate to. Can be negative.
  106170. */
  106171. private _applyBoundRadiusAnimation;
  106172. /**
  106173. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106174. */
  106175. protected _clearAnimationLocks(): void;
  106176. /**
  106177. * Stops and removes all animations that have been applied to the camera
  106178. */
  106179. stopAllAnimations(): void;
  106180. }
  106181. }
  106182. declare module BABYLON {
  106183. /**
  106184. * 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.
  106185. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106186. */
  106187. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106188. /**
  106189. * Gets the name of the behavior.
  106190. */
  106191. readonly name: string;
  106192. private _mode;
  106193. private _radiusScale;
  106194. private _positionScale;
  106195. private _defaultElevation;
  106196. private _elevationReturnTime;
  106197. private _elevationReturnWaitTime;
  106198. private _zoomStopsAnimation;
  106199. private _framingTime;
  106200. /**
  106201. * The easing function used by animations
  106202. */
  106203. static EasingFunction: ExponentialEase;
  106204. /**
  106205. * The easing mode used by animations
  106206. */
  106207. static EasingMode: number;
  106208. /**
  106209. * Sets the current mode used by the behavior
  106210. */
  106211. /**
  106212. * Gets current mode used by the behavior.
  106213. */
  106214. mode: number;
  106215. /**
  106216. * Sets the scale applied to the radius (1 by default)
  106217. */
  106218. /**
  106219. * Gets the scale applied to the radius
  106220. */
  106221. radiusScale: number;
  106222. /**
  106223. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106224. */
  106225. /**
  106226. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106227. */
  106228. positionScale: number;
  106229. /**
  106230. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106231. * behaviour is triggered, in radians.
  106232. */
  106233. /**
  106234. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106235. * behaviour is triggered, in radians.
  106236. */
  106237. defaultElevation: number;
  106238. /**
  106239. * Sets the time (in milliseconds) taken to return to the default beta position.
  106240. * Negative value indicates camera should not return to default.
  106241. */
  106242. /**
  106243. * Gets the time (in milliseconds) taken to return to the default beta position.
  106244. * Negative value indicates camera should not return to default.
  106245. */
  106246. elevationReturnTime: number;
  106247. /**
  106248. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106249. */
  106250. /**
  106251. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106252. */
  106253. elevationReturnWaitTime: number;
  106254. /**
  106255. * Sets the flag that indicates if user zooming should stop animation.
  106256. */
  106257. /**
  106258. * Gets the flag that indicates if user zooming should stop animation.
  106259. */
  106260. zoomStopsAnimation: boolean;
  106261. /**
  106262. * Sets the transition time when framing the mesh, in milliseconds
  106263. */
  106264. /**
  106265. * Gets the transition time when framing the mesh, in milliseconds
  106266. */
  106267. framingTime: number;
  106268. /**
  106269. * Define if the behavior should automatically change the configured
  106270. * camera limits and sensibilities.
  106271. */
  106272. autoCorrectCameraLimitsAndSensibility: boolean;
  106273. private _onPrePointerObservableObserver;
  106274. private _onAfterCheckInputsObserver;
  106275. private _onMeshTargetChangedObserver;
  106276. private _attachedCamera;
  106277. private _isPointerDown;
  106278. private _lastInteractionTime;
  106279. /**
  106280. * Initializes the behavior.
  106281. */
  106282. init(): void;
  106283. /**
  106284. * Attaches the behavior to its arc rotate camera.
  106285. * @param camera Defines the camera to attach the behavior to
  106286. */
  106287. attach(camera: ArcRotateCamera): void;
  106288. /**
  106289. * Detaches the behavior from its current arc rotate camera.
  106290. */
  106291. detach(): void;
  106292. private _animatables;
  106293. private _betaIsAnimating;
  106294. private _betaTransition;
  106295. private _radiusTransition;
  106296. private _vectorTransition;
  106297. /**
  106298. * Targets the given mesh and updates zoom level accordingly.
  106299. * @param mesh The mesh to target.
  106300. * @param radius Optional. If a cached radius position already exists, overrides default.
  106301. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106302. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106303. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106304. */
  106305. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106306. /**
  106307. * Targets the given mesh with its children and updates zoom level accordingly.
  106308. * @param mesh The mesh to target.
  106309. * @param radius Optional. If a cached radius position already exists, overrides default.
  106310. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106311. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106312. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106313. */
  106314. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106315. /**
  106316. * Targets the given meshes with their children and updates zoom level accordingly.
  106317. * @param meshes The mesh to target.
  106318. * @param radius Optional. If a cached radius position already exists, overrides default.
  106319. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106320. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106321. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106322. */
  106323. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106324. /**
  106325. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106326. * @param minimumWorld Determines the smaller position of the bounding box extend
  106327. * @param maximumWorld Determines the bigger position of the bounding box extend
  106328. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106329. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106330. */
  106331. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106332. /**
  106333. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106334. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106335. * frustum width.
  106336. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106337. * to fully enclose the mesh in the viewing frustum.
  106338. */
  106339. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106340. /**
  106341. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106342. * is automatically returned to its default position (expected to be above ground plane).
  106343. */
  106344. private _maintainCameraAboveGround;
  106345. /**
  106346. * Returns the frustum slope based on the canvas ratio and camera FOV
  106347. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106348. */
  106349. private _getFrustumSlope;
  106350. /**
  106351. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106352. */
  106353. private _clearAnimationLocks;
  106354. /**
  106355. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106356. */
  106357. private _applyUserInteraction;
  106358. /**
  106359. * Stops and removes all animations that have been applied to the camera
  106360. */
  106361. stopAllAnimations(): void;
  106362. /**
  106363. * Gets a value indicating if the user is moving the camera
  106364. */
  106365. readonly isUserIsMoving: boolean;
  106366. /**
  106367. * The camera can move all the way towards the mesh.
  106368. */
  106369. static IgnoreBoundsSizeMode: number;
  106370. /**
  106371. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106372. */
  106373. static FitFrustumSidesMode: number;
  106374. }
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * Base class for Camera Pointer Inputs.
  106379. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106380. * for example usage.
  106381. */
  106382. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106383. /**
  106384. * Defines the camera the input is attached to.
  106385. */
  106386. abstract camera: Camera;
  106387. /**
  106388. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106389. */
  106390. protected _altKey: boolean;
  106391. protected _ctrlKey: boolean;
  106392. protected _metaKey: boolean;
  106393. protected _shiftKey: boolean;
  106394. /**
  106395. * Which mouse buttons were pressed at time of last mouse event.
  106396. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106397. */
  106398. protected _buttonsPressed: number;
  106399. /**
  106400. * Defines the buttons associated with the input to handle camera move.
  106401. */
  106402. buttons: number[];
  106403. /**
  106404. * Attach the input controls to a specific dom element to get the input from.
  106405. * @param element Defines the element the controls should be listened from
  106406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106407. */
  106408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106409. /**
  106410. * Detach the current controls from the specified dom element.
  106411. * @param element Defines the element to stop listening the inputs from
  106412. */
  106413. detachControl(element: Nullable<HTMLElement>): void;
  106414. /**
  106415. * Gets the class name of the current input.
  106416. * @returns the class name
  106417. */
  106418. getClassName(): string;
  106419. /**
  106420. * Get the friendly name associated with the input class.
  106421. * @returns the input friendly name
  106422. */
  106423. getSimpleName(): string;
  106424. /**
  106425. * Called on pointer POINTERDOUBLETAP event.
  106426. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106427. */
  106428. protected onDoubleTap(type: string): void;
  106429. /**
  106430. * Called on pointer POINTERMOVE event if only a single touch is active.
  106431. * Override this method to provide functionality.
  106432. */
  106433. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106434. /**
  106435. * Called on pointer POINTERMOVE event if multiple touches are active.
  106436. * Override this method to provide functionality.
  106437. */
  106438. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106439. /**
  106440. * Called on JS contextmenu event.
  106441. * Override this method to provide functionality.
  106442. */
  106443. protected onContextMenu(evt: PointerEvent): void;
  106444. /**
  106445. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106446. * press.
  106447. * Override this method to provide functionality.
  106448. */
  106449. protected onButtonDown(evt: PointerEvent): void;
  106450. /**
  106451. * Called each time a new POINTERUP event occurs. Ie, for each button
  106452. * release.
  106453. * Override this method to provide functionality.
  106454. */
  106455. protected onButtonUp(evt: PointerEvent): void;
  106456. /**
  106457. * Called when window becomes inactive.
  106458. * Override this method to provide functionality.
  106459. */
  106460. protected onLostFocus(): void;
  106461. private _pointerInput;
  106462. private _observer;
  106463. private _onLostFocus;
  106464. private pointA;
  106465. private pointB;
  106466. }
  106467. }
  106468. declare module BABYLON {
  106469. /**
  106470. * Manage the pointers inputs to control an arc rotate camera.
  106471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106472. */
  106473. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  106474. /**
  106475. * Defines the camera the input is attached to.
  106476. */
  106477. camera: ArcRotateCamera;
  106478. /**
  106479. * Gets the class name of the current input.
  106480. * @returns the class name
  106481. */
  106482. getClassName(): string;
  106483. /**
  106484. * Defines the buttons associated with the input to handle camera move.
  106485. */
  106486. buttons: number[];
  106487. /**
  106488. * Defines the pointer angular sensibility along the X axis or how fast is
  106489. * the camera rotating.
  106490. */
  106491. angularSensibilityX: number;
  106492. /**
  106493. * Defines the pointer angular sensibility along the Y axis or how fast is
  106494. * the camera rotating.
  106495. */
  106496. angularSensibilityY: number;
  106497. /**
  106498. * Defines the pointer pinch precision or how fast is the camera zooming.
  106499. */
  106500. pinchPrecision: number;
  106501. /**
  106502. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106503. * from 0.
  106504. * It defines the percentage of current camera.radius to use as delta when
  106505. * pinch zoom is used.
  106506. */
  106507. pinchDeltaPercentage: number;
  106508. /**
  106509. * Defines the pointer panning sensibility or how fast is the camera moving.
  106510. */
  106511. panningSensibility: number;
  106512. /**
  106513. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  106514. */
  106515. multiTouchPanning: boolean;
  106516. /**
  106517. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  106518. * zoom (pinch) through multitouch.
  106519. */
  106520. multiTouchPanAndZoom: boolean;
  106521. /**
  106522. * Revers pinch action direction.
  106523. */
  106524. pinchInwards: boolean;
  106525. private _isPanClick;
  106526. private _twoFingerActivityCount;
  106527. private _isPinching;
  106528. /**
  106529. * Called on pointer POINTERMOVE event if only a single touch is active.
  106530. */
  106531. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106532. /**
  106533. * Called on pointer POINTERDOUBLETAP event.
  106534. */
  106535. protected onDoubleTap(type: string): void;
  106536. /**
  106537. * Called on pointer POINTERMOVE event if multiple touches are active.
  106538. */
  106539. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106540. /**
  106541. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106542. * press.
  106543. */
  106544. protected onButtonDown(evt: PointerEvent): void;
  106545. /**
  106546. * Called each time a new POINTERUP event occurs. Ie, for each button
  106547. * release.
  106548. */
  106549. protected onButtonUp(evt: PointerEvent): void;
  106550. /**
  106551. * Called when window becomes inactive.
  106552. */
  106553. protected onLostFocus(): void;
  106554. }
  106555. }
  106556. declare module BABYLON {
  106557. /**
  106558. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  106559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106560. */
  106561. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  106562. /**
  106563. * Defines the camera the input is attached to.
  106564. */
  106565. camera: ArcRotateCamera;
  106566. /**
  106567. * Defines the list of key codes associated with the up action (increase alpha)
  106568. */
  106569. keysUp: number[];
  106570. /**
  106571. * Defines the list of key codes associated with the down action (decrease alpha)
  106572. */
  106573. keysDown: number[];
  106574. /**
  106575. * Defines the list of key codes associated with the left action (increase beta)
  106576. */
  106577. keysLeft: number[];
  106578. /**
  106579. * Defines the list of key codes associated with the right action (decrease beta)
  106580. */
  106581. keysRight: number[];
  106582. /**
  106583. * Defines the list of key codes associated with the reset action.
  106584. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  106585. */
  106586. keysReset: number[];
  106587. /**
  106588. * Defines the panning sensibility of the inputs.
  106589. * (How fast is the camera paning)
  106590. */
  106591. panningSensibility: number;
  106592. /**
  106593. * Defines the zooming sensibility of the inputs.
  106594. * (How fast is the camera zooming)
  106595. */
  106596. zoomingSensibility: number;
  106597. /**
  106598. * Defines wether maintaining the alt key down switch the movement mode from
  106599. * orientation to zoom.
  106600. */
  106601. useAltToZoom: boolean;
  106602. /**
  106603. * Rotation speed of the camera
  106604. */
  106605. angularSpeed: number;
  106606. private _keys;
  106607. private _ctrlPressed;
  106608. private _altPressed;
  106609. private _onCanvasBlurObserver;
  106610. private _onKeyboardObserver;
  106611. private _engine;
  106612. private _scene;
  106613. /**
  106614. * Attach the input controls to a specific dom element to get the input from.
  106615. * @param element Defines the element the controls should be listened from
  106616. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106617. */
  106618. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106619. /**
  106620. * Detach the current controls from the specified dom element.
  106621. * @param element Defines the element to stop listening the inputs from
  106622. */
  106623. detachControl(element: Nullable<HTMLElement>): void;
  106624. /**
  106625. * Update the current camera state depending on the inputs that have been used this frame.
  106626. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106627. */
  106628. checkInputs(): void;
  106629. /**
  106630. * Gets the class name of the current intput.
  106631. * @returns the class name
  106632. */
  106633. getClassName(): string;
  106634. /**
  106635. * Get the friendly name associated with the input class.
  106636. * @returns the input friendly name
  106637. */
  106638. getSimpleName(): string;
  106639. }
  106640. }
  106641. declare module BABYLON {
  106642. /**
  106643. * Manage the mouse wheel inputs to control an arc rotate camera.
  106644. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106645. */
  106646. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  106647. /**
  106648. * Defines the camera the input is attached to.
  106649. */
  106650. camera: ArcRotateCamera;
  106651. /**
  106652. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106653. */
  106654. wheelPrecision: number;
  106655. /**
  106656. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106657. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106658. */
  106659. wheelDeltaPercentage: number;
  106660. private _wheel;
  106661. private _observer;
  106662. private computeDeltaFromMouseWheelLegacyEvent;
  106663. /**
  106664. * Attach the input controls to a specific dom element to get the input from.
  106665. * @param element Defines the element the controls should be listened from
  106666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106667. */
  106668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106669. /**
  106670. * Detach the current controls from the specified dom element.
  106671. * @param element Defines the element to stop listening the inputs from
  106672. */
  106673. detachControl(element: Nullable<HTMLElement>): void;
  106674. /**
  106675. * Gets the class name of the current intput.
  106676. * @returns the class name
  106677. */
  106678. getClassName(): string;
  106679. /**
  106680. * Get the friendly name associated with the input class.
  106681. * @returns the input friendly name
  106682. */
  106683. getSimpleName(): string;
  106684. }
  106685. }
  106686. declare module BABYLON {
  106687. /**
  106688. * Default Inputs manager for the ArcRotateCamera.
  106689. * It groups all the default supported inputs for ease of use.
  106690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106691. */
  106692. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  106693. /**
  106694. * Instantiates a new ArcRotateCameraInputsManager.
  106695. * @param camera Defines the camera the inputs belong to
  106696. */
  106697. constructor(camera: ArcRotateCamera);
  106698. /**
  106699. * Add mouse wheel input support to the input manager.
  106700. * @returns the current input manager
  106701. */
  106702. addMouseWheel(): ArcRotateCameraInputsManager;
  106703. /**
  106704. * Add pointers input support to the input manager.
  106705. * @returns the current input manager
  106706. */
  106707. addPointers(): ArcRotateCameraInputsManager;
  106708. /**
  106709. * Add keyboard input support to the input manager.
  106710. * @returns the current input manager
  106711. */
  106712. addKeyboard(): ArcRotateCameraInputsManager;
  106713. }
  106714. }
  106715. declare module BABYLON {
  106716. /**
  106717. * This represents an orbital type of camera.
  106718. *
  106719. * 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.
  106720. * 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.
  106721. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  106722. */
  106723. export class ArcRotateCamera extends TargetCamera {
  106724. /**
  106725. * Defines the rotation angle of the camera along the longitudinal axis.
  106726. */
  106727. alpha: number;
  106728. /**
  106729. * Defines the rotation angle of the camera along the latitudinal axis.
  106730. */
  106731. beta: number;
  106732. /**
  106733. * Defines the radius of the camera from it s target point.
  106734. */
  106735. radius: number;
  106736. protected _target: Vector3;
  106737. protected _targetHost: Nullable<AbstractMesh>;
  106738. /**
  106739. * Defines the target point of the camera.
  106740. * The camera looks towards it form the radius distance.
  106741. */
  106742. target: Vector3;
  106743. /**
  106744. * Define the current local position of the camera in the scene
  106745. */
  106746. position: Vector3;
  106747. protected _upVector: Vector3;
  106748. protected _upToYMatrix: Matrix;
  106749. protected _YToUpMatrix: Matrix;
  106750. /**
  106751. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  106752. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  106753. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  106754. */
  106755. upVector: Vector3;
  106756. /**
  106757. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  106758. */
  106759. setMatUp(): void;
  106760. /**
  106761. * Current inertia value on the longitudinal axis.
  106762. * The bigger this number the longer it will take for the camera to stop.
  106763. */
  106764. inertialAlphaOffset: number;
  106765. /**
  106766. * Current inertia value on the latitudinal axis.
  106767. * The bigger this number the longer it will take for the camera to stop.
  106768. */
  106769. inertialBetaOffset: number;
  106770. /**
  106771. * Current inertia value on the radius axis.
  106772. * The bigger this number the longer it will take for the camera to stop.
  106773. */
  106774. inertialRadiusOffset: number;
  106775. /**
  106776. * Minimum allowed angle on the longitudinal axis.
  106777. * This can help limiting how the Camera is able to move in the scene.
  106778. */
  106779. lowerAlphaLimit: Nullable<number>;
  106780. /**
  106781. * Maximum allowed angle on the longitudinal axis.
  106782. * This can help limiting how the Camera is able to move in the scene.
  106783. */
  106784. upperAlphaLimit: Nullable<number>;
  106785. /**
  106786. * Minimum allowed angle on the latitudinal axis.
  106787. * This can help limiting how the Camera is able to move in the scene.
  106788. */
  106789. lowerBetaLimit: number;
  106790. /**
  106791. * Maximum allowed angle on the latitudinal axis.
  106792. * This can help limiting how the Camera is able to move in the scene.
  106793. */
  106794. upperBetaLimit: number;
  106795. /**
  106796. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  106797. * This can help limiting how the Camera is able to move in the scene.
  106798. */
  106799. lowerRadiusLimit: Nullable<number>;
  106800. /**
  106801. * Maximum allowed distance of the camera to the target (The camera can not get further).
  106802. * This can help limiting how the Camera is able to move in the scene.
  106803. */
  106804. upperRadiusLimit: Nullable<number>;
  106805. /**
  106806. * Defines the current inertia value used during panning of the camera along the X axis.
  106807. */
  106808. inertialPanningX: number;
  106809. /**
  106810. * Defines the current inertia value used during panning of the camera along the Y axis.
  106811. */
  106812. inertialPanningY: number;
  106813. /**
  106814. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  106815. * Basically if your fingers moves away from more than this distance you will be considered
  106816. * in pinch mode.
  106817. */
  106818. pinchToPanMaxDistance: number;
  106819. /**
  106820. * Defines the maximum distance the camera can pan.
  106821. * This could help keeping the cammera always in your scene.
  106822. */
  106823. panningDistanceLimit: Nullable<number>;
  106824. /**
  106825. * Defines the target of the camera before paning.
  106826. */
  106827. panningOriginTarget: Vector3;
  106828. /**
  106829. * Defines the value of the inertia used during panning.
  106830. * 0 would mean stop inertia and one would mean no decelleration at all.
  106831. */
  106832. panningInertia: number;
  106833. /**
  106834. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  106835. */
  106836. angularSensibilityX: number;
  106837. /**
  106838. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  106839. */
  106840. angularSensibilityY: number;
  106841. /**
  106842. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  106843. */
  106844. pinchPrecision: number;
  106845. /**
  106846. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  106847. * It will be used instead of pinchDeltaPrecision if different from 0.
  106848. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106849. */
  106850. pinchDeltaPercentage: number;
  106851. /**
  106852. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  106853. */
  106854. panningSensibility: number;
  106855. /**
  106856. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  106857. */
  106858. keysUp: number[];
  106859. /**
  106860. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  106861. */
  106862. keysDown: number[];
  106863. /**
  106864. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  106865. */
  106866. keysLeft: number[];
  106867. /**
  106868. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  106869. */
  106870. keysRight: number[];
  106871. /**
  106872. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  106873. */
  106874. wheelPrecision: number;
  106875. /**
  106876. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  106877. * It will be used instead of pinchDeltaPrecision if different from 0.
  106878. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  106879. */
  106880. wheelDeltaPercentage: number;
  106881. /**
  106882. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  106883. */
  106884. zoomOnFactor: number;
  106885. /**
  106886. * Defines a screen offset for the camera position.
  106887. */
  106888. targetScreenOffset: Vector2;
  106889. /**
  106890. * Allows the camera to be completely reversed.
  106891. * If false the camera can not arrive upside down.
  106892. */
  106893. allowUpsideDown: boolean;
  106894. /**
  106895. * Define if double tap/click is used to restore the previously saved state of the camera.
  106896. */
  106897. useInputToRestoreState: boolean;
  106898. /** @hidden */
  106899. _viewMatrix: Matrix;
  106900. /** @hidden */
  106901. _useCtrlForPanning: boolean;
  106902. /** @hidden */
  106903. _panningMouseButton: number;
  106904. /**
  106905. * Defines the input associated to the camera.
  106906. */
  106907. inputs: ArcRotateCameraInputsManager;
  106908. /** @hidden */
  106909. _reset: () => void;
  106910. /**
  106911. * Defines the allowed panning axis.
  106912. */
  106913. panningAxis: Vector3;
  106914. protected _localDirection: Vector3;
  106915. protected _transformedDirection: Vector3;
  106916. private _bouncingBehavior;
  106917. /**
  106918. * Gets the bouncing behavior of the camera if it has been enabled.
  106919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106920. */
  106921. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  106922. /**
  106923. * Defines if the bouncing behavior of the camera is enabled on the camera.
  106924. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106925. */
  106926. useBouncingBehavior: boolean;
  106927. private _framingBehavior;
  106928. /**
  106929. * Gets the framing behavior of the camera if it has been enabled.
  106930. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106931. */
  106932. readonly framingBehavior: Nullable<FramingBehavior>;
  106933. /**
  106934. * Defines if the framing behavior of the camera is enabled on the camera.
  106935. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106936. */
  106937. useFramingBehavior: boolean;
  106938. private _autoRotationBehavior;
  106939. /**
  106940. * Gets the auto rotation behavior of the camera if it has been enabled.
  106941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106942. */
  106943. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  106944. /**
  106945. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  106946. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  106947. */
  106948. useAutoRotationBehavior: boolean;
  106949. /**
  106950. * Observable triggered when the mesh target has been changed on the camera.
  106951. */
  106952. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  106953. /**
  106954. * Event raised when the camera is colliding with a mesh.
  106955. */
  106956. onCollide: (collidedMesh: AbstractMesh) => void;
  106957. /**
  106958. * Defines whether the camera should check collision with the objects oh the scene.
  106959. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  106960. */
  106961. checkCollisions: boolean;
  106962. /**
  106963. * Defines the collision radius of the camera.
  106964. * This simulates a sphere around the camera.
  106965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106966. */
  106967. collisionRadius: Vector3;
  106968. protected _collider: Collider;
  106969. protected _previousPosition: Vector3;
  106970. protected _collisionVelocity: Vector3;
  106971. protected _newPosition: Vector3;
  106972. protected _previousAlpha: number;
  106973. protected _previousBeta: number;
  106974. protected _previousRadius: number;
  106975. protected _collisionTriggered: boolean;
  106976. protected _targetBoundingCenter: Nullable<Vector3>;
  106977. private _computationVector;
  106978. /**
  106979. * Instantiates a new ArcRotateCamera in a given scene
  106980. * @param name Defines the name of the camera
  106981. * @param alpha Defines the camera rotation along the logitudinal axis
  106982. * @param beta Defines the camera rotation along the latitudinal axis
  106983. * @param radius Defines the camera distance from its target
  106984. * @param target Defines the camera target
  106985. * @param scene Defines the scene the camera belongs to
  106986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  106987. */
  106988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106989. /** @hidden */
  106990. _initCache(): void;
  106991. /** @hidden */
  106992. _updateCache(ignoreParentClass?: boolean): void;
  106993. protected _getTargetPosition(): Vector3;
  106994. private _storedAlpha;
  106995. private _storedBeta;
  106996. private _storedRadius;
  106997. private _storedTarget;
  106998. private _storedTargetScreenOffset;
  106999. /**
  107000. * Stores the current state of the camera (alpha, beta, radius and target)
  107001. * @returns the camera itself
  107002. */
  107003. storeState(): Camera;
  107004. /**
  107005. * @hidden
  107006. * Restored camera state. You must call storeState() first
  107007. */
  107008. _restoreStateValues(): boolean;
  107009. /** @hidden */
  107010. _isSynchronizedViewMatrix(): boolean;
  107011. /**
  107012. * Attached controls to the current camera.
  107013. * @param element Defines the element the controls should be listened from
  107014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107015. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107016. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107017. */
  107018. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107019. /**
  107020. * Detach the current controls from the camera.
  107021. * The camera will stop reacting to inputs.
  107022. * @param element Defines the element to stop listening the inputs from
  107023. */
  107024. detachControl(element: HTMLElement): void;
  107025. /** @hidden */
  107026. _checkInputs(): void;
  107027. protected _checkLimits(): void;
  107028. /**
  107029. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107030. */
  107031. rebuildAnglesAndRadius(): void;
  107032. /**
  107033. * Use a position to define the current camera related information like alpha, beta and radius
  107034. * @param position Defines the position to set the camera at
  107035. */
  107036. setPosition(position: Vector3): void;
  107037. /**
  107038. * Defines the target the camera should look at.
  107039. * This will automatically adapt alpha beta and radius to fit within the new target.
  107040. * @param target Defines the new target as a Vector or a mesh
  107041. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107042. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107043. */
  107044. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107045. /** @hidden */
  107046. _getViewMatrix(): Matrix;
  107047. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107048. /**
  107049. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107050. * @param meshes Defines the mesh to zoom on
  107051. * @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)
  107052. */
  107053. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107054. /**
  107055. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107056. * The target will be changed but the radius
  107057. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107058. * @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)
  107059. */
  107060. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107061. min: Vector3;
  107062. max: Vector3;
  107063. distance: number;
  107064. }, doNotUpdateMaxZ?: boolean): void;
  107065. /**
  107066. * @override
  107067. * Override Camera.createRigCamera
  107068. */
  107069. createRigCamera(name: string, cameraIndex: number): Camera;
  107070. /**
  107071. * @hidden
  107072. * @override
  107073. * Override Camera._updateRigCameras
  107074. */
  107075. _updateRigCameras(): void;
  107076. /**
  107077. * Destroy the camera and release the current resources hold by it.
  107078. */
  107079. dispose(): void;
  107080. /**
  107081. * Gets the current object class name.
  107082. * @return the class name
  107083. */
  107084. getClassName(): string;
  107085. }
  107086. }
  107087. declare module BABYLON {
  107088. /**
  107089. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107090. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107091. */
  107092. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107093. /**
  107094. * Gets the name of the behavior.
  107095. */
  107096. readonly name: string;
  107097. private _zoomStopsAnimation;
  107098. private _idleRotationSpeed;
  107099. private _idleRotationWaitTime;
  107100. private _idleRotationSpinupTime;
  107101. /**
  107102. * Sets the flag that indicates if user zooming should stop animation.
  107103. */
  107104. /**
  107105. * Gets the flag that indicates if user zooming should stop animation.
  107106. */
  107107. zoomStopsAnimation: boolean;
  107108. /**
  107109. * Sets the default speed at which the camera rotates around the model.
  107110. */
  107111. /**
  107112. * Gets the default speed at which the camera rotates around the model.
  107113. */
  107114. idleRotationSpeed: number;
  107115. /**
  107116. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107117. */
  107118. /**
  107119. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107120. */
  107121. idleRotationWaitTime: number;
  107122. /**
  107123. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107124. */
  107125. /**
  107126. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107127. */
  107128. idleRotationSpinupTime: number;
  107129. /**
  107130. * Gets a value indicating if the camera is currently rotating because of this behavior
  107131. */
  107132. readonly rotationInProgress: boolean;
  107133. private _onPrePointerObservableObserver;
  107134. private _onAfterCheckInputsObserver;
  107135. private _attachedCamera;
  107136. private _isPointerDown;
  107137. private _lastFrameTime;
  107138. private _lastInteractionTime;
  107139. private _cameraRotationSpeed;
  107140. /**
  107141. * Initializes the behavior.
  107142. */
  107143. init(): void;
  107144. /**
  107145. * Attaches the behavior to its arc rotate camera.
  107146. * @param camera Defines the camera to attach the behavior to
  107147. */
  107148. attach(camera: ArcRotateCamera): void;
  107149. /**
  107150. * Detaches the behavior from its current arc rotate camera.
  107151. */
  107152. detach(): void;
  107153. /**
  107154. * Returns true if user is scrolling.
  107155. * @return true if user is scrolling.
  107156. */
  107157. private _userIsZooming;
  107158. private _lastFrameRadius;
  107159. private _shouldAnimationStopForInteraction;
  107160. /**
  107161. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107162. */
  107163. private _applyUserInteraction;
  107164. private _userIsMoving;
  107165. }
  107166. }
  107167. declare module BABYLON {
  107168. /**
  107169. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107170. */
  107171. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107172. private ui;
  107173. /**
  107174. * The name of the behavior
  107175. */
  107176. name: string;
  107177. /**
  107178. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107179. */
  107180. distanceAwayFromFace: number;
  107181. /**
  107182. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107183. */
  107184. distanceAwayFromBottomOfFace: number;
  107185. private _faceVectors;
  107186. private _target;
  107187. private _scene;
  107188. private _onRenderObserver;
  107189. private _tmpMatrix;
  107190. private _tmpVector;
  107191. /**
  107192. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107193. * @param ui The transform node that should be attched to the mesh
  107194. */
  107195. constructor(ui: TransformNode);
  107196. /**
  107197. * Initializes the behavior
  107198. */
  107199. init(): void;
  107200. private _closestFace;
  107201. private _zeroVector;
  107202. private _lookAtTmpMatrix;
  107203. private _lookAtToRef;
  107204. /**
  107205. * Attaches the AttachToBoxBehavior to the passed in mesh
  107206. * @param target The mesh that the specified node will be attached to
  107207. */
  107208. attach(target: Mesh): void;
  107209. /**
  107210. * Detaches the behavior from the mesh
  107211. */
  107212. detach(): void;
  107213. }
  107214. }
  107215. declare module BABYLON {
  107216. /**
  107217. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107218. */
  107219. export class FadeInOutBehavior implements Behavior<Mesh> {
  107220. /**
  107221. * Time in milliseconds to delay before fading in (Default: 0)
  107222. */
  107223. delay: number;
  107224. /**
  107225. * Time in milliseconds for the mesh to fade in (Default: 300)
  107226. */
  107227. fadeInTime: number;
  107228. private _millisecondsPerFrame;
  107229. private _hovered;
  107230. private _hoverValue;
  107231. private _ownerNode;
  107232. /**
  107233. * Instatiates the FadeInOutBehavior
  107234. */
  107235. constructor();
  107236. /**
  107237. * The name of the behavior
  107238. */
  107239. readonly name: string;
  107240. /**
  107241. * Initializes the behavior
  107242. */
  107243. init(): void;
  107244. /**
  107245. * Attaches the fade behavior on the passed in mesh
  107246. * @param ownerNode The mesh that will be faded in/out once attached
  107247. */
  107248. attach(ownerNode: Mesh): void;
  107249. /**
  107250. * Detaches the behavior from the mesh
  107251. */
  107252. detach(): void;
  107253. /**
  107254. * Triggers the mesh to begin fading in or out
  107255. * @param value if the object should fade in or out (true to fade in)
  107256. */
  107257. fadeIn(value: boolean): void;
  107258. private _update;
  107259. private _setAllVisibility;
  107260. }
  107261. }
  107262. declare module BABYLON {
  107263. /**
  107264. * Class containing a set of static utilities functions for managing Pivots
  107265. * @hidden
  107266. */
  107267. export class PivotTools {
  107268. private static _PivotCached;
  107269. private static _OldPivotPoint;
  107270. private static _PivotTranslation;
  107271. private static _PivotTmpVector;
  107272. /** @hidden */
  107273. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107274. /** @hidden */
  107275. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107276. }
  107277. }
  107278. declare module BABYLON {
  107279. /**
  107280. * Class containing static functions to help procedurally build meshes
  107281. */
  107282. export class PlaneBuilder {
  107283. /**
  107284. * Creates a plane mesh
  107285. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107286. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107287. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107291. * @param name defines the name of the mesh
  107292. * @param options defines the options used to create the mesh
  107293. * @param scene defines the hosting scene
  107294. * @returns the plane mesh
  107295. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107296. */
  107297. static CreatePlane(name: string, options: {
  107298. size?: number;
  107299. width?: number;
  107300. height?: number;
  107301. sideOrientation?: number;
  107302. frontUVs?: Vector4;
  107303. backUVs?: Vector4;
  107304. updatable?: boolean;
  107305. sourcePlane?: Plane;
  107306. }, scene?: Nullable<Scene>): Mesh;
  107307. }
  107308. }
  107309. declare module BABYLON {
  107310. /**
  107311. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107312. */
  107313. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107314. private static _AnyMouseID;
  107315. /**
  107316. * Abstract mesh the behavior is set on
  107317. */
  107318. attachedNode: AbstractMesh;
  107319. private _dragPlane;
  107320. private _scene;
  107321. private _pointerObserver;
  107322. private _beforeRenderObserver;
  107323. private static _planeScene;
  107324. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107325. /**
  107326. * 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)
  107327. */
  107328. maxDragAngle: number;
  107329. /**
  107330. * @hidden
  107331. */
  107332. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107333. /**
  107334. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107335. */
  107336. currentDraggingPointerID: number;
  107337. /**
  107338. * The last position where the pointer hit the drag plane in world space
  107339. */
  107340. lastDragPosition: Vector3;
  107341. /**
  107342. * If the behavior is currently in a dragging state
  107343. */
  107344. dragging: boolean;
  107345. /**
  107346. * 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)
  107347. */
  107348. dragDeltaRatio: number;
  107349. /**
  107350. * If the drag plane orientation should be updated during the dragging (Default: true)
  107351. */
  107352. updateDragPlane: boolean;
  107353. private _debugMode;
  107354. private _moving;
  107355. /**
  107356. * Fires each time the attached mesh is dragged with the pointer
  107357. * * delta between last drag position and current drag position in world space
  107358. * * dragDistance along the drag axis
  107359. * * dragPlaneNormal normal of the current drag plane used during the drag
  107360. * * dragPlanePoint in world space where the drag intersects the drag plane
  107361. */
  107362. onDragObservable: Observable<{
  107363. delta: Vector3;
  107364. dragPlanePoint: Vector3;
  107365. dragPlaneNormal: Vector3;
  107366. dragDistance: number;
  107367. pointerId: number;
  107368. }>;
  107369. /**
  107370. * Fires each time a drag begins (eg. mouse down on mesh)
  107371. */
  107372. onDragStartObservable: Observable<{
  107373. dragPlanePoint: Vector3;
  107374. pointerId: number;
  107375. }>;
  107376. /**
  107377. * Fires each time a drag ends (eg. mouse release after drag)
  107378. */
  107379. onDragEndObservable: Observable<{
  107380. dragPlanePoint: Vector3;
  107381. pointerId: number;
  107382. }>;
  107383. /**
  107384. * If the attached mesh should be moved when dragged
  107385. */
  107386. moveAttached: boolean;
  107387. /**
  107388. * If the drag behavior will react to drag events (Default: true)
  107389. */
  107390. enabled: boolean;
  107391. /**
  107392. * If pointer events should start and release the drag (Default: true)
  107393. */
  107394. startAndReleaseDragOnPointerEvents: boolean;
  107395. /**
  107396. * If camera controls should be detached during the drag
  107397. */
  107398. detachCameraControls: boolean;
  107399. /**
  107400. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107401. */
  107402. useObjectOrienationForDragging: boolean;
  107403. private _options;
  107404. /**
  107405. * Gets the options used by the behavior
  107406. */
  107407. /**
  107408. * Sets the options used by the behavior
  107409. */
  107410. options: {
  107411. dragAxis?: Vector3;
  107412. dragPlaneNormal?: Vector3;
  107413. };
  107414. /**
  107415. * Creates a pointer drag behavior that can be attached to a mesh
  107416. * @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)
  107417. */
  107418. constructor(options?: {
  107419. dragAxis?: Vector3;
  107420. dragPlaneNormal?: Vector3;
  107421. });
  107422. /**
  107423. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107424. */
  107425. validateDrag: (targetPosition: Vector3) => boolean;
  107426. /**
  107427. * The name of the behavior
  107428. */
  107429. readonly name: string;
  107430. /**
  107431. * Initializes the behavior
  107432. */
  107433. init(): void;
  107434. private _tmpVector;
  107435. private _alternatePickedPoint;
  107436. private _worldDragAxis;
  107437. private _targetPosition;
  107438. private _attachedElement;
  107439. /**
  107440. * Attaches the drag behavior the passed in mesh
  107441. * @param ownerNode The mesh that will be dragged around once attached
  107442. * @param predicate Predicate to use for pick filtering
  107443. */
  107444. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107445. /**
  107446. * Force relase the drag action by code.
  107447. */
  107448. releaseDrag(): void;
  107449. private _startDragRay;
  107450. private _lastPointerRay;
  107451. /**
  107452. * Simulates the start of a pointer drag event on the behavior
  107453. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  107454. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  107455. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  107456. */
  107457. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  107458. private _startDrag;
  107459. private _dragDelta;
  107460. private _moveDrag;
  107461. private _pickWithRayOnDragPlane;
  107462. private _pointA;
  107463. private _pointB;
  107464. private _pointC;
  107465. private _lineA;
  107466. private _lineB;
  107467. private _localAxis;
  107468. private _lookAt;
  107469. private _updateDragPlanePosition;
  107470. /**
  107471. * Detaches the behavior from the mesh
  107472. */
  107473. detach(): void;
  107474. }
  107475. }
  107476. declare module BABYLON {
  107477. /**
  107478. * A behavior that when attached to a mesh will allow the mesh to be scaled
  107479. */
  107480. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  107481. private _dragBehaviorA;
  107482. private _dragBehaviorB;
  107483. private _startDistance;
  107484. private _initialScale;
  107485. private _targetScale;
  107486. private _ownerNode;
  107487. private _sceneRenderObserver;
  107488. /**
  107489. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  107490. */
  107491. constructor();
  107492. /**
  107493. * The name of the behavior
  107494. */
  107495. readonly name: string;
  107496. /**
  107497. * Initializes the behavior
  107498. */
  107499. init(): void;
  107500. private _getCurrentDistance;
  107501. /**
  107502. * Attaches the scale behavior the passed in mesh
  107503. * @param ownerNode The mesh that will be scaled around once attached
  107504. */
  107505. attach(ownerNode: Mesh): void;
  107506. /**
  107507. * Detaches the behavior from the mesh
  107508. */
  107509. detach(): void;
  107510. }
  107511. }
  107512. declare module BABYLON {
  107513. /**
  107514. * 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
  107515. */
  107516. export class SixDofDragBehavior implements Behavior<Mesh> {
  107517. private static _virtualScene;
  107518. private _ownerNode;
  107519. private _sceneRenderObserver;
  107520. private _scene;
  107521. private _targetPosition;
  107522. private _virtualOriginMesh;
  107523. private _virtualDragMesh;
  107524. private _pointerObserver;
  107525. private _moving;
  107526. private _startingOrientation;
  107527. /**
  107528. * 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)
  107529. */
  107530. private zDragFactor;
  107531. /**
  107532. * If the object should rotate to face the drag origin
  107533. */
  107534. rotateDraggedObject: boolean;
  107535. /**
  107536. * If the behavior is currently in a dragging state
  107537. */
  107538. dragging: boolean;
  107539. /**
  107540. * 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)
  107541. */
  107542. dragDeltaRatio: number;
  107543. /**
  107544. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107545. */
  107546. currentDraggingPointerID: number;
  107547. /**
  107548. * If camera controls should be detached during the drag
  107549. */
  107550. detachCameraControls: boolean;
  107551. /**
  107552. * Fires each time a drag starts
  107553. */
  107554. onDragStartObservable: Observable<{}>;
  107555. /**
  107556. * Fires each time a drag ends (eg. mouse release after drag)
  107557. */
  107558. onDragEndObservable: Observable<{}>;
  107559. /**
  107560. * 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
  107561. */
  107562. constructor();
  107563. /**
  107564. * The name of the behavior
  107565. */
  107566. readonly name: string;
  107567. /**
  107568. * Initializes the behavior
  107569. */
  107570. init(): void;
  107571. /**
  107572. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  107573. */
  107574. private readonly _pointerCamera;
  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. * Class used to apply inverse kinematics to bones
  107589. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  107590. */
  107591. export class BoneIKController {
  107592. private static _tmpVecs;
  107593. private static _tmpQuat;
  107594. private static _tmpMats;
  107595. /**
  107596. * Gets or sets the target mesh
  107597. */
  107598. targetMesh: AbstractMesh;
  107599. /** Gets or sets the mesh used as pole */
  107600. poleTargetMesh: AbstractMesh;
  107601. /**
  107602. * Gets or sets the bone used as pole
  107603. */
  107604. poleTargetBone: Nullable<Bone>;
  107605. /**
  107606. * Gets or sets the target position
  107607. */
  107608. targetPosition: Vector3;
  107609. /**
  107610. * Gets or sets the pole target position
  107611. */
  107612. poleTargetPosition: Vector3;
  107613. /**
  107614. * Gets or sets the pole target local offset
  107615. */
  107616. poleTargetLocalOffset: Vector3;
  107617. /**
  107618. * Gets or sets the pole angle
  107619. */
  107620. poleAngle: number;
  107621. /**
  107622. * Gets or sets the mesh associated with the controller
  107623. */
  107624. mesh: AbstractMesh;
  107625. /**
  107626. * 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)
  107627. */
  107628. slerpAmount: number;
  107629. private _bone1Quat;
  107630. private _bone1Mat;
  107631. private _bone2Ang;
  107632. private _bone1;
  107633. private _bone2;
  107634. private _bone1Length;
  107635. private _bone2Length;
  107636. private _maxAngle;
  107637. private _maxReach;
  107638. private _rightHandedSystem;
  107639. private _bendAxis;
  107640. private _slerping;
  107641. private _adjustRoll;
  107642. /**
  107643. * Gets or sets maximum allowed angle
  107644. */
  107645. maxAngle: number;
  107646. /**
  107647. * Creates a new BoneIKController
  107648. * @param mesh defines the mesh to control
  107649. * @param bone defines the bone to control
  107650. * @param options defines options to set up the controller
  107651. */
  107652. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  107653. targetMesh?: AbstractMesh;
  107654. poleTargetMesh?: AbstractMesh;
  107655. poleTargetBone?: Bone;
  107656. poleTargetLocalOffset?: Vector3;
  107657. poleAngle?: number;
  107658. bendAxis?: Vector3;
  107659. maxAngle?: number;
  107660. slerpAmount?: number;
  107661. });
  107662. private _setMaxAngle;
  107663. /**
  107664. * Force the controller to update the bones
  107665. */
  107666. update(): void;
  107667. }
  107668. }
  107669. declare module BABYLON {
  107670. /**
  107671. * Class used to make a bone look toward a point in space
  107672. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  107673. */
  107674. export class BoneLookController {
  107675. private static _tmpVecs;
  107676. private static _tmpQuat;
  107677. private static _tmpMats;
  107678. /**
  107679. * The target Vector3 that the bone will look at
  107680. */
  107681. target: Vector3;
  107682. /**
  107683. * The mesh that the bone is attached to
  107684. */
  107685. mesh: AbstractMesh;
  107686. /**
  107687. * The bone that will be looking to the target
  107688. */
  107689. bone: Bone;
  107690. /**
  107691. * The up axis of the coordinate system that is used when the bone is rotated
  107692. */
  107693. upAxis: Vector3;
  107694. /**
  107695. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  107696. */
  107697. upAxisSpace: Space;
  107698. /**
  107699. * Used to make an adjustment to the yaw of the bone
  107700. */
  107701. adjustYaw: number;
  107702. /**
  107703. * Used to make an adjustment to the pitch of the bone
  107704. */
  107705. adjustPitch: number;
  107706. /**
  107707. * Used to make an adjustment to the roll of the bone
  107708. */
  107709. adjustRoll: number;
  107710. /**
  107711. * 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)
  107712. */
  107713. slerpAmount: number;
  107714. private _minYaw;
  107715. private _maxYaw;
  107716. private _minPitch;
  107717. private _maxPitch;
  107718. private _minYawSin;
  107719. private _minYawCos;
  107720. private _maxYawSin;
  107721. private _maxYawCos;
  107722. private _midYawConstraint;
  107723. private _minPitchTan;
  107724. private _maxPitchTan;
  107725. private _boneQuat;
  107726. private _slerping;
  107727. private _transformYawPitch;
  107728. private _transformYawPitchInv;
  107729. private _firstFrameSkipped;
  107730. private _yawRange;
  107731. private _fowardAxis;
  107732. /**
  107733. * Gets or sets the minimum yaw angle that the bone can look to
  107734. */
  107735. minYaw: number;
  107736. /**
  107737. * Gets or sets the maximum yaw angle that the bone can look to
  107738. */
  107739. maxYaw: number;
  107740. /**
  107741. * Gets or sets the minimum pitch angle that the bone can look to
  107742. */
  107743. minPitch: number;
  107744. /**
  107745. * Gets or sets the maximum pitch angle that the bone can look to
  107746. */
  107747. maxPitch: number;
  107748. /**
  107749. * Create a BoneLookController
  107750. * @param mesh the mesh that the bone belongs to
  107751. * @param bone the bone that will be looking to the target
  107752. * @param target the target Vector3 to look at
  107753. * @param options optional settings:
  107754. * * maxYaw: the maximum angle the bone will yaw to
  107755. * * minYaw: the minimum angle the bone will yaw to
  107756. * * maxPitch: the maximum angle the bone will pitch to
  107757. * * minPitch: the minimum angle the bone will yaw to
  107758. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  107759. * * upAxis: the up axis of the coordinate system
  107760. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  107761. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  107762. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  107763. * * adjustYaw: used to make an adjustment to the yaw of the bone
  107764. * * adjustPitch: used to make an adjustment to the pitch of the bone
  107765. * * adjustRoll: used to make an adjustment to the roll of the bone
  107766. **/
  107767. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  107768. maxYaw?: number;
  107769. minYaw?: number;
  107770. maxPitch?: number;
  107771. minPitch?: number;
  107772. slerpAmount?: number;
  107773. upAxis?: Vector3;
  107774. upAxisSpace?: Space;
  107775. yawAxis?: Vector3;
  107776. pitchAxis?: Vector3;
  107777. adjustYaw?: number;
  107778. adjustPitch?: number;
  107779. adjustRoll?: number;
  107780. });
  107781. /**
  107782. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  107783. */
  107784. update(): void;
  107785. private _getAngleDiff;
  107786. private _getAngleBetween;
  107787. private _isAngleBetween;
  107788. }
  107789. }
  107790. declare module BABYLON {
  107791. /**
  107792. * Manage the gamepad inputs to control an arc rotate camera.
  107793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107794. */
  107795. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  107796. /**
  107797. * Defines the camera the input is attached to.
  107798. */
  107799. camera: ArcRotateCamera;
  107800. /**
  107801. * Defines the gamepad the input is gathering event from.
  107802. */
  107803. gamepad: Nullable<Gamepad>;
  107804. /**
  107805. * Defines the gamepad rotation sensiblity.
  107806. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107807. */
  107808. gamepadRotationSensibility: number;
  107809. /**
  107810. * Defines the gamepad move sensiblity.
  107811. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107812. */
  107813. gamepadMoveSensibility: number;
  107814. private _yAxisScale;
  107815. /**
  107816. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107817. */
  107818. invertYAxis: boolean;
  107819. private _onGamepadConnectedObserver;
  107820. private _onGamepadDisconnectedObserver;
  107821. /**
  107822. * Attach the input controls to a specific dom element to get the input from.
  107823. * @param element Defines the element the controls should be listened from
  107824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107825. */
  107826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107827. /**
  107828. * Detach the current controls from the specified dom element.
  107829. * @param element Defines the element to stop listening the inputs from
  107830. */
  107831. detachControl(element: Nullable<HTMLElement>): void;
  107832. /**
  107833. * Update the current camera state depending on the inputs that have been used this frame.
  107834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107835. */
  107836. checkInputs(): void;
  107837. /**
  107838. * Gets the class name of the current intput.
  107839. * @returns the class name
  107840. */
  107841. getClassName(): string;
  107842. /**
  107843. * Get the friendly name associated with the input class.
  107844. * @returns the input friendly name
  107845. */
  107846. getSimpleName(): string;
  107847. }
  107848. }
  107849. declare module BABYLON {
  107850. interface ArcRotateCameraInputsManager {
  107851. /**
  107852. * Add orientation input support to the input manager.
  107853. * @returns the current input manager
  107854. */
  107855. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  107856. }
  107857. /**
  107858. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  107859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107860. */
  107861. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  107862. /**
  107863. * Defines the camera the input is attached to.
  107864. */
  107865. camera: ArcRotateCamera;
  107866. /**
  107867. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  107868. */
  107869. alphaCorrection: number;
  107870. /**
  107871. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  107872. */
  107873. gammaCorrection: number;
  107874. private _alpha;
  107875. private _gamma;
  107876. private _dirty;
  107877. private _deviceOrientationHandler;
  107878. /**
  107879. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  107880. */
  107881. constructor();
  107882. /**
  107883. * Attach the input controls to a specific dom element to get the input from.
  107884. * @param element Defines the element the controls should be listened from
  107885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107886. */
  107887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107888. /** @hidden */
  107889. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  107890. /**
  107891. * Update the current camera state depending on the inputs that have been used this frame.
  107892. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107893. */
  107894. checkInputs(): void;
  107895. /**
  107896. * Detach the current controls from the specified dom element.
  107897. * @param element Defines the element to stop listening the inputs from
  107898. */
  107899. detachControl(element: Nullable<HTMLElement>): void;
  107900. /**
  107901. * Gets the class name of the current intput.
  107902. * @returns the class name
  107903. */
  107904. getClassName(): string;
  107905. /**
  107906. * Get the friendly name associated with the input class.
  107907. * @returns the input friendly name
  107908. */
  107909. getSimpleName(): string;
  107910. }
  107911. }
  107912. declare module BABYLON {
  107913. /**
  107914. * Listen to mouse events to control the camera.
  107915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107916. */
  107917. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  107918. /**
  107919. * Defines the camera the input is attached to.
  107920. */
  107921. camera: FlyCamera;
  107922. /**
  107923. * Defines if touch is enabled. (Default is true.)
  107924. */
  107925. touchEnabled: boolean;
  107926. /**
  107927. * Defines the buttons associated with the input to handle camera rotation.
  107928. */
  107929. buttons: number[];
  107930. /**
  107931. * Assign buttons for Yaw control.
  107932. */
  107933. buttonsYaw: number[];
  107934. /**
  107935. * Assign buttons for Pitch control.
  107936. */
  107937. buttonsPitch: number[];
  107938. /**
  107939. * Assign buttons for Roll control.
  107940. */
  107941. buttonsRoll: number[];
  107942. /**
  107943. * Detect if any button is being pressed while mouse is moved.
  107944. * -1 = Mouse locked.
  107945. * 0 = Left button.
  107946. * 1 = Middle Button.
  107947. * 2 = Right Button.
  107948. */
  107949. activeButton: number;
  107950. /**
  107951. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  107952. * Higher values reduce its sensitivity.
  107953. */
  107954. angularSensibility: number;
  107955. private _mousemoveCallback;
  107956. private _observer;
  107957. private _rollObserver;
  107958. private previousPosition;
  107959. private noPreventDefault;
  107960. private element;
  107961. /**
  107962. * Listen to mouse events to control the camera.
  107963. * @param touchEnabled Define if touch is enabled. (Default is true.)
  107964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107965. */
  107966. constructor(touchEnabled?: boolean);
  107967. /**
  107968. * Attach the mouse control to the HTML DOM element.
  107969. * @param element Defines the element that listens to the input events.
  107970. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  107971. */
  107972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107973. /**
  107974. * Detach the current controls from the specified dom element.
  107975. * @param element Defines the element to stop listening the inputs from
  107976. */
  107977. detachControl(element: Nullable<HTMLElement>): void;
  107978. /**
  107979. * Gets the class name of the current input.
  107980. * @returns the class name.
  107981. */
  107982. getClassName(): string;
  107983. /**
  107984. * Get the friendly name associated with the input class.
  107985. * @returns the input's friendly name.
  107986. */
  107987. getSimpleName(): string;
  107988. private _pointerInput;
  107989. private _onMouseMove;
  107990. /**
  107991. * Rotate camera by mouse offset.
  107992. */
  107993. private rotateCamera;
  107994. }
  107995. }
  107996. declare module BABYLON {
  107997. /**
  107998. * Default Inputs manager for the FlyCamera.
  107999. * It groups all the default supported inputs for ease of use.
  108000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108001. */
  108002. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108003. /**
  108004. * Instantiates a new FlyCameraInputsManager.
  108005. * @param camera Defines the camera the inputs belong to.
  108006. */
  108007. constructor(camera: FlyCamera);
  108008. /**
  108009. * Add keyboard input support to the input manager.
  108010. * @returns the new FlyCameraKeyboardMoveInput().
  108011. */
  108012. addKeyboard(): FlyCameraInputsManager;
  108013. /**
  108014. * Add mouse input support to the input manager.
  108015. * @param touchEnabled Enable touch screen support.
  108016. * @returns the new FlyCameraMouseInput().
  108017. */
  108018. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108019. }
  108020. }
  108021. declare module BABYLON {
  108022. /**
  108023. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108024. * such as in a 3D Space Shooter or a Flight Simulator.
  108025. */
  108026. export class FlyCamera extends TargetCamera {
  108027. /**
  108028. * Define the collision ellipsoid of the camera.
  108029. * This is helpful for simulating a camera body, like a player's body.
  108030. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108031. */
  108032. ellipsoid: Vector3;
  108033. /**
  108034. * Define an offset for the position of the ellipsoid around the camera.
  108035. * This can be helpful if the camera is attached away from the player's body center,
  108036. * such as at its head.
  108037. */
  108038. ellipsoidOffset: Vector3;
  108039. /**
  108040. * Enable or disable collisions of the camera with the rest of the scene objects.
  108041. */
  108042. checkCollisions: boolean;
  108043. /**
  108044. * Enable or disable gravity on the camera.
  108045. */
  108046. applyGravity: boolean;
  108047. /**
  108048. * Define the current direction the camera is moving to.
  108049. */
  108050. cameraDirection: Vector3;
  108051. /**
  108052. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108053. * This overrides and empties cameraRotation.
  108054. */
  108055. rotationQuaternion: Quaternion;
  108056. /**
  108057. * Track Roll to maintain the wanted Rolling when looking around.
  108058. */
  108059. _trackRoll: number;
  108060. /**
  108061. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108062. */
  108063. rollCorrect: number;
  108064. /**
  108065. * Mimic a banked turn, Rolling the camera when Yawing.
  108066. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108067. */
  108068. bankedTurn: boolean;
  108069. /**
  108070. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108071. */
  108072. bankedTurnLimit: number;
  108073. /**
  108074. * Value of 0 disables the banked Roll.
  108075. * Value of 1 is equal to the Yaw angle in radians.
  108076. */
  108077. bankedTurnMultiplier: number;
  108078. /**
  108079. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108080. */
  108081. inputs: FlyCameraInputsManager;
  108082. /**
  108083. * Gets the input sensibility for mouse input.
  108084. * Higher values reduce sensitivity.
  108085. */
  108086. /**
  108087. * Sets the input sensibility for a mouse input.
  108088. * Higher values reduce sensitivity.
  108089. */
  108090. angularSensibility: number;
  108091. /**
  108092. * Get the keys for camera movement forward.
  108093. */
  108094. /**
  108095. * Set the keys for camera movement forward.
  108096. */
  108097. keysForward: number[];
  108098. /**
  108099. * Get the keys for camera movement backward.
  108100. */
  108101. keysBackward: number[];
  108102. /**
  108103. * Get the keys for camera movement up.
  108104. */
  108105. /**
  108106. * Set the keys for camera movement up.
  108107. */
  108108. keysUp: number[];
  108109. /**
  108110. * Get the keys for camera movement down.
  108111. */
  108112. /**
  108113. * Set the keys for camera movement down.
  108114. */
  108115. keysDown: number[];
  108116. /**
  108117. * Get the keys for camera movement left.
  108118. */
  108119. /**
  108120. * Set the keys for camera movement left.
  108121. */
  108122. keysLeft: number[];
  108123. /**
  108124. * Set the keys for camera movement right.
  108125. */
  108126. /**
  108127. * Set the keys for camera movement right.
  108128. */
  108129. keysRight: number[];
  108130. /**
  108131. * Event raised when the camera collides with a mesh in the scene.
  108132. */
  108133. onCollide: (collidedMesh: AbstractMesh) => void;
  108134. private _collider;
  108135. private _needMoveForGravity;
  108136. private _oldPosition;
  108137. private _diffPosition;
  108138. private _newPosition;
  108139. /** @hidden */
  108140. _localDirection: Vector3;
  108141. /** @hidden */
  108142. _transformedDirection: Vector3;
  108143. /**
  108144. * Instantiates a FlyCamera.
  108145. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108146. * such as in a 3D Space Shooter or a Flight Simulator.
  108147. * @param name Define the name of the camera in the scene.
  108148. * @param position Define the starting position of the camera in the scene.
  108149. * @param scene Define the scene the camera belongs to.
  108150. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108151. */
  108152. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108153. /**
  108154. * Attach a control to the HTML DOM element.
  108155. * @param element Defines the element that listens to the input events.
  108156. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108157. */
  108158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108159. /**
  108160. * Detach a control from the HTML DOM element.
  108161. * The camera will stop reacting to that input.
  108162. * @param element Defines the element that listens to the input events.
  108163. */
  108164. detachControl(element: HTMLElement): void;
  108165. private _collisionMask;
  108166. /**
  108167. * Get the mask that the camera ignores in collision events.
  108168. */
  108169. /**
  108170. * Set the mask that the camera ignores in collision events.
  108171. */
  108172. collisionMask: number;
  108173. /** @hidden */
  108174. _collideWithWorld(displacement: Vector3): void;
  108175. /** @hidden */
  108176. private _onCollisionPositionChange;
  108177. /** @hidden */
  108178. _checkInputs(): void;
  108179. /** @hidden */
  108180. _decideIfNeedsToMove(): boolean;
  108181. /** @hidden */
  108182. _updatePosition(): void;
  108183. /**
  108184. * Restore the Roll to its target value at the rate specified.
  108185. * @param rate - Higher means slower restoring.
  108186. * @hidden
  108187. */
  108188. restoreRoll(rate: number): void;
  108189. /**
  108190. * Destroy the camera and release the current resources held by it.
  108191. */
  108192. dispose(): void;
  108193. /**
  108194. * Get the current object class name.
  108195. * @returns the class name.
  108196. */
  108197. getClassName(): string;
  108198. }
  108199. }
  108200. declare module BABYLON {
  108201. /**
  108202. * Listen to keyboard events to control the camera.
  108203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108204. */
  108205. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108206. /**
  108207. * Defines the camera the input is attached to.
  108208. */
  108209. camera: FlyCamera;
  108210. /**
  108211. * The list of keyboard keys used to control the forward move of the camera.
  108212. */
  108213. keysForward: number[];
  108214. /**
  108215. * The list of keyboard keys used to control the backward move of the camera.
  108216. */
  108217. keysBackward: number[];
  108218. /**
  108219. * The list of keyboard keys used to control the forward move of the camera.
  108220. */
  108221. keysUp: number[];
  108222. /**
  108223. * The list of keyboard keys used to control the backward move of the camera.
  108224. */
  108225. keysDown: number[];
  108226. /**
  108227. * The list of keyboard keys used to control the right strafe move of the camera.
  108228. */
  108229. keysRight: number[];
  108230. /**
  108231. * The list of keyboard keys used to control the left strafe move of the camera.
  108232. */
  108233. keysLeft: number[];
  108234. private _keys;
  108235. private _onCanvasBlurObserver;
  108236. private _onKeyboardObserver;
  108237. private _engine;
  108238. private _scene;
  108239. /**
  108240. * Attach the input controls to a specific dom element to get the input from.
  108241. * @param element Defines the element the controls should be listened from
  108242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108243. */
  108244. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108245. /**
  108246. * Detach the current controls from the specified dom element.
  108247. * @param element Defines the element to stop listening the inputs from
  108248. */
  108249. detachControl(element: Nullable<HTMLElement>): void;
  108250. /**
  108251. * Gets the class name of the current intput.
  108252. * @returns the class name
  108253. */
  108254. getClassName(): string;
  108255. /** @hidden */
  108256. _onLostFocus(e: FocusEvent): void;
  108257. /**
  108258. * Get the friendly name associated with the input class.
  108259. * @returns the input friendly name
  108260. */
  108261. getSimpleName(): string;
  108262. /**
  108263. * Update the current camera state depending on the inputs that have been used this frame.
  108264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108265. */
  108266. checkInputs(): void;
  108267. }
  108268. }
  108269. declare module BABYLON {
  108270. /**
  108271. * Manage the mouse wheel inputs to control a follow camera.
  108272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108273. */
  108274. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108275. /**
  108276. * Defines the camera the input is attached to.
  108277. */
  108278. camera: FollowCamera;
  108279. /**
  108280. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108281. */
  108282. axisControlRadius: boolean;
  108283. /**
  108284. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108285. */
  108286. axisControlHeight: boolean;
  108287. /**
  108288. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108289. */
  108290. axisControlRotation: boolean;
  108291. /**
  108292. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108293. * relation to mouseWheel events.
  108294. */
  108295. wheelPrecision: number;
  108296. /**
  108297. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108298. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108299. */
  108300. wheelDeltaPercentage: number;
  108301. private _wheel;
  108302. private _observer;
  108303. /**
  108304. * Attach the input controls to a specific dom element to get the input from.
  108305. * @param element Defines the element the controls should be listened from
  108306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108307. */
  108308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108309. /**
  108310. * Detach the current controls from the specified dom element.
  108311. * @param element Defines the element to stop listening the inputs from
  108312. */
  108313. detachControl(element: Nullable<HTMLElement>): void;
  108314. /**
  108315. * Gets the class name of the current intput.
  108316. * @returns the class name
  108317. */
  108318. getClassName(): string;
  108319. /**
  108320. * Get the friendly name associated with the input class.
  108321. * @returns the input friendly name
  108322. */
  108323. getSimpleName(): string;
  108324. }
  108325. }
  108326. declare module BABYLON {
  108327. /**
  108328. * Manage the pointers inputs to control an follow camera.
  108329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108330. */
  108331. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108332. /**
  108333. * Defines the camera the input is attached to.
  108334. */
  108335. camera: FollowCamera;
  108336. /**
  108337. * Gets the class name of the current input.
  108338. * @returns the class name
  108339. */
  108340. getClassName(): string;
  108341. /**
  108342. * Defines the pointer angular sensibility along the X axis or how fast is
  108343. * the camera rotating.
  108344. * A negative number will reverse the axis direction.
  108345. */
  108346. angularSensibilityX: number;
  108347. /**
  108348. * Defines the pointer angular sensibility along the Y axis or how fast is
  108349. * the camera rotating.
  108350. * A negative number will reverse the axis direction.
  108351. */
  108352. angularSensibilityY: number;
  108353. /**
  108354. * Defines the pointer pinch precision or how fast is the camera zooming.
  108355. * A negative number will reverse the axis direction.
  108356. */
  108357. pinchPrecision: number;
  108358. /**
  108359. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108360. * from 0.
  108361. * It defines the percentage of current camera.radius to use as delta when
  108362. * pinch zoom is used.
  108363. */
  108364. pinchDeltaPercentage: number;
  108365. /**
  108366. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108367. */
  108368. axisXControlRadius: boolean;
  108369. /**
  108370. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108371. */
  108372. axisXControlHeight: boolean;
  108373. /**
  108374. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108375. */
  108376. axisXControlRotation: boolean;
  108377. /**
  108378. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108379. */
  108380. axisYControlRadius: boolean;
  108381. /**
  108382. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108383. */
  108384. axisYControlHeight: boolean;
  108385. /**
  108386. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108387. */
  108388. axisYControlRotation: boolean;
  108389. /**
  108390. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108391. */
  108392. axisPinchControlRadius: boolean;
  108393. /**
  108394. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108395. */
  108396. axisPinchControlHeight: boolean;
  108397. /**
  108398. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108399. */
  108400. axisPinchControlRotation: boolean;
  108401. /**
  108402. * Log error messages if basic misconfiguration has occurred.
  108403. */
  108404. warningEnable: boolean;
  108405. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108406. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108407. private _warningCounter;
  108408. private _warning;
  108409. }
  108410. }
  108411. declare module BABYLON {
  108412. /**
  108413. * Default Inputs manager for the FollowCamera.
  108414. * It groups all the default supported inputs for ease of use.
  108415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108416. */
  108417. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108418. /**
  108419. * Instantiates a new FollowCameraInputsManager.
  108420. * @param camera Defines the camera the inputs belong to
  108421. */
  108422. constructor(camera: FollowCamera);
  108423. /**
  108424. * Add keyboard input support to the input manager.
  108425. * @returns the current input manager
  108426. */
  108427. addKeyboard(): FollowCameraInputsManager;
  108428. /**
  108429. * Add mouse wheel input support to the input manager.
  108430. * @returns the current input manager
  108431. */
  108432. addMouseWheel(): FollowCameraInputsManager;
  108433. /**
  108434. * Add pointers input support to the input manager.
  108435. * @returns the current input manager
  108436. */
  108437. addPointers(): FollowCameraInputsManager;
  108438. /**
  108439. * Add orientation input support to the input manager.
  108440. * @returns the current input manager
  108441. */
  108442. addVRDeviceOrientation(): FollowCameraInputsManager;
  108443. }
  108444. }
  108445. declare module BABYLON {
  108446. /**
  108447. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108448. * an arc rotate version arcFollowCamera are available.
  108449. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108450. */
  108451. export class FollowCamera extends TargetCamera {
  108452. /**
  108453. * Distance the follow camera should follow an object at
  108454. */
  108455. radius: number;
  108456. /**
  108457. * Minimum allowed distance of the camera to the axis of rotation
  108458. * (The camera can not get closer).
  108459. * This can help limiting how the Camera is able to move in the scene.
  108460. */
  108461. lowerRadiusLimit: Nullable<number>;
  108462. /**
  108463. * Maximum allowed distance of the camera to the axis of rotation
  108464. * (The camera can not get further).
  108465. * This can help limiting how the Camera is able to move in the scene.
  108466. */
  108467. upperRadiusLimit: Nullable<number>;
  108468. /**
  108469. * Define a rotation offset between the camera and the object it follows
  108470. */
  108471. rotationOffset: number;
  108472. /**
  108473. * Minimum allowed angle to camera position relative to target object.
  108474. * This can help limiting how the Camera is able to move in the scene.
  108475. */
  108476. lowerRotationOffsetLimit: Nullable<number>;
  108477. /**
  108478. * Maximum allowed angle to camera position relative to target object.
  108479. * This can help limiting how the Camera is able to move in the scene.
  108480. */
  108481. upperRotationOffsetLimit: Nullable<number>;
  108482. /**
  108483. * Define a height offset between the camera and the object it follows.
  108484. * It can help following an object from the top (like a car chaing a plane)
  108485. */
  108486. heightOffset: number;
  108487. /**
  108488. * Minimum allowed height of camera position relative to target object.
  108489. * This can help limiting how the Camera is able to move in the scene.
  108490. */
  108491. lowerHeightOffsetLimit: Nullable<number>;
  108492. /**
  108493. * Maximum allowed height of camera position relative to target object.
  108494. * This can help limiting how the Camera is able to move in the scene.
  108495. */
  108496. upperHeightOffsetLimit: Nullable<number>;
  108497. /**
  108498. * Define how fast the camera can accelerate to follow it s target.
  108499. */
  108500. cameraAcceleration: number;
  108501. /**
  108502. * Define the speed limit of the camera following an object.
  108503. */
  108504. maxCameraSpeed: number;
  108505. /**
  108506. * Define the target of the camera.
  108507. */
  108508. lockedTarget: Nullable<AbstractMesh>;
  108509. /**
  108510. * Defines the input associated with the camera.
  108511. */
  108512. inputs: FollowCameraInputsManager;
  108513. /**
  108514. * Instantiates the follow camera.
  108515. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108516. * @param name Define the name of the camera in the scene
  108517. * @param position Define the position of the camera
  108518. * @param scene Define the scene the camera belong to
  108519. * @param lockedTarget Define the target of the camera
  108520. */
  108521. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  108522. private _follow;
  108523. /**
  108524. * Attached controls to the current camera.
  108525. * @param element Defines the element the controls should be listened from
  108526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108527. */
  108528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108529. /**
  108530. * Detach the current controls from the camera.
  108531. * The camera will stop reacting to inputs.
  108532. * @param element Defines the element to stop listening the inputs from
  108533. */
  108534. detachControl(element: HTMLElement): void;
  108535. /** @hidden */
  108536. _checkInputs(): void;
  108537. private _checkLimits;
  108538. /**
  108539. * Gets the camera class name.
  108540. * @returns the class name
  108541. */
  108542. getClassName(): string;
  108543. }
  108544. /**
  108545. * Arc Rotate version of the follow camera.
  108546. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  108547. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108548. */
  108549. export class ArcFollowCamera extends TargetCamera {
  108550. /** The longitudinal angle of the camera */
  108551. alpha: number;
  108552. /** The latitudinal angle of the camera */
  108553. beta: number;
  108554. /** The radius of the camera from its target */
  108555. radius: number;
  108556. /** Define the camera target (the messh it should follow) */
  108557. target: Nullable<AbstractMesh>;
  108558. private _cartesianCoordinates;
  108559. /**
  108560. * Instantiates a new ArcFollowCamera
  108561. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  108562. * @param name Define the name of the camera
  108563. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  108564. * @param beta Define the rotation angle of the camera around the elevation axis
  108565. * @param radius Define the radius of the camera from its target point
  108566. * @param target Define the target of the camera
  108567. * @param scene Define the scene the camera belongs to
  108568. */
  108569. constructor(name: string,
  108570. /** The longitudinal angle of the camera */
  108571. alpha: number,
  108572. /** The latitudinal angle of the camera */
  108573. beta: number,
  108574. /** The radius of the camera from its target */
  108575. radius: number,
  108576. /** Define the camera target (the messh it should follow) */
  108577. target: Nullable<AbstractMesh>, scene: Scene);
  108578. private _follow;
  108579. /** @hidden */
  108580. _checkInputs(): void;
  108581. /**
  108582. * Returns the class name of the object.
  108583. * It is mostly used internally for serialization purposes.
  108584. */
  108585. getClassName(): string;
  108586. }
  108587. }
  108588. declare module BABYLON {
  108589. /**
  108590. * Manage the keyboard inputs to control the movement of a follow camera.
  108591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108592. */
  108593. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  108594. /**
  108595. * Defines the camera the input is attached to.
  108596. */
  108597. camera: FollowCamera;
  108598. /**
  108599. * Defines the list of key codes associated with the up action (increase heightOffset)
  108600. */
  108601. keysHeightOffsetIncr: number[];
  108602. /**
  108603. * Defines the list of key codes associated with the down action (decrease heightOffset)
  108604. */
  108605. keysHeightOffsetDecr: number[];
  108606. /**
  108607. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  108608. */
  108609. keysHeightOffsetModifierAlt: boolean;
  108610. /**
  108611. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  108612. */
  108613. keysHeightOffsetModifierCtrl: boolean;
  108614. /**
  108615. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  108616. */
  108617. keysHeightOffsetModifierShift: boolean;
  108618. /**
  108619. * Defines the list of key codes associated with the left action (increase rotationOffset)
  108620. */
  108621. keysRotationOffsetIncr: number[];
  108622. /**
  108623. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  108624. */
  108625. keysRotationOffsetDecr: number[];
  108626. /**
  108627. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  108628. */
  108629. keysRotationOffsetModifierAlt: boolean;
  108630. /**
  108631. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  108632. */
  108633. keysRotationOffsetModifierCtrl: boolean;
  108634. /**
  108635. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  108636. */
  108637. keysRotationOffsetModifierShift: boolean;
  108638. /**
  108639. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  108640. */
  108641. keysRadiusIncr: number[];
  108642. /**
  108643. * Defines the list of key codes associated with the zoom-out action (increase radius)
  108644. */
  108645. keysRadiusDecr: number[];
  108646. /**
  108647. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  108648. */
  108649. keysRadiusModifierAlt: boolean;
  108650. /**
  108651. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  108652. */
  108653. keysRadiusModifierCtrl: boolean;
  108654. /**
  108655. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  108656. */
  108657. keysRadiusModifierShift: boolean;
  108658. /**
  108659. * Defines the rate of change of heightOffset.
  108660. */
  108661. heightSensibility: number;
  108662. /**
  108663. * Defines the rate of change of rotationOffset.
  108664. */
  108665. rotationSensibility: number;
  108666. /**
  108667. * Defines the rate of change of radius.
  108668. */
  108669. radiusSensibility: number;
  108670. private _keys;
  108671. private _ctrlPressed;
  108672. private _altPressed;
  108673. private _shiftPressed;
  108674. private _onCanvasBlurObserver;
  108675. private _onKeyboardObserver;
  108676. private _engine;
  108677. private _scene;
  108678. /**
  108679. * Attach the input controls to a specific dom element to get the input from.
  108680. * @param element Defines the element the controls should be listened from
  108681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108682. */
  108683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108684. /**
  108685. * Detach the current controls from the specified dom element.
  108686. * @param element Defines the element to stop listening the inputs from
  108687. */
  108688. detachControl(element: Nullable<HTMLElement>): void;
  108689. /**
  108690. * Update the current camera state depending on the inputs that have been used this frame.
  108691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108692. */
  108693. checkInputs(): void;
  108694. /**
  108695. * Gets the class name of the current input.
  108696. * @returns the class name
  108697. */
  108698. getClassName(): string;
  108699. /**
  108700. * Get the friendly name associated with the input class.
  108701. * @returns the input friendly name
  108702. */
  108703. getSimpleName(): string;
  108704. /**
  108705. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108706. * allow modification of the heightOffset value.
  108707. */
  108708. private _modifierHeightOffset;
  108709. /**
  108710. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108711. * allow modification of the rotationOffset value.
  108712. */
  108713. private _modifierRotationOffset;
  108714. /**
  108715. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  108716. * allow modification of the radius value.
  108717. */
  108718. private _modifierRadius;
  108719. }
  108720. }
  108721. declare module BABYLON {
  108722. interface FreeCameraInputsManager {
  108723. /**
  108724. * @hidden
  108725. */
  108726. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  108727. /**
  108728. * Add orientation input support to the input manager.
  108729. * @returns the current input manager
  108730. */
  108731. addDeviceOrientation(): FreeCameraInputsManager;
  108732. }
  108733. /**
  108734. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  108735. * Screen rotation is taken into account.
  108736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108737. */
  108738. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  108739. private _camera;
  108740. private _screenOrientationAngle;
  108741. private _constantTranform;
  108742. private _screenQuaternion;
  108743. private _alpha;
  108744. private _beta;
  108745. private _gamma;
  108746. /**
  108747. * Can be used to detect if a device orientation sensor is availible on a device
  108748. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  108749. * @returns a promise that will resolve on orientation change
  108750. */
  108751. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  108752. /**
  108753. * @hidden
  108754. */
  108755. _onDeviceOrientationChangedObservable: Observable<void>;
  108756. /**
  108757. * Instantiates a new input
  108758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108759. */
  108760. constructor();
  108761. /**
  108762. * Define the camera controlled by the input.
  108763. */
  108764. camera: FreeCamera;
  108765. /**
  108766. * Attach the input controls to a specific dom element to get the input from.
  108767. * @param element Defines the element the controls should be listened from
  108768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108769. */
  108770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108771. private _orientationChanged;
  108772. private _deviceOrientation;
  108773. /**
  108774. * Detach the current controls from the specified dom element.
  108775. * @param element Defines the element to stop listening the inputs from
  108776. */
  108777. detachControl(element: Nullable<HTMLElement>): void;
  108778. /**
  108779. * Update the current camera state depending on the inputs that have been used this frame.
  108780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108781. */
  108782. checkInputs(): void;
  108783. /**
  108784. * Gets the class name of the current intput.
  108785. * @returns the class name
  108786. */
  108787. getClassName(): string;
  108788. /**
  108789. * Get the friendly name associated with the input class.
  108790. * @returns the input friendly name
  108791. */
  108792. getSimpleName(): string;
  108793. }
  108794. }
  108795. declare module BABYLON {
  108796. /**
  108797. * Manage the gamepad inputs to control a free camera.
  108798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108799. */
  108800. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  108801. /**
  108802. * Define the camera the input is attached to.
  108803. */
  108804. camera: FreeCamera;
  108805. /**
  108806. * Define the Gamepad controlling the input
  108807. */
  108808. gamepad: Nullable<Gamepad>;
  108809. /**
  108810. * Defines the gamepad rotation sensiblity.
  108811. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108812. */
  108813. gamepadAngularSensibility: number;
  108814. /**
  108815. * Defines the gamepad move sensiblity.
  108816. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108817. */
  108818. gamepadMoveSensibility: number;
  108819. private _yAxisScale;
  108820. /**
  108821. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108822. */
  108823. invertYAxis: boolean;
  108824. private _onGamepadConnectedObserver;
  108825. private _onGamepadDisconnectedObserver;
  108826. private _cameraTransform;
  108827. private _deltaTransform;
  108828. private _vector3;
  108829. private _vector2;
  108830. /**
  108831. * Attach the input controls to a specific dom element to get the input from.
  108832. * @param element Defines the element the controls should be listened from
  108833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108834. */
  108835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108836. /**
  108837. * Detach the current controls from the specified dom element.
  108838. * @param element Defines the element to stop listening the inputs from
  108839. */
  108840. detachControl(element: Nullable<HTMLElement>): void;
  108841. /**
  108842. * Update the current camera state depending on the inputs that have been used this frame.
  108843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108844. */
  108845. checkInputs(): void;
  108846. /**
  108847. * Gets the class name of the current intput.
  108848. * @returns the class name
  108849. */
  108850. getClassName(): string;
  108851. /**
  108852. * Get the friendly name associated with the input class.
  108853. * @returns the input friendly name
  108854. */
  108855. getSimpleName(): string;
  108856. }
  108857. }
  108858. declare module BABYLON {
  108859. /**
  108860. * Defines the potential axis of a Joystick
  108861. */
  108862. export enum JoystickAxis {
  108863. /** X axis */
  108864. X = 0,
  108865. /** Y axis */
  108866. Y = 1,
  108867. /** Z axis */
  108868. Z = 2
  108869. }
  108870. /**
  108871. * Class used to define virtual joystick (used in touch mode)
  108872. */
  108873. export class VirtualJoystick {
  108874. /**
  108875. * Gets or sets a boolean indicating that left and right values must be inverted
  108876. */
  108877. reverseLeftRight: boolean;
  108878. /**
  108879. * Gets or sets a boolean indicating that up and down values must be inverted
  108880. */
  108881. reverseUpDown: boolean;
  108882. /**
  108883. * Gets the offset value for the position (ie. the change of the position value)
  108884. */
  108885. deltaPosition: Vector3;
  108886. /**
  108887. * Gets a boolean indicating if the virtual joystick was pressed
  108888. */
  108889. pressed: boolean;
  108890. /**
  108891. * Canvas the virtual joystick will render onto, default z-index of this is 5
  108892. */
  108893. static Canvas: Nullable<HTMLCanvasElement>;
  108894. private static _globalJoystickIndex;
  108895. private static vjCanvasContext;
  108896. private static vjCanvasWidth;
  108897. private static vjCanvasHeight;
  108898. private static halfWidth;
  108899. private _action;
  108900. private _axisTargetedByLeftAndRight;
  108901. private _axisTargetedByUpAndDown;
  108902. private _joystickSensibility;
  108903. private _inversedSensibility;
  108904. private _joystickPointerID;
  108905. private _joystickColor;
  108906. private _joystickPointerPos;
  108907. private _joystickPreviousPointerPos;
  108908. private _joystickPointerStartPos;
  108909. private _deltaJoystickVector;
  108910. private _leftJoystick;
  108911. private _touches;
  108912. private _onPointerDownHandlerRef;
  108913. private _onPointerMoveHandlerRef;
  108914. private _onPointerUpHandlerRef;
  108915. private _onResize;
  108916. /**
  108917. * Creates a new virtual joystick
  108918. * @param leftJoystick defines that the joystick is for left hand (false by default)
  108919. */
  108920. constructor(leftJoystick?: boolean);
  108921. /**
  108922. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  108923. * @param newJoystickSensibility defines the new sensibility
  108924. */
  108925. setJoystickSensibility(newJoystickSensibility: number): void;
  108926. private _onPointerDown;
  108927. private _onPointerMove;
  108928. private _onPointerUp;
  108929. /**
  108930. * Change the color of the virtual joystick
  108931. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  108932. */
  108933. setJoystickColor(newColor: string): void;
  108934. /**
  108935. * Defines a callback to call when the joystick is touched
  108936. * @param action defines the callback
  108937. */
  108938. setActionOnTouch(action: () => any): void;
  108939. /**
  108940. * Defines which axis you'd like to control for left & right
  108941. * @param axis defines the axis to use
  108942. */
  108943. setAxisForLeftRight(axis: JoystickAxis): void;
  108944. /**
  108945. * Defines which axis you'd like to control for up & down
  108946. * @param axis defines the axis to use
  108947. */
  108948. setAxisForUpDown(axis: JoystickAxis): void;
  108949. private _drawVirtualJoystick;
  108950. /**
  108951. * Release internal HTML canvas
  108952. */
  108953. releaseCanvas(): void;
  108954. }
  108955. }
  108956. declare module BABYLON {
  108957. interface FreeCameraInputsManager {
  108958. /**
  108959. * Add virtual joystick input support to the input manager.
  108960. * @returns the current input manager
  108961. */
  108962. addVirtualJoystick(): FreeCameraInputsManager;
  108963. }
  108964. /**
  108965. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  108966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108967. */
  108968. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  108969. /**
  108970. * Defines the camera the input is attached to.
  108971. */
  108972. camera: FreeCamera;
  108973. private _leftjoystick;
  108974. private _rightjoystick;
  108975. /**
  108976. * Gets the left stick of the virtual joystick.
  108977. * @returns The virtual Joystick
  108978. */
  108979. getLeftJoystick(): VirtualJoystick;
  108980. /**
  108981. * Gets the right stick of the virtual joystick.
  108982. * @returns The virtual Joystick
  108983. */
  108984. getRightJoystick(): VirtualJoystick;
  108985. /**
  108986. * Update the current camera state depending on the inputs that have been used this frame.
  108987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108988. */
  108989. checkInputs(): void;
  108990. /**
  108991. * Attach the input controls to a specific dom element to get the input from.
  108992. * @param element Defines the element the controls should be listened from
  108993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108994. */
  108995. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108996. /**
  108997. * Detach the current controls from the specified dom element.
  108998. * @param element Defines the element to stop listening the inputs from
  108999. */
  109000. detachControl(element: Nullable<HTMLElement>): void;
  109001. /**
  109002. * Gets the class name of the current intput.
  109003. * @returns the class name
  109004. */
  109005. getClassName(): string;
  109006. /**
  109007. * Get the friendly name associated with the input class.
  109008. * @returns the input friendly name
  109009. */
  109010. getSimpleName(): string;
  109011. }
  109012. }
  109013. declare module BABYLON {
  109014. /**
  109015. * This represents a FPS type of camera controlled by touch.
  109016. * This is like a universal camera minus the Gamepad controls.
  109017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109018. */
  109019. export class TouchCamera extends FreeCamera {
  109020. /**
  109021. * Defines the touch sensibility for rotation.
  109022. * The higher the faster.
  109023. */
  109024. touchAngularSensibility: number;
  109025. /**
  109026. * Defines the touch sensibility for move.
  109027. * The higher the faster.
  109028. */
  109029. touchMoveSensibility: number;
  109030. /**
  109031. * Instantiates a new touch camera.
  109032. * This represents a FPS type of camera controlled by touch.
  109033. * This is like a universal camera minus the Gamepad controls.
  109034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109035. * @param name Define the name of the camera in the scene
  109036. * @param position Define the start position of the camera in the scene
  109037. * @param scene Define the scene the camera belongs to
  109038. */
  109039. constructor(name: string, position: Vector3, scene: Scene);
  109040. /**
  109041. * Gets the current object class name.
  109042. * @return the class name
  109043. */
  109044. getClassName(): string;
  109045. /** @hidden */
  109046. _setupInputs(): void;
  109047. }
  109048. }
  109049. declare module BABYLON {
  109050. /**
  109051. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109052. * being tilted forward or back and left or right.
  109053. */
  109054. export class DeviceOrientationCamera extends FreeCamera {
  109055. private _initialQuaternion;
  109056. private _quaternionCache;
  109057. private _tmpDragQuaternion;
  109058. private _disablePointerInputWhenUsingDeviceOrientation;
  109059. /**
  109060. * Creates a new device orientation camera
  109061. * @param name The name of the camera
  109062. * @param position The start position camera
  109063. * @param scene The scene the camera belongs to
  109064. */
  109065. constructor(name: string, position: Vector3, scene: Scene);
  109066. /**
  109067. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109068. */
  109069. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109070. private _dragFactor;
  109071. /**
  109072. * Enabled turning on the y axis when the orientation sensor is active
  109073. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109074. */
  109075. enableHorizontalDragging(dragFactor?: number): void;
  109076. /**
  109077. * Gets the current instance class name ("DeviceOrientationCamera").
  109078. * This helps avoiding instanceof at run time.
  109079. * @returns the class name
  109080. */
  109081. getClassName(): string;
  109082. /**
  109083. * @hidden
  109084. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109085. */
  109086. _checkInputs(): void;
  109087. /**
  109088. * Reset the camera to its default orientation on the specified axis only.
  109089. * @param axis The axis to reset
  109090. */
  109091. resetToCurrentRotation(axis?: Axis): void;
  109092. }
  109093. }
  109094. declare module BABYLON {
  109095. /**
  109096. * Defines supported buttons for XBox360 compatible gamepads
  109097. */
  109098. export enum Xbox360Button {
  109099. /** A */
  109100. A = 0,
  109101. /** B */
  109102. B = 1,
  109103. /** X */
  109104. X = 2,
  109105. /** Y */
  109106. Y = 3,
  109107. /** Start */
  109108. Start = 4,
  109109. /** Back */
  109110. Back = 5,
  109111. /** Left button */
  109112. LB = 6,
  109113. /** Right button */
  109114. RB = 7,
  109115. /** Left stick */
  109116. LeftStick = 8,
  109117. /** Right stick */
  109118. RightStick = 9
  109119. }
  109120. /** Defines values for XBox360 DPad */
  109121. export enum Xbox360Dpad {
  109122. /** Up */
  109123. Up = 0,
  109124. /** Down */
  109125. Down = 1,
  109126. /** Left */
  109127. Left = 2,
  109128. /** Right */
  109129. Right = 3
  109130. }
  109131. /**
  109132. * Defines a XBox360 gamepad
  109133. */
  109134. export class Xbox360Pad extends Gamepad {
  109135. private _leftTrigger;
  109136. private _rightTrigger;
  109137. private _onlefttriggerchanged;
  109138. private _onrighttriggerchanged;
  109139. private _onbuttondown;
  109140. private _onbuttonup;
  109141. private _ondpaddown;
  109142. private _ondpadup;
  109143. /** Observable raised when a button is pressed */
  109144. onButtonDownObservable: Observable<Xbox360Button>;
  109145. /** Observable raised when a button is released */
  109146. onButtonUpObservable: Observable<Xbox360Button>;
  109147. /** Observable raised when a pad is pressed */
  109148. onPadDownObservable: Observable<Xbox360Dpad>;
  109149. /** Observable raised when a pad is released */
  109150. onPadUpObservable: Observable<Xbox360Dpad>;
  109151. private _buttonA;
  109152. private _buttonB;
  109153. private _buttonX;
  109154. private _buttonY;
  109155. private _buttonBack;
  109156. private _buttonStart;
  109157. private _buttonLB;
  109158. private _buttonRB;
  109159. private _buttonLeftStick;
  109160. private _buttonRightStick;
  109161. private _dPadUp;
  109162. private _dPadDown;
  109163. private _dPadLeft;
  109164. private _dPadRight;
  109165. private _isXboxOnePad;
  109166. /**
  109167. * Creates a new XBox360 gamepad object
  109168. * @param id defines the id of this gamepad
  109169. * @param index defines its index
  109170. * @param gamepad defines the internal HTML gamepad object
  109171. * @param xboxOne defines if it is a XBox One gamepad
  109172. */
  109173. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109174. /**
  109175. * Defines the callback to call when left trigger is pressed
  109176. * @param callback defines the callback to use
  109177. */
  109178. onlefttriggerchanged(callback: (value: number) => void): void;
  109179. /**
  109180. * Defines the callback to call when right trigger is pressed
  109181. * @param callback defines the callback to use
  109182. */
  109183. onrighttriggerchanged(callback: (value: number) => void): void;
  109184. /**
  109185. * Gets the left trigger value
  109186. */
  109187. /**
  109188. * Sets the left trigger value
  109189. */
  109190. leftTrigger: number;
  109191. /**
  109192. * Gets the right trigger value
  109193. */
  109194. /**
  109195. * Sets the right trigger value
  109196. */
  109197. rightTrigger: number;
  109198. /**
  109199. * Defines the callback to call when a button is pressed
  109200. * @param callback defines the callback to use
  109201. */
  109202. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109203. /**
  109204. * Defines the callback to call when a button is released
  109205. * @param callback defines the callback to use
  109206. */
  109207. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109208. /**
  109209. * Defines the callback to call when a pad is pressed
  109210. * @param callback defines the callback to use
  109211. */
  109212. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109213. /**
  109214. * Defines the callback to call when a pad is released
  109215. * @param callback defines the callback to use
  109216. */
  109217. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109218. private _setButtonValue;
  109219. private _setDPadValue;
  109220. /**
  109221. * Gets the value of the `A` button
  109222. */
  109223. /**
  109224. * Sets the value of the `A` button
  109225. */
  109226. buttonA: number;
  109227. /**
  109228. * Gets the value of the `B` button
  109229. */
  109230. /**
  109231. * Sets the value of the `B` button
  109232. */
  109233. buttonB: number;
  109234. /**
  109235. * Gets the value of the `X` button
  109236. */
  109237. /**
  109238. * Sets the value of the `X` button
  109239. */
  109240. buttonX: number;
  109241. /**
  109242. * Gets the value of the `Y` button
  109243. */
  109244. /**
  109245. * Sets the value of the `Y` button
  109246. */
  109247. buttonY: number;
  109248. /**
  109249. * Gets the value of the `Start` button
  109250. */
  109251. /**
  109252. * Sets the value of the `Start` button
  109253. */
  109254. buttonStart: number;
  109255. /**
  109256. * Gets the value of the `Back` button
  109257. */
  109258. /**
  109259. * Sets the value of the `Back` button
  109260. */
  109261. buttonBack: number;
  109262. /**
  109263. * Gets the value of the `Left` button
  109264. */
  109265. /**
  109266. * Sets the value of the `Left` button
  109267. */
  109268. buttonLB: number;
  109269. /**
  109270. * Gets the value of the `Right` button
  109271. */
  109272. /**
  109273. * Sets the value of the `Right` button
  109274. */
  109275. buttonRB: number;
  109276. /**
  109277. * Gets the value of the Left joystick
  109278. */
  109279. /**
  109280. * Sets the value of the Left joystick
  109281. */
  109282. buttonLeftStick: number;
  109283. /**
  109284. * Gets the value of the Right joystick
  109285. */
  109286. /**
  109287. * Sets the value of the Right joystick
  109288. */
  109289. buttonRightStick: number;
  109290. /**
  109291. * Gets the value of D-pad up
  109292. */
  109293. /**
  109294. * Sets the value of D-pad up
  109295. */
  109296. dPadUp: number;
  109297. /**
  109298. * Gets the value of D-pad down
  109299. */
  109300. /**
  109301. * Sets the value of D-pad down
  109302. */
  109303. dPadDown: number;
  109304. /**
  109305. * Gets the value of D-pad left
  109306. */
  109307. /**
  109308. * Sets the value of D-pad left
  109309. */
  109310. dPadLeft: number;
  109311. /**
  109312. * Gets the value of D-pad right
  109313. */
  109314. /**
  109315. * Sets the value of D-pad right
  109316. */
  109317. dPadRight: number;
  109318. /**
  109319. * Force the gamepad to synchronize with device values
  109320. */
  109321. update(): void;
  109322. /**
  109323. * Disposes the gamepad
  109324. */
  109325. dispose(): void;
  109326. }
  109327. }
  109328. declare module BABYLON {
  109329. /**
  109330. * Defines supported buttons for DualShock compatible gamepads
  109331. */
  109332. export enum DualShockButton {
  109333. /** Cross */
  109334. Cross = 0,
  109335. /** Circle */
  109336. Circle = 1,
  109337. /** Square */
  109338. Square = 2,
  109339. /** Triangle */
  109340. Triangle = 3,
  109341. /** Options */
  109342. Options = 4,
  109343. /** Share */
  109344. Share = 5,
  109345. /** L1 */
  109346. L1 = 6,
  109347. /** R1 */
  109348. R1 = 7,
  109349. /** Left stick */
  109350. LeftStick = 8,
  109351. /** Right stick */
  109352. RightStick = 9
  109353. }
  109354. /** Defines values for DualShock DPad */
  109355. export enum DualShockDpad {
  109356. /** Up */
  109357. Up = 0,
  109358. /** Down */
  109359. Down = 1,
  109360. /** Left */
  109361. Left = 2,
  109362. /** Right */
  109363. Right = 3
  109364. }
  109365. /**
  109366. * Defines a DualShock gamepad
  109367. */
  109368. export class DualShockPad extends Gamepad {
  109369. private _leftTrigger;
  109370. private _rightTrigger;
  109371. private _onlefttriggerchanged;
  109372. private _onrighttriggerchanged;
  109373. private _onbuttondown;
  109374. private _onbuttonup;
  109375. private _ondpaddown;
  109376. private _ondpadup;
  109377. /** Observable raised when a button is pressed */
  109378. onButtonDownObservable: Observable<DualShockButton>;
  109379. /** Observable raised when a button is released */
  109380. onButtonUpObservable: Observable<DualShockButton>;
  109381. /** Observable raised when a pad is pressed */
  109382. onPadDownObservable: Observable<DualShockDpad>;
  109383. /** Observable raised when a pad is released */
  109384. onPadUpObservable: Observable<DualShockDpad>;
  109385. private _buttonCross;
  109386. private _buttonCircle;
  109387. private _buttonSquare;
  109388. private _buttonTriangle;
  109389. private _buttonShare;
  109390. private _buttonOptions;
  109391. private _buttonL1;
  109392. private _buttonR1;
  109393. private _buttonLeftStick;
  109394. private _buttonRightStick;
  109395. private _dPadUp;
  109396. private _dPadDown;
  109397. private _dPadLeft;
  109398. private _dPadRight;
  109399. /**
  109400. * Creates a new DualShock gamepad object
  109401. * @param id defines the id of this gamepad
  109402. * @param index defines its index
  109403. * @param gamepad defines the internal HTML gamepad object
  109404. */
  109405. constructor(id: string, index: number, gamepad: any);
  109406. /**
  109407. * Defines the callback to call when left trigger is pressed
  109408. * @param callback defines the callback to use
  109409. */
  109410. onlefttriggerchanged(callback: (value: number) => void): void;
  109411. /**
  109412. * Defines the callback to call when right trigger is pressed
  109413. * @param callback defines the callback to use
  109414. */
  109415. onrighttriggerchanged(callback: (value: number) => void): void;
  109416. /**
  109417. * Gets the left trigger value
  109418. */
  109419. /**
  109420. * Sets the left trigger value
  109421. */
  109422. leftTrigger: number;
  109423. /**
  109424. * Gets the right trigger value
  109425. */
  109426. /**
  109427. * Sets the right trigger value
  109428. */
  109429. rightTrigger: number;
  109430. /**
  109431. * Defines the callback to call when a button is pressed
  109432. * @param callback defines the callback to use
  109433. */
  109434. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109435. /**
  109436. * Defines the callback to call when a button is released
  109437. * @param callback defines the callback to use
  109438. */
  109439. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109440. /**
  109441. * Defines the callback to call when a pad is pressed
  109442. * @param callback defines the callback to use
  109443. */
  109444. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109445. /**
  109446. * Defines the callback to call when a pad is released
  109447. * @param callback defines the callback to use
  109448. */
  109449. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  109450. private _setButtonValue;
  109451. private _setDPadValue;
  109452. /**
  109453. * Gets the value of the `Cross` button
  109454. */
  109455. /**
  109456. * Sets the value of the `Cross` button
  109457. */
  109458. buttonCross: number;
  109459. /**
  109460. * Gets the value of the `Circle` button
  109461. */
  109462. /**
  109463. * Sets the value of the `Circle` button
  109464. */
  109465. buttonCircle: number;
  109466. /**
  109467. * Gets the value of the `Square` button
  109468. */
  109469. /**
  109470. * Sets the value of the `Square` button
  109471. */
  109472. buttonSquare: number;
  109473. /**
  109474. * Gets the value of the `Triangle` button
  109475. */
  109476. /**
  109477. * Sets the value of the `Triangle` button
  109478. */
  109479. buttonTriangle: number;
  109480. /**
  109481. * Gets the value of the `Options` button
  109482. */
  109483. /**
  109484. * Sets the value of the `Options` button
  109485. */
  109486. buttonOptions: number;
  109487. /**
  109488. * Gets the value of the `Share` button
  109489. */
  109490. /**
  109491. * Sets the value of the `Share` button
  109492. */
  109493. buttonShare: number;
  109494. /**
  109495. * Gets the value of the `L1` button
  109496. */
  109497. /**
  109498. * Sets the value of the `L1` button
  109499. */
  109500. buttonL1: number;
  109501. /**
  109502. * Gets the value of the `R1` button
  109503. */
  109504. /**
  109505. * Sets the value of the `R1` button
  109506. */
  109507. buttonR1: number;
  109508. /**
  109509. * Gets the value of the Left joystick
  109510. */
  109511. /**
  109512. * Sets the value of the Left joystick
  109513. */
  109514. buttonLeftStick: number;
  109515. /**
  109516. * Gets the value of the Right joystick
  109517. */
  109518. /**
  109519. * Sets the value of the Right joystick
  109520. */
  109521. buttonRightStick: number;
  109522. /**
  109523. * Gets the value of D-pad up
  109524. */
  109525. /**
  109526. * Sets the value of D-pad up
  109527. */
  109528. dPadUp: number;
  109529. /**
  109530. * Gets the value of D-pad down
  109531. */
  109532. /**
  109533. * Sets the value of D-pad down
  109534. */
  109535. dPadDown: number;
  109536. /**
  109537. * Gets the value of D-pad left
  109538. */
  109539. /**
  109540. * Sets the value of D-pad left
  109541. */
  109542. dPadLeft: number;
  109543. /**
  109544. * Gets the value of D-pad right
  109545. */
  109546. /**
  109547. * Sets the value of D-pad right
  109548. */
  109549. dPadRight: number;
  109550. /**
  109551. * Force the gamepad to synchronize with device values
  109552. */
  109553. update(): void;
  109554. /**
  109555. * Disposes the gamepad
  109556. */
  109557. dispose(): void;
  109558. }
  109559. }
  109560. declare module BABYLON {
  109561. /**
  109562. * Manager for handling gamepads
  109563. */
  109564. export class GamepadManager {
  109565. private _scene?;
  109566. private _babylonGamepads;
  109567. private _oneGamepadConnected;
  109568. /** @hidden */
  109569. _isMonitoring: boolean;
  109570. private _gamepadEventSupported;
  109571. private _gamepadSupport;
  109572. /**
  109573. * observable to be triggered when the gamepad controller has been connected
  109574. */
  109575. onGamepadConnectedObservable: Observable<Gamepad>;
  109576. /**
  109577. * observable to be triggered when the gamepad controller has been disconnected
  109578. */
  109579. onGamepadDisconnectedObservable: Observable<Gamepad>;
  109580. private _onGamepadConnectedEvent;
  109581. private _onGamepadDisconnectedEvent;
  109582. /**
  109583. * Initializes the gamepad manager
  109584. * @param _scene BabylonJS scene
  109585. */
  109586. constructor(_scene?: Scene | undefined);
  109587. /**
  109588. * The gamepads in the game pad manager
  109589. */
  109590. readonly gamepads: Gamepad[];
  109591. /**
  109592. * Get the gamepad controllers based on type
  109593. * @param type The type of gamepad controller
  109594. * @returns Nullable gamepad
  109595. */
  109596. getGamepadByType(type?: number): Nullable<Gamepad>;
  109597. /**
  109598. * Disposes the gamepad manager
  109599. */
  109600. dispose(): void;
  109601. private _addNewGamepad;
  109602. private _startMonitoringGamepads;
  109603. private _stopMonitoringGamepads;
  109604. /** @hidden */
  109605. _checkGamepadsStatus(): void;
  109606. private _updateGamepadObjects;
  109607. }
  109608. }
  109609. declare module BABYLON {
  109610. interface Scene {
  109611. /** @hidden */
  109612. _gamepadManager: Nullable<GamepadManager>;
  109613. /**
  109614. * Gets the gamepad manager associated with the scene
  109615. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  109616. */
  109617. gamepadManager: GamepadManager;
  109618. }
  109619. /**
  109620. * Interface representing a free camera inputs manager
  109621. */
  109622. interface FreeCameraInputsManager {
  109623. /**
  109624. * Adds gamepad input support to the FreeCameraInputsManager.
  109625. * @returns the FreeCameraInputsManager
  109626. */
  109627. addGamepad(): FreeCameraInputsManager;
  109628. }
  109629. /**
  109630. * Interface representing an arc rotate camera inputs manager
  109631. */
  109632. interface ArcRotateCameraInputsManager {
  109633. /**
  109634. * Adds gamepad input support to the ArcRotateCamera InputManager.
  109635. * @returns the camera inputs manager
  109636. */
  109637. addGamepad(): ArcRotateCameraInputsManager;
  109638. }
  109639. /**
  109640. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  109641. */
  109642. export class GamepadSystemSceneComponent implements ISceneComponent {
  109643. /**
  109644. * The component name helpfull to identify the component in the list of scene components.
  109645. */
  109646. readonly name: string;
  109647. /**
  109648. * The scene the component belongs to.
  109649. */
  109650. scene: Scene;
  109651. /**
  109652. * Creates a new instance of the component for the given scene
  109653. * @param scene Defines the scene to register the component in
  109654. */
  109655. constructor(scene: Scene);
  109656. /**
  109657. * Registers the component in a given scene
  109658. */
  109659. register(): void;
  109660. /**
  109661. * Rebuilds the elements related to this component in case of
  109662. * context lost for instance.
  109663. */
  109664. rebuild(): void;
  109665. /**
  109666. * Disposes the component and the associated ressources
  109667. */
  109668. dispose(): void;
  109669. private _beforeCameraUpdate;
  109670. }
  109671. }
  109672. declare module BABYLON {
  109673. /**
  109674. * 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,
  109675. * which still works and will still be found in many Playgrounds.
  109676. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109677. */
  109678. export class UniversalCamera extends TouchCamera {
  109679. /**
  109680. * Defines the gamepad rotation sensiblity.
  109681. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109682. */
  109683. gamepadAngularSensibility: number;
  109684. /**
  109685. * Defines the gamepad move sensiblity.
  109686. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109687. */
  109688. gamepadMoveSensibility: number;
  109689. /**
  109690. * 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,
  109691. * which still works and will still be found in many Playgrounds.
  109692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109693. * @param name Define the name of the camera in the scene
  109694. * @param position Define the start position of the camera in the scene
  109695. * @param scene Define the scene the camera belongs to
  109696. */
  109697. constructor(name: string, position: Vector3, scene: Scene);
  109698. /**
  109699. * Gets the current object class name.
  109700. * @return the class name
  109701. */
  109702. getClassName(): string;
  109703. }
  109704. }
  109705. declare module BABYLON {
  109706. /**
  109707. * This represents a FPS type of camera. This is only here for back compat purpose.
  109708. * Please use the UniversalCamera instead as both are identical.
  109709. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109710. */
  109711. export class GamepadCamera extends UniversalCamera {
  109712. /**
  109713. * Instantiates a new Gamepad Camera
  109714. * This represents a FPS type of camera. This is only here for back compat purpose.
  109715. * Please use the UniversalCamera instead as both are identical.
  109716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109717. * @param name Define the name of the camera in the scene
  109718. * @param position Define the start position of the camera in the scene
  109719. * @param scene Define the scene the camera belongs to
  109720. */
  109721. constructor(name: string, position: Vector3, scene: Scene);
  109722. /**
  109723. * Gets the current object class name.
  109724. * @return the class name
  109725. */
  109726. getClassName(): string;
  109727. }
  109728. }
  109729. declare module BABYLON {
  109730. /** @hidden */
  109731. export var passPixelShader: {
  109732. name: string;
  109733. shader: string;
  109734. };
  109735. }
  109736. declare module BABYLON {
  109737. /** @hidden */
  109738. export var passCubePixelShader: {
  109739. name: string;
  109740. shader: string;
  109741. };
  109742. }
  109743. declare module BABYLON {
  109744. /**
  109745. * PassPostProcess which produces an output the same as it's input
  109746. */
  109747. export class PassPostProcess extends PostProcess {
  109748. /**
  109749. * Creates the PassPostProcess
  109750. * @param name The name of the effect.
  109751. * @param options The required width/height ratio to downsize to before computing the render pass.
  109752. * @param camera The camera to apply the render pass to.
  109753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109754. * @param engine The engine which the post process will be applied. (default: current engine)
  109755. * @param reusable If the post process can be reused on the same frame. (default: false)
  109756. * @param textureType The type of texture to be used when performing the post processing.
  109757. * @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)
  109758. */
  109759. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109760. }
  109761. /**
  109762. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  109763. */
  109764. export class PassCubePostProcess extends PostProcess {
  109765. private _face;
  109766. /**
  109767. * Gets or sets the cube face to display.
  109768. * * 0 is +X
  109769. * * 1 is -X
  109770. * * 2 is +Y
  109771. * * 3 is -Y
  109772. * * 4 is +Z
  109773. * * 5 is -Z
  109774. */
  109775. face: number;
  109776. /**
  109777. * Creates the PassCubePostProcess
  109778. * @param name The name of the effect.
  109779. * @param options The required width/height ratio to downsize to before computing the render pass.
  109780. * @param camera The camera to apply the render pass to.
  109781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109782. * @param engine The engine which the post process will be applied. (default: current engine)
  109783. * @param reusable If the post process can be reused on the same frame. (default: false)
  109784. * @param textureType The type of texture to be used when performing the post processing.
  109785. * @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)
  109786. */
  109787. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109788. }
  109789. }
  109790. declare module BABYLON {
  109791. /** @hidden */
  109792. export var anaglyphPixelShader: {
  109793. name: string;
  109794. shader: string;
  109795. };
  109796. }
  109797. declare module BABYLON {
  109798. /**
  109799. * Postprocess used to generate anaglyphic rendering
  109800. */
  109801. export class AnaglyphPostProcess extends PostProcess {
  109802. private _passedProcess;
  109803. /**
  109804. * Creates a new AnaglyphPostProcess
  109805. * @param name defines postprocess name
  109806. * @param options defines creation options or target ratio scale
  109807. * @param rigCameras defines cameras using this postprocess
  109808. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  109809. * @param engine defines hosting engine
  109810. * @param reusable defines if the postprocess will be reused multiple times per frame
  109811. */
  109812. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  109813. }
  109814. }
  109815. declare module BABYLON {
  109816. /**
  109817. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  109818. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109819. */
  109820. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  109821. /**
  109822. * Creates a new AnaglyphArcRotateCamera
  109823. * @param name defines camera name
  109824. * @param alpha defines alpha angle (in radians)
  109825. * @param beta defines beta angle (in radians)
  109826. * @param radius defines radius
  109827. * @param target defines camera target
  109828. * @param interaxialDistance defines distance between each color axis
  109829. * @param scene defines the hosting scene
  109830. */
  109831. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  109832. /**
  109833. * Gets camera class name
  109834. * @returns AnaglyphArcRotateCamera
  109835. */
  109836. getClassName(): string;
  109837. }
  109838. }
  109839. declare module BABYLON {
  109840. /**
  109841. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  109842. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109843. */
  109844. export class AnaglyphFreeCamera extends FreeCamera {
  109845. /**
  109846. * Creates a new AnaglyphFreeCamera
  109847. * @param name defines camera name
  109848. * @param position defines initial position
  109849. * @param interaxialDistance defines distance between each color axis
  109850. * @param scene defines the hosting scene
  109851. */
  109852. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109853. /**
  109854. * Gets camera class name
  109855. * @returns AnaglyphFreeCamera
  109856. */
  109857. getClassName(): string;
  109858. }
  109859. }
  109860. declare module BABYLON {
  109861. /**
  109862. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  109863. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109864. */
  109865. export class AnaglyphGamepadCamera extends GamepadCamera {
  109866. /**
  109867. * Creates a new AnaglyphGamepadCamera
  109868. * @param name defines camera name
  109869. * @param position defines initial position
  109870. * @param interaxialDistance defines distance between each color axis
  109871. * @param scene defines the hosting scene
  109872. */
  109873. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109874. /**
  109875. * Gets camera class name
  109876. * @returns AnaglyphGamepadCamera
  109877. */
  109878. getClassName(): string;
  109879. }
  109880. }
  109881. declare module BABYLON {
  109882. /**
  109883. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  109884. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  109885. */
  109886. export class AnaglyphUniversalCamera extends UniversalCamera {
  109887. /**
  109888. * Creates a new AnaglyphUniversalCamera
  109889. * @param name defines camera name
  109890. * @param position defines initial position
  109891. * @param interaxialDistance defines distance between each color axis
  109892. * @param scene defines the hosting scene
  109893. */
  109894. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  109895. /**
  109896. * Gets camera class name
  109897. * @returns AnaglyphUniversalCamera
  109898. */
  109899. getClassName(): string;
  109900. }
  109901. }
  109902. declare module BABYLON {
  109903. /** @hidden */
  109904. export var stereoscopicInterlacePixelShader: {
  109905. name: string;
  109906. shader: string;
  109907. };
  109908. }
  109909. declare module BABYLON {
  109910. /**
  109911. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  109912. */
  109913. export class StereoscopicInterlacePostProcess extends PostProcess {
  109914. private _stepSize;
  109915. private _passedProcess;
  109916. /**
  109917. * Initializes a StereoscopicInterlacePostProcess
  109918. * @param name The name of the effect.
  109919. * @param rigCameras The rig cameras to be appled to the post process
  109920. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  109921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109922. * @param engine The engine which the post process will be applied. (default: current engine)
  109923. * @param reusable If the post process can be reused on the same frame. (default: false)
  109924. */
  109925. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109926. }
  109927. }
  109928. declare module BABYLON {
  109929. /**
  109930. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  109931. * @see http://doc.babylonjs.com/features/cameras
  109932. */
  109933. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  109934. /**
  109935. * Creates a new StereoscopicArcRotateCamera
  109936. * @param name defines camera name
  109937. * @param alpha defines alpha angle (in radians)
  109938. * @param beta defines beta angle (in radians)
  109939. * @param radius defines radius
  109940. * @param target defines camera target
  109941. * @param interaxialDistance defines distance between each color axis
  109942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109943. * @param scene defines the hosting scene
  109944. */
  109945. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109946. /**
  109947. * Gets camera class name
  109948. * @returns StereoscopicArcRotateCamera
  109949. */
  109950. getClassName(): string;
  109951. }
  109952. }
  109953. declare module BABYLON {
  109954. /**
  109955. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  109956. * @see http://doc.babylonjs.com/features/cameras
  109957. */
  109958. export class StereoscopicFreeCamera extends FreeCamera {
  109959. /**
  109960. * Creates a new StereoscopicFreeCamera
  109961. * @param name defines camera name
  109962. * @param position defines initial position
  109963. * @param interaxialDistance defines distance between each color axis
  109964. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109965. * @param scene defines the hosting scene
  109966. */
  109967. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109968. /**
  109969. * Gets camera class name
  109970. * @returns StereoscopicFreeCamera
  109971. */
  109972. getClassName(): string;
  109973. }
  109974. }
  109975. declare module BABYLON {
  109976. /**
  109977. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  109978. * @see http://doc.babylonjs.com/features/cameras
  109979. */
  109980. export class StereoscopicGamepadCamera extends GamepadCamera {
  109981. /**
  109982. * Creates a new StereoscopicGamepadCamera
  109983. * @param name defines camera name
  109984. * @param position defines initial position
  109985. * @param interaxialDistance defines distance between each color axis
  109986. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  109987. * @param scene defines the hosting scene
  109988. */
  109989. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  109990. /**
  109991. * Gets camera class name
  109992. * @returns StereoscopicGamepadCamera
  109993. */
  109994. getClassName(): string;
  109995. }
  109996. }
  109997. declare module BABYLON {
  109998. /**
  109999. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110000. * @see http://doc.babylonjs.com/features/cameras
  110001. */
  110002. export class StereoscopicUniversalCamera extends UniversalCamera {
  110003. /**
  110004. * Creates a new StereoscopicUniversalCamera
  110005. * @param name defines camera name
  110006. * @param position defines initial position
  110007. * @param interaxialDistance defines distance between each color axis
  110008. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110009. * @param scene defines the hosting scene
  110010. */
  110011. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110012. /**
  110013. * Gets camera class name
  110014. * @returns StereoscopicUniversalCamera
  110015. */
  110016. getClassName(): string;
  110017. }
  110018. }
  110019. declare module BABYLON {
  110020. /**
  110021. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110022. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110023. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110024. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110025. */
  110026. export class VirtualJoysticksCamera extends FreeCamera {
  110027. /**
  110028. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110029. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110030. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110031. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110032. * @param name Define the name of the camera in the scene
  110033. * @param position Define the start position of the camera in the scene
  110034. * @param scene Define the scene the camera belongs to
  110035. */
  110036. constructor(name: string, position: Vector3, scene: Scene);
  110037. /**
  110038. * Gets the current object class name.
  110039. * @return the class name
  110040. */
  110041. getClassName(): string;
  110042. }
  110043. }
  110044. declare module BABYLON {
  110045. /**
  110046. * This represents all the required metrics to create a VR camera.
  110047. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110048. */
  110049. export class VRCameraMetrics {
  110050. /**
  110051. * Define the horizontal resolution off the screen.
  110052. */
  110053. hResolution: number;
  110054. /**
  110055. * Define the vertical resolution off the screen.
  110056. */
  110057. vResolution: number;
  110058. /**
  110059. * Define the horizontal screen size.
  110060. */
  110061. hScreenSize: number;
  110062. /**
  110063. * Define the vertical screen size.
  110064. */
  110065. vScreenSize: number;
  110066. /**
  110067. * Define the vertical screen center position.
  110068. */
  110069. vScreenCenter: number;
  110070. /**
  110071. * Define the distance of the eyes to the screen.
  110072. */
  110073. eyeToScreenDistance: number;
  110074. /**
  110075. * Define the distance between both lenses
  110076. */
  110077. lensSeparationDistance: number;
  110078. /**
  110079. * Define the distance between both viewer's eyes.
  110080. */
  110081. interpupillaryDistance: number;
  110082. /**
  110083. * Define the distortion factor of the VR postprocess.
  110084. * Please, touch with care.
  110085. */
  110086. distortionK: number[];
  110087. /**
  110088. * Define the chromatic aberration correction factors for the VR post process.
  110089. */
  110090. chromaAbCorrection: number[];
  110091. /**
  110092. * Define the scale factor of the post process.
  110093. * The smaller the better but the slower.
  110094. */
  110095. postProcessScaleFactor: number;
  110096. /**
  110097. * Define an offset for the lens center.
  110098. */
  110099. lensCenterOffset: number;
  110100. /**
  110101. * Define if the current vr camera should compensate the distortion of the lense or not.
  110102. */
  110103. compensateDistortion: boolean;
  110104. /**
  110105. * Defines if multiview should be enabled when rendering (Default: false)
  110106. */
  110107. multiviewEnabled: boolean;
  110108. /**
  110109. * Gets the rendering aspect ratio based on the provided resolutions.
  110110. */
  110111. readonly aspectRatio: number;
  110112. /**
  110113. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110114. */
  110115. readonly aspectRatioFov: number;
  110116. /**
  110117. * @hidden
  110118. */
  110119. readonly leftHMatrix: Matrix;
  110120. /**
  110121. * @hidden
  110122. */
  110123. readonly rightHMatrix: Matrix;
  110124. /**
  110125. * @hidden
  110126. */
  110127. readonly leftPreViewMatrix: Matrix;
  110128. /**
  110129. * @hidden
  110130. */
  110131. readonly rightPreViewMatrix: Matrix;
  110132. /**
  110133. * Get the default VRMetrics based on the most generic setup.
  110134. * @returns the default vr metrics
  110135. */
  110136. static GetDefault(): VRCameraMetrics;
  110137. }
  110138. }
  110139. declare module BABYLON {
  110140. /** @hidden */
  110141. export var vrDistortionCorrectionPixelShader: {
  110142. name: string;
  110143. shader: string;
  110144. };
  110145. }
  110146. declare module BABYLON {
  110147. /**
  110148. * VRDistortionCorrectionPostProcess used for mobile VR
  110149. */
  110150. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110151. private _isRightEye;
  110152. private _distortionFactors;
  110153. private _postProcessScaleFactor;
  110154. private _lensCenterOffset;
  110155. private _scaleIn;
  110156. private _scaleFactor;
  110157. private _lensCenter;
  110158. /**
  110159. * Initializes the VRDistortionCorrectionPostProcess
  110160. * @param name The name of the effect.
  110161. * @param camera The camera to apply the render pass to.
  110162. * @param isRightEye If this is for the right eye distortion
  110163. * @param vrMetrics All the required metrics for the VR camera
  110164. */
  110165. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110166. }
  110167. }
  110168. declare module BABYLON {
  110169. /**
  110170. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110171. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110172. */
  110173. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110174. /**
  110175. * Creates a new VRDeviceOrientationArcRotateCamera
  110176. * @param name defines camera name
  110177. * @param alpha defines the camera rotation along the logitudinal axis
  110178. * @param beta defines the camera rotation along the latitudinal axis
  110179. * @param radius defines the camera distance from its target
  110180. * @param target defines the camera target
  110181. * @param scene defines the scene the camera belongs to
  110182. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110183. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110184. */
  110185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110186. /**
  110187. * Gets camera class name
  110188. * @returns VRDeviceOrientationArcRotateCamera
  110189. */
  110190. getClassName(): string;
  110191. }
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * Camera used to simulate VR rendering (based on FreeCamera)
  110196. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110197. */
  110198. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110199. /**
  110200. * Creates a new VRDeviceOrientationFreeCamera
  110201. * @param name defines camera name
  110202. * @param position defines the start position of the camera
  110203. * @param scene defines the scene the camera belongs to
  110204. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110205. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110206. */
  110207. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110208. /**
  110209. * Gets camera class name
  110210. * @returns VRDeviceOrientationFreeCamera
  110211. */
  110212. getClassName(): string;
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110218. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110219. */
  110220. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110221. /**
  110222. * Creates a new VRDeviceOrientationGamepadCamera
  110223. * @param name defines camera name
  110224. * @param position defines the start position of the camera
  110225. * @param scene defines the scene the camera belongs to
  110226. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110227. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110228. */
  110229. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110230. /**
  110231. * Gets camera class name
  110232. * @returns VRDeviceOrientationGamepadCamera
  110233. */
  110234. getClassName(): string;
  110235. }
  110236. }
  110237. declare module BABYLON {
  110238. /** @hidden */
  110239. export var imageProcessingPixelShader: {
  110240. name: string;
  110241. shader: string;
  110242. };
  110243. }
  110244. declare module BABYLON {
  110245. /**
  110246. * ImageProcessingPostProcess
  110247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110248. */
  110249. export class ImageProcessingPostProcess extends PostProcess {
  110250. /**
  110251. * Default configuration related to image processing available in the PBR Material.
  110252. */
  110253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110254. /**
  110255. * Gets the image processing configuration used either in this material.
  110256. */
  110257. /**
  110258. * Sets the Default image processing configuration used either in the this material.
  110259. *
  110260. * If sets to null, the scene one is in use.
  110261. */
  110262. imageProcessingConfiguration: ImageProcessingConfiguration;
  110263. /**
  110264. * Keep track of the image processing observer to allow dispose and replace.
  110265. */
  110266. private _imageProcessingObserver;
  110267. /**
  110268. * Attaches a new image processing configuration to the PBR Material.
  110269. * @param configuration
  110270. */
  110271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110272. /**
  110273. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110274. */
  110275. /**
  110276. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110277. */
  110278. colorCurves: Nullable<ColorCurves>;
  110279. /**
  110280. * Gets wether the color curves effect is enabled.
  110281. */
  110282. /**
  110283. * Sets wether the color curves effect is enabled.
  110284. */
  110285. colorCurvesEnabled: boolean;
  110286. /**
  110287. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110288. */
  110289. /**
  110290. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110291. */
  110292. colorGradingTexture: Nullable<BaseTexture>;
  110293. /**
  110294. * Gets wether the color grading effect is enabled.
  110295. */
  110296. /**
  110297. * Gets wether the color grading effect is enabled.
  110298. */
  110299. colorGradingEnabled: boolean;
  110300. /**
  110301. * Gets exposure used in the effect.
  110302. */
  110303. /**
  110304. * Sets exposure used in the effect.
  110305. */
  110306. exposure: number;
  110307. /**
  110308. * Gets wether tonemapping is enabled or not.
  110309. */
  110310. /**
  110311. * Sets wether tonemapping is enabled or not
  110312. */
  110313. toneMappingEnabled: boolean;
  110314. /**
  110315. * Gets the type of tone mapping effect.
  110316. */
  110317. /**
  110318. * Sets the type of tone mapping effect.
  110319. */
  110320. toneMappingType: number;
  110321. /**
  110322. * Gets contrast used in the effect.
  110323. */
  110324. /**
  110325. * Sets contrast used in the effect.
  110326. */
  110327. contrast: number;
  110328. /**
  110329. * Gets Vignette stretch size.
  110330. */
  110331. /**
  110332. * Sets Vignette stretch size.
  110333. */
  110334. vignetteStretch: number;
  110335. /**
  110336. * Gets Vignette centre X Offset.
  110337. */
  110338. /**
  110339. * Sets Vignette centre X Offset.
  110340. */
  110341. vignetteCentreX: number;
  110342. /**
  110343. * Gets Vignette centre Y Offset.
  110344. */
  110345. /**
  110346. * Sets Vignette centre Y Offset.
  110347. */
  110348. vignetteCentreY: number;
  110349. /**
  110350. * Gets Vignette weight or intensity of the vignette effect.
  110351. */
  110352. /**
  110353. * Sets Vignette weight or intensity of the vignette effect.
  110354. */
  110355. vignetteWeight: number;
  110356. /**
  110357. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110358. * if vignetteEnabled is set to true.
  110359. */
  110360. /**
  110361. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110362. * if vignetteEnabled is set to true.
  110363. */
  110364. vignetteColor: Color4;
  110365. /**
  110366. * Gets Camera field of view used by the Vignette effect.
  110367. */
  110368. /**
  110369. * Sets Camera field of view used by the Vignette effect.
  110370. */
  110371. vignetteCameraFov: number;
  110372. /**
  110373. * Gets the vignette blend mode allowing different kind of effect.
  110374. */
  110375. /**
  110376. * Sets the vignette blend mode allowing different kind of effect.
  110377. */
  110378. vignetteBlendMode: number;
  110379. /**
  110380. * Gets wether the vignette effect is enabled.
  110381. */
  110382. /**
  110383. * Sets wether the vignette effect is enabled.
  110384. */
  110385. vignetteEnabled: boolean;
  110386. private _fromLinearSpace;
  110387. /**
  110388. * Gets wether the input of the processing is in Gamma or Linear Space.
  110389. */
  110390. /**
  110391. * Sets wether the input of the processing is in Gamma or Linear Space.
  110392. */
  110393. fromLinearSpace: boolean;
  110394. /**
  110395. * Defines cache preventing GC.
  110396. */
  110397. private _defines;
  110398. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110399. /**
  110400. * "ImageProcessingPostProcess"
  110401. * @returns "ImageProcessingPostProcess"
  110402. */
  110403. getClassName(): string;
  110404. protected _updateParameters(): void;
  110405. dispose(camera?: Camera): void;
  110406. }
  110407. }
  110408. declare module BABYLON {
  110409. /**
  110410. * Class containing static functions to help procedurally build meshes
  110411. */
  110412. export class GroundBuilder {
  110413. /**
  110414. * Creates a ground mesh
  110415. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110416. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110418. * @param name defines the name of the mesh
  110419. * @param options defines the options used to create the mesh
  110420. * @param scene defines the hosting scene
  110421. * @returns the ground mesh
  110422. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110423. */
  110424. static CreateGround(name: string, options: {
  110425. width?: number;
  110426. height?: number;
  110427. subdivisions?: number;
  110428. subdivisionsX?: number;
  110429. subdivisionsY?: number;
  110430. updatable?: boolean;
  110431. }, scene: any): Mesh;
  110432. /**
  110433. * Creates a tiled ground mesh
  110434. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110435. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110436. * * 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
  110437. * * 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
  110438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110439. * @param name defines the name of the mesh
  110440. * @param options defines the options used to create the mesh
  110441. * @param scene defines the hosting scene
  110442. * @returns the tiled ground mesh
  110443. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110444. */
  110445. static CreateTiledGround(name: string, options: {
  110446. xmin: number;
  110447. zmin: number;
  110448. xmax: number;
  110449. zmax: number;
  110450. subdivisions?: {
  110451. w: number;
  110452. h: number;
  110453. };
  110454. precision?: {
  110455. w: number;
  110456. h: number;
  110457. };
  110458. updatable?: boolean;
  110459. }, scene?: Nullable<Scene>): Mesh;
  110460. /**
  110461. * Creates a ground mesh from a height map
  110462. * * The parameter `url` sets the URL of the height map image resource.
  110463. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110464. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110465. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110466. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110467. * * 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.
  110468. * * 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).
  110469. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110471. * @param name defines the name of the mesh
  110472. * @param url defines the url to the height map
  110473. * @param options defines the options used to create the mesh
  110474. * @param scene defines the hosting scene
  110475. * @returns the ground mesh
  110476. * @see https://doc.babylonjs.com/babylon101/height_map
  110477. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110478. */
  110479. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110480. width?: number;
  110481. height?: number;
  110482. subdivisions?: number;
  110483. minHeight?: number;
  110484. maxHeight?: number;
  110485. colorFilter?: Color3;
  110486. alphaFilter?: number;
  110487. updatable?: boolean;
  110488. onReady?: (mesh: GroundMesh) => void;
  110489. }, scene?: Nullable<Scene>): GroundMesh;
  110490. }
  110491. }
  110492. declare module BABYLON {
  110493. /**
  110494. * Class containing static functions to help procedurally build meshes
  110495. */
  110496. export class TorusBuilder {
  110497. /**
  110498. * Creates a torus mesh
  110499. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  110500. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  110501. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  110502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110505. * @param name defines the name of the mesh
  110506. * @param options defines the options used to create the mesh
  110507. * @param scene defines the hosting scene
  110508. * @returns the torus mesh
  110509. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  110510. */
  110511. static CreateTorus(name: string, options: {
  110512. diameter?: number;
  110513. thickness?: number;
  110514. tessellation?: number;
  110515. updatable?: boolean;
  110516. sideOrientation?: number;
  110517. frontUVs?: Vector4;
  110518. backUVs?: Vector4;
  110519. }, scene: any): Mesh;
  110520. }
  110521. }
  110522. declare module BABYLON {
  110523. /**
  110524. * Class containing static functions to help procedurally build meshes
  110525. */
  110526. export class CylinderBuilder {
  110527. /**
  110528. * Creates a cylinder or a cone mesh
  110529. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  110530. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  110531. * * 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.
  110532. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  110533. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  110534. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  110535. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  110536. * * 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).
  110537. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  110538. * * 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).
  110539. * * 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
  110540. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  110541. * * 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
  110542. * * 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.
  110543. * * If `enclose` is false, a ring surface is one element.
  110544. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  110545. * * 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
  110546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110549. * @param name defines the name of the mesh
  110550. * @param options defines the options used to create the mesh
  110551. * @param scene defines the hosting scene
  110552. * @returns the cylinder mesh
  110553. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  110554. */
  110555. static CreateCylinder(name: string, options: {
  110556. height?: number;
  110557. diameterTop?: number;
  110558. diameterBottom?: number;
  110559. diameter?: number;
  110560. tessellation?: number;
  110561. subdivisions?: number;
  110562. arc?: number;
  110563. faceColors?: Color4[];
  110564. faceUV?: Vector4[];
  110565. updatable?: boolean;
  110566. hasRings?: boolean;
  110567. enclose?: boolean;
  110568. cap?: number;
  110569. sideOrientation?: number;
  110570. frontUVs?: Vector4;
  110571. backUVs?: Vector4;
  110572. }, scene: any): Mesh;
  110573. }
  110574. }
  110575. declare module BABYLON {
  110576. /**
  110577. * States of the webXR experience
  110578. */
  110579. export enum WebXRState {
  110580. /**
  110581. * Transitioning to being in XR mode
  110582. */
  110583. ENTERING_XR = 0,
  110584. /**
  110585. * Transitioning to non XR mode
  110586. */
  110587. EXITING_XR = 1,
  110588. /**
  110589. * In XR mode and presenting
  110590. */
  110591. IN_XR = 2,
  110592. /**
  110593. * Not entered XR mode
  110594. */
  110595. NOT_IN_XR = 3
  110596. }
  110597. /**
  110598. * Abstraction of the XR render target
  110599. */
  110600. export interface WebXRRenderTarget extends IDisposable {
  110601. /**
  110602. * xrpresent context of the canvas which can be used to display/mirror xr content
  110603. */
  110604. canvasContext: WebGLRenderingContext;
  110605. /**
  110606. * xr layer for the canvas
  110607. */
  110608. xrLayer: Nullable<XRWebGLLayer>;
  110609. /**
  110610. * Initializes the xr layer for the session
  110611. * @param xrSession xr session
  110612. * @returns a promise that will resolve once the XR Layer has been created
  110613. */
  110614. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110615. }
  110616. }
  110617. declare module BABYLON {
  110618. /**
  110619. * COnfiguration object for WebXR output canvas
  110620. */
  110621. export class WebXRManagedOutputCanvasOptions {
  110622. /**
  110623. * Options for this XR Layer output
  110624. */
  110625. canvasOptions: XRWebGLLayerOptions;
  110626. /**
  110627. * CSS styling for a newly created canvas (if not provided)
  110628. */
  110629. newCanvasCssStyle?: string;
  110630. /**
  110631. * Get the default values of the configuration object
  110632. * @returns default values of this configuration object
  110633. */
  110634. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110635. }
  110636. /**
  110637. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110638. */
  110639. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110640. private configuration;
  110641. private _engine;
  110642. private _canvas;
  110643. /**
  110644. * xrpresent context of the canvas which can be used to display/mirror xr content
  110645. */
  110646. canvasContext: WebGLRenderingContext;
  110647. /**
  110648. * xr layer for the canvas
  110649. */
  110650. xrLayer: Nullable<XRWebGLLayer>;
  110651. /**
  110652. * Initializes the xr layer for the session
  110653. * @param xrSession xr session
  110654. * @returns a promise that will resolve once the XR Layer has been created
  110655. */
  110656. initializeXRLayerAsync(xrSession: any): any;
  110657. /**
  110658. * Initializes the canvas to be added/removed upon entering/exiting xr
  110659. * @param engine the Babylon engine
  110660. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110661. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110662. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110663. */
  110664. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110665. /**
  110666. * Disposes of the object
  110667. */
  110668. dispose(): void;
  110669. private _setManagedOutputCanvas;
  110670. private _addCanvas;
  110671. private _removeCanvas;
  110672. }
  110673. }
  110674. declare module BABYLON {
  110675. /**
  110676. * Manages an XRSession to work with Babylon's engine
  110677. * @see https://doc.babylonjs.com/how_to/webxr
  110678. */
  110679. export class WebXRSessionManager implements IDisposable {
  110680. private scene;
  110681. /**
  110682. * Fires every time a new xrFrame arrives which can be used to update the camera
  110683. */
  110684. onXRFrameObservable: Observable<any>;
  110685. /**
  110686. * Fires when the xr session is ended either by the device or manually done
  110687. */
  110688. onXRSessionEnded: Observable<any>;
  110689. /**
  110690. * Underlying xr session
  110691. */
  110692. session: XRSession;
  110693. /**
  110694. * Type of reference space used when creating the session
  110695. */
  110696. referenceSpace: XRReferenceSpace;
  110697. /**
  110698. * Current XR frame
  110699. */
  110700. currentFrame: Nullable<XRFrame>;
  110701. private _xrNavigator;
  110702. private baseLayer;
  110703. private _rttProvider;
  110704. private _sessionEnded;
  110705. /**
  110706. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110707. * @param scene The scene which the session should be created for
  110708. */
  110709. constructor(scene: Scene);
  110710. /**
  110711. * Initializes the manager
  110712. * After initialization enterXR can be called to start an XR session
  110713. * @returns Promise which resolves after it is initialized
  110714. */
  110715. initializeAsync(): Promise<void>;
  110716. /**
  110717. * Initializes an xr session
  110718. * @param xrSessionMode mode to initialize
  110719. * @param optionalFeatures defines optional values to pass to the session builder
  110720. * @returns a promise which will resolve once the session has been initialized
  110721. */
  110722. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110723. /**
  110724. * Sets the reference space on the xr session
  110725. * @param referenceSpace space to set
  110726. * @returns a promise that will resolve once the reference space has been set
  110727. */
  110728. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110729. /**
  110730. * Updates the render state of the session
  110731. * @param state state to set
  110732. * @returns a promise that resolves once the render state has been updated
  110733. */
  110734. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110735. /**
  110736. * Starts rendering to the xr layer
  110737. * @returns a promise that will resolve once rendering has started
  110738. */
  110739. startRenderingToXRAsync(): Promise<void>;
  110740. /**
  110741. * Gets the correct render target texture to be rendered this frame for this eye
  110742. * @param eye the eye for which to get the render target
  110743. * @returns the render target for the specified eye
  110744. */
  110745. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110746. /**
  110747. * Stops the xrSession and restores the renderloop
  110748. * @returns Promise which resolves after it exits XR
  110749. */
  110750. exitXRAsync(): Promise<void>;
  110751. /**
  110752. * Checks if a session would be supported for the creation options specified
  110753. * @param sessionMode session mode to check if supported eg. immersive-vr
  110754. * @returns true if supported
  110755. */
  110756. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110757. /**
  110758. * Creates a WebXRRenderTarget object for the XR session
  110759. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110760. * @param options optional options to provide when creating a new render target
  110761. * @returns a WebXR render target to which the session can render
  110762. */
  110763. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110764. /**
  110765. * @hidden
  110766. * Converts the render layer of xrSession to a render target
  110767. * @param session session to create render target for
  110768. * @param scene scene the new render target should be created for
  110769. */
  110770. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110771. /**
  110772. * Disposes of the session manager
  110773. */
  110774. dispose(): void;
  110775. /**
  110776. * Gets a promise returning true when fullfiled if the given session mode is supported
  110777. * @param sessionMode defines the session to test
  110778. * @returns a promise
  110779. */
  110780. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  110781. }
  110782. }
  110783. declare module BABYLON {
  110784. /**
  110785. * WebXR Camera which holds the views for the xrSession
  110786. * @see https://doc.babylonjs.com/how_to/webxr
  110787. */
  110788. export class WebXRCamera extends FreeCamera {
  110789. /**
  110790. * Is the camera in debug mode. Used when using an emulator
  110791. */
  110792. debugMode: boolean;
  110793. /**
  110794. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110795. * @param name the name of the camera
  110796. * @param scene the scene to add the camera to
  110797. */
  110798. constructor(name: string, scene: Scene);
  110799. private _updateNumberOfRigCameras;
  110800. /** @hidden */
  110801. _updateForDualEyeDebugging(): void;
  110802. /**
  110803. * Updates the cameras position from the current pose information of the XR session
  110804. * @param xrSessionManager the session containing pose information
  110805. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110806. */
  110807. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110808. }
  110809. }
  110810. declare module BABYLON {
  110811. /**
  110812. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110813. * @see https://doc.babylonjs.com/how_to/webxr
  110814. */
  110815. export class WebXRExperienceHelper implements IDisposable {
  110816. private scene;
  110817. /**
  110818. * 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
  110819. */
  110820. container: AbstractMesh;
  110821. /**
  110822. * Camera used to render xr content
  110823. */
  110824. camera: WebXRCamera;
  110825. /**
  110826. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110827. */
  110828. state: WebXRState;
  110829. private _setState;
  110830. private static _TmpVector;
  110831. /**
  110832. * Fires when the state of the experience helper has changed
  110833. */
  110834. onStateChangedObservable: Observable<WebXRState>;
  110835. /** Session manager used to keep track of xr session */
  110836. sessionManager: WebXRSessionManager;
  110837. private _nonVRCamera;
  110838. private _originalSceneAutoClear;
  110839. private _supported;
  110840. /**
  110841. * Creates the experience helper
  110842. * @param scene the scene to attach the experience helper to
  110843. * @returns a promise for the experience helper
  110844. */
  110845. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110846. /**
  110847. * Creates a WebXRExperienceHelper
  110848. * @param scene The scene the helper should be created in
  110849. */
  110850. private constructor();
  110851. /**
  110852. * Exits XR mode and returns the scene to its original state
  110853. * @returns promise that resolves after xr mode has exited
  110854. */
  110855. exitXRAsync(): Promise<void>;
  110856. /**
  110857. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110858. * @param sessionMode options for the XR session
  110859. * @param referenceSpaceType frame of reference of the XR session
  110860. * @param renderTarget the output canvas that will be used to enter XR mode
  110861. * @returns promise that resolves after xr mode has entered
  110862. */
  110863. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110864. /**
  110865. * Updates the global position of the camera by moving the camera's container
  110866. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110867. * @param position The desired global position of the camera
  110868. */
  110869. setPositionOfCameraUsingContainer(position: Vector3): void;
  110870. /**
  110871. * Rotates the xr camera by rotating the camera's container around the camera's position
  110872. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110873. * @param rotation the desired quaternion rotation to apply to the camera
  110874. */
  110875. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110876. /**
  110877. * Disposes of the experience helper
  110878. */
  110879. dispose(): void;
  110880. }
  110881. }
  110882. declare module BABYLON {
  110883. /**
  110884. * Represents an XR input
  110885. */
  110886. export class WebXRController {
  110887. private scene;
  110888. /** The underlying input source for the controller */
  110889. inputSource: XRInputSource;
  110890. private parentContainer;
  110891. /**
  110892. * 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
  110893. */
  110894. grip?: AbstractMesh;
  110895. /**
  110896. * Pointer which can be used to select objects or attach a visible laser to
  110897. */
  110898. pointer: AbstractMesh;
  110899. private _gamepadMode;
  110900. /**
  110901. * If available, this is the gamepad object related to this controller.
  110902. * Using this object it is possible to get click events and trackpad changes of the
  110903. * webxr controller that is currently being used.
  110904. */
  110905. gamepadController?: WebVRController;
  110906. /**
  110907. * Event that fires when the controller is removed/disposed
  110908. */
  110909. onDisposeObservable: Observable<{}>;
  110910. private _tmpQuaternion;
  110911. private _tmpVector;
  110912. /**
  110913. * Creates the controller
  110914. * @see https://doc.babylonjs.com/how_to/webxr
  110915. * @param scene the scene which the controller should be associated to
  110916. * @param inputSource the underlying input source for the controller
  110917. * @param parentContainer parent that the controller meshes should be children of
  110918. */
  110919. constructor(scene: Scene,
  110920. /** The underlying input source for the controller */
  110921. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110922. /**
  110923. * Updates the controller pose based on the given XRFrame
  110924. * @param xrFrame xr frame to update the pose with
  110925. * @param referenceSpace reference space to use
  110926. */
  110927. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110928. /**
  110929. * Gets a world space ray coming from the controller
  110930. * @param result the resulting ray
  110931. */
  110932. getWorldPointerRayToRef(result: Ray): void;
  110933. /**
  110934. * Get the scene associated with this controller
  110935. * @returns the scene object
  110936. */
  110937. getScene(): Scene;
  110938. /**
  110939. * Disposes of the object
  110940. */
  110941. dispose(): void;
  110942. }
  110943. }
  110944. declare module BABYLON {
  110945. /**
  110946. * XR input used to track XR inputs such as controllers/rays
  110947. */
  110948. export class WebXRInput implements IDisposable {
  110949. /**
  110950. * Base experience the input listens to
  110951. */
  110952. baseExperience: WebXRExperienceHelper;
  110953. /**
  110954. * XR controllers being tracked
  110955. */
  110956. controllers: Array<WebXRController>;
  110957. private _frameObserver;
  110958. private _stateObserver;
  110959. /**
  110960. * Event when a controller has been connected/added
  110961. */
  110962. onControllerAddedObservable: Observable<WebXRController>;
  110963. /**
  110964. * Event when a controller has been removed/disconnected
  110965. */
  110966. onControllerRemovedObservable: Observable<WebXRController>;
  110967. /**
  110968. * Initializes the WebXRInput
  110969. * @param baseExperience experience helper which the input should be created for
  110970. */
  110971. constructor(
  110972. /**
  110973. * Base experience the input listens to
  110974. */
  110975. baseExperience: WebXRExperienceHelper);
  110976. private _onInputSourcesChange;
  110977. private _addAndRemoveControllers;
  110978. /**
  110979. * Disposes of the object
  110980. */
  110981. dispose(): void;
  110982. }
  110983. }
  110984. declare module BABYLON {
  110985. /**
  110986. * Class used to represent data loading progression
  110987. */
  110988. export class SceneLoaderProgressEvent {
  110989. /** defines if data length to load can be evaluated */
  110990. readonly lengthComputable: boolean;
  110991. /** defines the loaded data length */
  110992. readonly loaded: number;
  110993. /** defines the data length to load */
  110994. readonly total: number;
  110995. /**
  110996. * Create a new progress event
  110997. * @param lengthComputable defines if data length to load can be evaluated
  110998. * @param loaded defines the loaded data length
  110999. * @param total defines the data length to load
  111000. */
  111001. constructor(
  111002. /** defines if data length to load can be evaluated */
  111003. lengthComputable: boolean,
  111004. /** defines the loaded data length */
  111005. loaded: number,
  111006. /** defines the data length to load */
  111007. total: number);
  111008. /**
  111009. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111010. * @param event defines the source event
  111011. * @returns a new SceneLoaderProgressEvent
  111012. */
  111013. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111014. }
  111015. /**
  111016. * Interface used by SceneLoader plugins to define supported file extensions
  111017. */
  111018. export interface ISceneLoaderPluginExtensions {
  111019. /**
  111020. * Defines the list of supported extensions
  111021. */
  111022. [extension: string]: {
  111023. isBinary: boolean;
  111024. };
  111025. }
  111026. /**
  111027. * Interface used by SceneLoader plugin factory
  111028. */
  111029. export interface ISceneLoaderPluginFactory {
  111030. /**
  111031. * Defines the name of the factory
  111032. */
  111033. name: string;
  111034. /**
  111035. * Function called to create a new plugin
  111036. * @return the new plugin
  111037. */
  111038. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111039. /**
  111040. * The callback that returns true if the data can be directly loaded.
  111041. * @param data string containing the file data
  111042. * @returns if the data can be loaded directly
  111043. */
  111044. canDirectLoad?(data: string): boolean;
  111045. }
  111046. /**
  111047. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111048. */
  111049. export interface ISceneLoaderPluginBase {
  111050. /**
  111051. * The friendly name of this plugin.
  111052. */
  111053. name: string;
  111054. /**
  111055. * The file extensions supported by this plugin.
  111056. */
  111057. extensions: string | ISceneLoaderPluginExtensions;
  111058. /**
  111059. * The callback called when loading from a url.
  111060. * @param scene scene loading this url
  111061. * @param url url to load
  111062. * @param onSuccess callback called when the file successfully loads
  111063. * @param onProgress callback called while file is loading (if the server supports this mode)
  111064. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111065. * @param onError callback called when the file fails to load
  111066. * @returns a file request object
  111067. */
  111068. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111069. /**
  111070. * The callback called when loading from a file object.
  111071. * @param scene scene loading this file
  111072. * @param file defines the file to load
  111073. * @param onSuccess defines the callback to call when data is loaded
  111074. * @param onProgress defines the callback to call during loading process
  111075. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111076. * @param onError defines the callback to call when an error occurs
  111077. * @returns a file request object
  111078. */
  111079. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111080. /**
  111081. * The callback that returns true if the data can be directly loaded.
  111082. * @param data string containing the file data
  111083. * @returns if the data can be loaded directly
  111084. */
  111085. canDirectLoad?(data: string): boolean;
  111086. /**
  111087. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111088. * @param scene scene loading this data
  111089. * @param data string containing the data
  111090. * @returns data to pass to the plugin
  111091. */
  111092. directLoad?(scene: Scene, data: string): any;
  111093. /**
  111094. * The callback that allows custom handling of the root url based on the response url.
  111095. * @param rootUrl the original root url
  111096. * @param responseURL the response url if available
  111097. * @returns the new root url
  111098. */
  111099. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111100. }
  111101. /**
  111102. * Interface used to define a SceneLoader plugin
  111103. */
  111104. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111105. /**
  111106. * Import meshes into a scene.
  111107. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111108. * @param scene The scene to import into
  111109. * @param data The data to import
  111110. * @param rootUrl The root url for scene and resources
  111111. * @param meshes The meshes array to import into
  111112. * @param particleSystems The particle systems array to import into
  111113. * @param skeletons The skeletons array to import into
  111114. * @param onError The callback when import fails
  111115. * @returns True if successful or false otherwise
  111116. */
  111117. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111118. /**
  111119. * Load into a scene.
  111120. * @param scene The scene to load into
  111121. * @param data The data to import
  111122. * @param rootUrl The root url for scene and resources
  111123. * @param onError The callback when import fails
  111124. * @returns True if successful or false otherwise
  111125. */
  111126. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111127. /**
  111128. * Load into an asset container.
  111129. * @param scene The scene to load into
  111130. * @param data The data to import
  111131. * @param rootUrl The root url for scene and resources
  111132. * @param onError The callback when import fails
  111133. * @returns The loaded asset container
  111134. */
  111135. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111136. }
  111137. /**
  111138. * Interface used to define an async SceneLoader plugin
  111139. */
  111140. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111141. /**
  111142. * Import meshes into a scene.
  111143. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111144. * @param scene The scene to import into
  111145. * @param data The data to import
  111146. * @param rootUrl The root url for scene and resources
  111147. * @param onProgress The callback when the load progresses
  111148. * @param fileName Defines the name of the file to load
  111149. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111150. */
  111151. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111152. meshes: AbstractMesh[];
  111153. particleSystems: IParticleSystem[];
  111154. skeletons: Skeleton[];
  111155. animationGroups: AnimationGroup[];
  111156. }>;
  111157. /**
  111158. * Load into a scene.
  111159. * @param scene The scene to load into
  111160. * @param data The data to import
  111161. * @param rootUrl The root url for scene and resources
  111162. * @param onProgress The callback when the load progresses
  111163. * @param fileName Defines the name of the file to load
  111164. * @returns Nothing
  111165. */
  111166. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111167. /**
  111168. * Load into an asset container.
  111169. * @param scene The scene to load into
  111170. * @param data The data to import
  111171. * @param rootUrl The root url for scene and resources
  111172. * @param onProgress The callback when the load progresses
  111173. * @param fileName Defines the name of the file to load
  111174. * @returns The loaded asset container
  111175. */
  111176. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111177. }
  111178. /**
  111179. * Class used to load scene from various file formats using registered plugins
  111180. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111181. */
  111182. export class SceneLoader {
  111183. /**
  111184. * No logging while loading
  111185. */
  111186. static readonly NO_LOGGING: number;
  111187. /**
  111188. * Minimal logging while loading
  111189. */
  111190. static readonly MINIMAL_LOGGING: number;
  111191. /**
  111192. * Summary logging while loading
  111193. */
  111194. static readonly SUMMARY_LOGGING: number;
  111195. /**
  111196. * Detailled logging while loading
  111197. */
  111198. static readonly DETAILED_LOGGING: number;
  111199. /**
  111200. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111201. */
  111202. static ForceFullSceneLoadingForIncremental: boolean;
  111203. /**
  111204. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111205. */
  111206. static ShowLoadingScreen: boolean;
  111207. /**
  111208. * Defines the current logging level (while loading the scene)
  111209. * @ignorenaming
  111210. */
  111211. static loggingLevel: number;
  111212. /**
  111213. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111214. */
  111215. static CleanBoneMatrixWeights: boolean;
  111216. /**
  111217. * Event raised when a plugin is used to load a scene
  111218. */
  111219. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111220. private static _registeredPlugins;
  111221. private static _getDefaultPlugin;
  111222. private static _getPluginForExtension;
  111223. private static _getPluginForDirectLoad;
  111224. private static _getPluginForFilename;
  111225. private static _getDirectLoad;
  111226. private static _loadData;
  111227. private static _getFileInfo;
  111228. /**
  111229. * Gets a plugin that can load the given extension
  111230. * @param extension defines the extension to load
  111231. * @returns a plugin or null if none works
  111232. */
  111233. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111234. /**
  111235. * Gets a boolean indicating that the given extension can be loaded
  111236. * @param extension defines the extension to load
  111237. * @returns true if the extension is supported
  111238. */
  111239. static IsPluginForExtensionAvailable(extension: string): boolean;
  111240. /**
  111241. * Adds a new plugin to the list of registered plugins
  111242. * @param plugin defines the plugin to add
  111243. */
  111244. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111245. /**
  111246. * Import meshes into a scene
  111247. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111248. * @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)
  111249. * @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)
  111250. * @param scene the instance of BABYLON.Scene to append to
  111251. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111252. * @param onProgress a callback with a progress event for each file being loaded
  111253. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111254. * @param pluginExtension the extension used to determine the plugin
  111255. * @returns The loaded plugin
  111256. */
  111257. 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>;
  111258. /**
  111259. * Import meshes into a scene
  111260. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111261. * @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)
  111262. * @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)
  111263. * @param scene the instance of BABYLON.Scene to append to
  111264. * @param onProgress a callback with a progress event for each file being loaded
  111265. * @param pluginExtension the extension used to determine the plugin
  111266. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111267. */
  111268. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111269. meshes: AbstractMesh[];
  111270. particleSystems: IParticleSystem[];
  111271. skeletons: Skeleton[];
  111272. animationGroups: AnimationGroup[];
  111273. }>;
  111274. /**
  111275. * Load a scene
  111276. * @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)
  111277. * @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)
  111278. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111279. * @param onSuccess a callback with the scene when import succeeds
  111280. * @param onProgress a callback with a progress event for each file being loaded
  111281. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111282. * @param pluginExtension the extension used to determine the plugin
  111283. * @returns The loaded plugin
  111284. */
  111285. 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>;
  111286. /**
  111287. * Load a scene
  111288. * @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)
  111289. * @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)
  111290. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111291. * @param onProgress a callback with a progress event for each file being loaded
  111292. * @param pluginExtension the extension used to determine the plugin
  111293. * @returns The loaded scene
  111294. */
  111295. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111296. /**
  111297. * Append a scene
  111298. * @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)
  111299. * @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)
  111300. * @param scene is the instance of BABYLON.Scene to append to
  111301. * @param onSuccess a callback with the scene when import succeeds
  111302. * @param onProgress a callback with a progress event for each file being loaded
  111303. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111304. * @param pluginExtension the extension used to determine the plugin
  111305. * @returns The loaded plugin
  111306. */
  111307. 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>;
  111308. /**
  111309. * Append a scene
  111310. * @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)
  111311. * @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)
  111312. * @param scene is the instance of BABYLON.Scene to append to
  111313. * @param onProgress a callback with a progress event for each file being loaded
  111314. * @param pluginExtension the extension used to determine the plugin
  111315. * @returns The given scene
  111316. */
  111317. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111318. /**
  111319. * Load a scene into an asset container
  111320. * @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)
  111321. * @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)
  111322. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111323. * @param onSuccess a callback with the scene when import succeeds
  111324. * @param onProgress a callback with a progress event for each file being loaded
  111325. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111326. * @param pluginExtension the extension used to determine the plugin
  111327. * @returns The loaded plugin
  111328. */
  111329. 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>;
  111330. /**
  111331. * Load a scene into an asset container
  111332. * @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)
  111333. * @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)
  111334. * @param scene is the instance of Scene to append to
  111335. * @param onProgress a callback with a progress event for each file being loaded
  111336. * @param pluginExtension the extension used to determine the plugin
  111337. * @returns The loaded asset container
  111338. */
  111339. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111340. }
  111341. }
  111342. declare module BABYLON {
  111343. /**
  111344. * Generic Controller
  111345. */
  111346. export class GenericController extends WebVRController {
  111347. /**
  111348. * Base Url for the controller model.
  111349. */
  111350. static readonly MODEL_BASE_URL: string;
  111351. /**
  111352. * File name for the controller model.
  111353. */
  111354. static readonly MODEL_FILENAME: string;
  111355. /**
  111356. * Creates a new GenericController from a gamepad
  111357. * @param vrGamepad the gamepad that the controller should be created from
  111358. */
  111359. constructor(vrGamepad: any);
  111360. /**
  111361. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111362. * @param scene scene in which to add meshes
  111363. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111364. */
  111365. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111366. /**
  111367. * Called once for each button that changed state since the last frame
  111368. * @param buttonIdx Which button index changed
  111369. * @param state New state of the button
  111370. * @param changes Which properties on the state changed since last frame
  111371. */
  111372. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111373. }
  111374. }
  111375. declare module BABYLON {
  111376. /**
  111377. * Defines the WindowsMotionController object that the state of the windows motion controller
  111378. */
  111379. export class WindowsMotionController extends WebVRController {
  111380. /**
  111381. * The base url used to load the left and right controller models
  111382. */
  111383. static MODEL_BASE_URL: string;
  111384. /**
  111385. * The name of the left controller model file
  111386. */
  111387. static MODEL_LEFT_FILENAME: string;
  111388. /**
  111389. * The name of the right controller model file
  111390. */
  111391. static MODEL_RIGHT_FILENAME: string;
  111392. /**
  111393. * The controller name prefix for this controller type
  111394. */
  111395. static readonly GAMEPAD_ID_PREFIX: string;
  111396. /**
  111397. * The controller id pattern for this controller type
  111398. */
  111399. private static readonly GAMEPAD_ID_PATTERN;
  111400. private _loadedMeshInfo;
  111401. protected readonly _mapping: {
  111402. buttons: string[];
  111403. buttonMeshNames: {
  111404. 'trigger': string;
  111405. 'menu': string;
  111406. 'grip': string;
  111407. 'thumbstick': string;
  111408. 'trackpad': string;
  111409. };
  111410. buttonObservableNames: {
  111411. 'trigger': string;
  111412. 'menu': string;
  111413. 'grip': string;
  111414. 'thumbstick': string;
  111415. 'trackpad': string;
  111416. };
  111417. axisMeshNames: string[];
  111418. pointingPoseMeshName: string;
  111419. };
  111420. /**
  111421. * Fired when the trackpad on this controller is clicked
  111422. */
  111423. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111424. /**
  111425. * Fired when the trackpad on this controller is modified
  111426. */
  111427. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111428. /**
  111429. * The current x and y values of this controller's trackpad
  111430. */
  111431. trackpad: StickValues;
  111432. /**
  111433. * Creates a new WindowsMotionController from a gamepad
  111434. * @param vrGamepad the gamepad that the controller should be created from
  111435. */
  111436. constructor(vrGamepad: any);
  111437. /**
  111438. * Fired when the trigger on this controller is modified
  111439. */
  111440. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111441. /**
  111442. * Fired when the menu button on this controller is modified
  111443. */
  111444. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111445. /**
  111446. * Fired when the grip button on this controller is modified
  111447. */
  111448. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111449. /**
  111450. * Fired when the thumbstick button on this controller is modified
  111451. */
  111452. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111453. /**
  111454. * Fired when the touchpad button on this controller is modified
  111455. */
  111456. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111457. /**
  111458. * Fired when the touchpad values on this controller are modified
  111459. */
  111460. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111461. protected _updateTrackpad(): void;
  111462. /**
  111463. * Called once per frame by the engine.
  111464. */
  111465. update(): void;
  111466. /**
  111467. * Called once for each button that changed state since the last frame
  111468. * @param buttonIdx Which button index changed
  111469. * @param state New state of the button
  111470. * @param changes Which properties on the state changed since last frame
  111471. */
  111472. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111473. /**
  111474. * Moves the buttons on the controller mesh based on their current state
  111475. * @param buttonName the name of the button to move
  111476. * @param buttonValue the value of the button which determines the buttons new position
  111477. */
  111478. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111479. /**
  111480. * Moves the axis on the controller mesh based on its current state
  111481. * @param axis the index of the axis
  111482. * @param axisValue the value of the axis which determines the meshes new position
  111483. * @hidden
  111484. */
  111485. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  111486. /**
  111487. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111488. * @param scene scene in which to add meshes
  111489. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111490. */
  111491. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  111492. /**
  111493. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111494. * can be transformed by button presses and axes values, based on this._mapping.
  111495. *
  111496. * @param scene scene in which the meshes exist
  111497. * @param meshes list of meshes that make up the controller model to process
  111498. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111499. */
  111500. private processModel;
  111501. private createMeshInfo;
  111502. /**
  111503. * Gets the ray of the controller in the direction the controller is pointing
  111504. * @param length the length the resulting ray should be
  111505. * @returns a ray in the direction the controller is pointing
  111506. */
  111507. getForwardRay(length?: number): Ray;
  111508. /**
  111509. * Disposes of the controller
  111510. */
  111511. dispose(): void;
  111512. }
  111513. /**
  111514. * This class represents a new windows motion controller in XR.
  111515. */
  111516. export class XRWindowsMotionController extends WindowsMotionController {
  111517. /**
  111518. * Changing the original WIndowsMotionController mapping to fir the new mapping
  111519. */
  111520. protected readonly _mapping: {
  111521. buttons: string[];
  111522. buttonMeshNames: {
  111523. 'trigger': string;
  111524. 'menu': string;
  111525. 'grip': string;
  111526. 'thumbstick': string;
  111527. 'trackpad': string;
  111528. };
  111529. buttonObservableNames: {
  111530. 'trigger': string;
  111531. 'menu': string;
  111532. 'grip': string;
  111533. 'thumbstick': string;
  111534. 'trackpad': string;
  111535. };
  111536. axisMeshNames: string[];
  111537. pointingPoseMeshName: string;
  111538. };
  111539. /**
  111540. * Construct a new XR-Based windows motion controller
  111541. *
  111542. * @param gamepadInfo the gamepad object from the browser
  111543. */
  111544. constructor(gamepadInfo: any);
  111545. /**
  111546. * holds the thumbstick values (X,Y)
  111547. */
  111548. thumbstickValues: StickValues;
  111549. /**
  111550. * Fired when the thumbstick on this controller is clicked
  111551. */
  111552. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  111553. /**
  111554. * Fired when the thumbstick on this controller is modified
  111555. */
  111556. onThumbstickValuesChangedObservable: Observable<StickValues>;
  111557. /**
  111558. * Fired when the touchpad button on this controller is modified
  111559. */
  111560. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111561. /**
  111562. * Fired when the touchpad values on this controller are modified
  111563. */
  111564. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111565. /**
  111566. * Fired when the thumbstick button on this controller is modified
  111567. * here to prevent breaking changes
  111568. */
  111569. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111570. /**
  111571. * updating the thumbstick(!) and not the trackpad.
  111572. * This is named this way due to the difference between WebVR and XR and to avoid
  111573. * changing the parent class.
  111574. */
  111575. protected _updateTrackpad(): void;
  111576. /**
  111577. * Disposes the class with joy
  111578. */
  111579. dispose(): void;
  111580. }
  111581. }
  111582. declare module BABYLON {
  111583. /**
  111584. * Oculus Touch Controller
  111585. */
  111586. export class OculusTouchController extends WebVRController {
  111587. /**
  111588. * Base Url for the controller model.
  111589. */
  111590. static MODEL_BASE_URL: string;
  111591. /**
  111592. * File name for the left controller model.
  111593. */
  111594. static MODEL_LEFT_FILENAME: string;
  111595. /**
  111596. * File name for the right controller model.
  111597. */
  111598. static MODEL_RIGHT_FILENAME: string;
  111599. /**
  111600. * Base Url for the Quest controller model.
  111601. */
  111602. static QUEST_MODEL_BASE_URL: string;
  111603. /**
  111604. * @hidden
  111605. * If the controllers are running on a device that needs the updated Quest controller models
  111606. */
  111607. static _IsQuest: boolean;
  111608. /**
  111609. * Fired when the secondary trigger on this controller is modified
  111610. */
  111611. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111612. /**
  111613. * Fired when the thumb rest on this controller is modified
  111614. */
  111615. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111616. /**
  111617. * Creates a new OculusTouchController from a gamepad
  111618. * @param vrGamepad the gamepad that the controller should be created from
  111619. */
  111620. constructor(vrGamepad: any);
  111621. /**
  111622. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111623. * @param scene scene in which to add meshes
  111624. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111625. */
  111626. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111627. /**
  111628. * Fired when the A button on this controller is modified
  111629. */
  111630. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111631. /**
  111632. * Fired when the B button on this controller is modified
  111633. */
  111634. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111635. /**
  111636. * Fired when the X button on this controller is modified
  111637. */
  111638. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111639. /**
  111640. * Fired when the Y button on this controller is modified
  111641. */
  111642. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111643. /**
  111644. * Called once for each button that changed state since the last frame
  111645. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111646. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111647. * 2) secondary trigger (same)
  111648. * 3) A (right) X (left), touch, pressed = value
  111649. * 4) B / Y
  111650. * 5) thumb rest
  111651. * @param buttonIdx Which button index changed
  111652. * @param state New state of the button
  111653. * @param changes Which properties on the state changed since last frame
  111654. */
  111655. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111656. }
  111657. }
  111658. declare module BABYLON {
  111659. /**
  111660. * Vive Controller
  111661. */
  111662. export class ViveController extends WebVRController {
  111663. /**
  111664. * Base Url for the controller model.
  111665. */
  111666. static MODEL_BASE_URL: string;
  111667. /**
  111668. * File name for the controller model.
  111669. */
  111670. static MODEL_FILENAME: string;
  111671. /**
  111672. * Creates a new ViveController from a gamepad
  111673. * @param vrGamepad the gamepad that the controller should be created from
  111674. */
  111675. constructor(vrGamepad: any);
  111676. /**
  111677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111678. * @param scene scene in which to add meshes
  111679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111680. */
  111681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111682. /**
  111683. * Fired when the left button on this controller is modified
  111684. */
  111685. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111686. /**
  111687. * Fired when the right button on this controller is modified
  111688. */
  111689. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111690. /**
  111691. * Fired when the menu button on this controller is modified
  111692. */
  111693. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111694. /**
  111695. * Called once for each button that changed state since the last frame
  111696. * Vive mapping:
  111697. * 0: touchpad
  111698. * 1: trigger
  111699. * 2: left AND right buttons
  111700. * 3: menu button
  111701. * @param buttonIdx Which button index changed
  111702. * @param state New state of the button
  111703. * @param changes Which properties on the state changed since last frame
  111704. */
  111705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111706. }
  111707. }
  111708. declare module BABYLON {
  111709. /**
  111710. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111711. */
  111712. export class WebXRControllerModelLoader {
  111713. /**
  111714. * an observable that triggers when a new model (the mesh itself) was initialized.
  111715. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111716. */
  111717. onControllerModelLoaded: Observable<WebXRController>;
  111718. /**
  111719. * Creates the WebXRControllerModelLoader
  111720. * @param input xr input that creates the controllers
  111721. */
  111722. constructor(input: WebXRInput);
  111723. }
  111724. }
  111725. declare module BABYLON {
  111726. /**
  111727. * Handles pointer input automatically for the pointer of XR controllers
  111728. */
  111729. export class WebXRControllerPointerSelection {
  111730. private static _idCounter;
  111731. private _tmpRay;
  111732. /**
  111733. * Creates a WebXRControllerPointerSelection
  111734. * @param input input manager to setup pointer selection
  111735. */
  111736. constructor(input: WebXRInput);
  111737. private _convertNormalToDirectionOfRay;
  111738. private _updatePointerDistance;
  111739. }
  111740. }
  111741. declare module BABYLON {
  111742. /**
  111743. * Enables teleportation
  111744. */
  111745. export class WebXRControllerTeleportation {
  111746. private _teleportationFillColor;
  111747. private _teleportationBorderColor;
  111748. private _tmpRay;
  111749. private _tmpVector;
  111750. /**
  111751. * Creates a WebXRControllerTeleportation
  111752. * @param input input manager to add teleportation to
  111753. * @param floorMeshes floormeshes which can be teleported to
  111754. */
  111755. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  111756. }
  111757. }
  111758. declare module BABYLON {
  111759. /**
  111760. * Button which can be used to enter a different mode of XR
  111761. */
  111762. export class WebXREnterExitUIButton {
  111763. /** button element */
  111764. element: HTMLElement;
  111765. /** XR initialization options for the button */
  111766. sessionMode: XRSessionMode;
  111767. /** Reference space type */
  111768. referenceSpaceType: XRReferenceSpaceType;
  111769. /**
  111770. * Creates a WebXREnterExitUIButton
  111771. * @param element button element
  111772. * @param sessionMode XR initialization session mode
  111773. * @param referenceSpaceType the type of reference space to be used
  111774. */
  111775. constructor(
  111776. /** button element */
  111777. element: HTMLElement,
  111778. /** XR initialization options for the button */
  111779. sessionMode: XRSessionMode,
  111780. /** Reference space type */
  111781. referenceSpaceType: XRReferenceSpaceType);
  111782. /**
  111783. * Overwritable function which can be used to update the button's visuals when the state changes
  111784. * @param activeButton the current active button in the UI
  111785. */
  111786. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  111787. }
  111788. /**
  111789. * Options to create the webXR UI
  111790. */
  111791. export class WebXREnterExitUIOptions {
  111792. /**
  111793. * Context to enter xr with
  111794. */
  111795. renderTarget?: Nullable<WebXRRenderTarget>;
  111796. /**
  111797. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  111798. */
  111799. customButtons?: Array<WebXREnterExitUIButton>;
  111800. /**
  111801. * A session mode to use when creating the default button.
  111802. * Default is immersive-vr
  111803. */
  111804. sessionMode?: XRSessionMode;
  111805. /**
  111806. * A reference space type to use when creating the default button.
  111807. * Default is local-floor
  111808. */
  111809. referenceSpaceType?: XRReferenceSpaceType;
  111810. }
  111811. /**
  111812. * UI to allow the user to enter/exit XR mode
  111813. */
  111814. export class WebXREnterExitUI implements IDisposable {
  111815. private scene;
  111816. private _overlay;
  111817. private _buttons;
  111818. private _activeButton;
  111819. /**
  111820. * Fired every time the active button is changed.
  111821. *
  111822. * When xr is entered via a button that launches xr that button will be the callback parameter
  111823. *
  111824. * When exiting xr the callback parameter will be null)
  111825. */
  111826. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  111827. /**
  111828. * Creates UI to allow the user to enter/exit XR mode
  111829. * @param scene the scene to add the ui to
  111830. * @param helper the xr experience helper to enter/exit xr with
  111831. * @param options options to configure the UI
  111832. * @returns the created ui
  111833. */
  111834. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  111835. private constructor();
  111836. private _updateButtons;
  111837. /**
  111838. * Disposes of the object
  111839. */
  111840. dispose(): void;
  111841. }
  111842. }
  111843. declare module BABYLON {
  111844. /**
  111845. * Options for the default xr helper
  111846. */
  111847. export class WebXRDefaultExperienceOptions {
  111848. /**
  111849. * Floor meshes that should be used for teleporting
  111850. */
  111851. floorMeshes: Array<AbstractMesh>;
  111852. /**
  111853. * Enable or disable default UI to enter XR
  111854. */
  111855. disableDefaultUI?: boolean;
  111856. /**
  111857. * optional configuration for the output canvas
  111858. */
  111859. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111860. }
  111861. /**
  111862. * Default experience which provides a similar setup to the previous webVRExperience
  111863. */
  111864. export class WebXRDefaultExperience {
  111865. /**
  111866. * Base experience
  111867. */
  111868. baseExperience: WebXRExperienceHelper;
  111869. /**
  111870. * Input experience extension
  111871. */
  111872. input: WebXRInput;
  111873. /**
  111874. * Loads the controller models
  111875. */
  111876. controllerModelLoader: WebXRControllerModelLoader;
  111877. /**
  111878. * Enables laser pointer and selection
  111879. */
  111880. pointerSelection: WebXRControllerPointerSelection;
  111881. /**
  111882. * Enables teleportation
  111883. */
  111884. teleportation: WebXRControllerTeleportation;
  111885. /**
  111886. * Enables ui for enetering/exiting xr
  111887. */
  111888. enterExitUI: WebXREnterExitUI;
  111889. /**
  111890. * Default target xr should render to
  111891. */
  111892. renderTarget: WebXRRenderTarget;
  111893. /**
  111894. * Creates the default xr experience
  111895. * @param scene scene
  111896. * @param options options for basic configuration
  111897. * @returns resulting WebXRDefaultExperience
  111898. */
  111899. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111900. private constructor();
  111901. /**
  111902. * DIsposes of the experience helper
  111903. */
  111904. dispose(): void;
  111905. }
  111906. }
  111907. declare module BABYLON {
  111908. /**
  111909. * Options to modify the vr teleportation behavior.
  111910. */
  111911. export interface VRTeleportationOptions {
  111912. /**
  111913. * The name of the mesh which should be used as the teleportation floor. (default: null)
  111914. */
  111915. floorMeshName?: string;
  111916. /**
  111917. * A list of meshes to be used as the teleportation floor. (default: empty)
  111918. */
  111919. floorMeshes?: Mesh[];
  111920. /**
  111921. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  111922. */
  111923. teleportationMode?: number;
  111924. /**
  111925. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  111926. */
  111927. teleportationTime?: number;
  111928. /**
  111929. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  111930. */
  111931. teleportationSpeed?: number;
  111932. /**
  111933. * The easing function used in the animation or null for Linear. (default CircleEase)
  111934. */
  111935. easingFunction?: EasingFunction;
  111936. }
  111937. /**
  111938. * Options to modify the vr experience helper's behavior.
  111939. */
  111940. export interface VRExperienceHelperOptions extends WebVROptions {
  111941. /**
  111942. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  111943. */
  111944. createDeviceOrientationCamera?: boolean;
  111945. /**
  111946. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  111947. */
  111948. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  111949. /**
  111950. * Uses the main button on the controller to toggle the laser casted. (default: true)
  111951. */
  111952. laserToggle?: boolean;
  111953. /**
  111954. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  111955. */
  111956. floorMeshes?: Mesh[];
  111957. /**
  111958. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  111959. */
  111960. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  111961. /**
  111962. * Defines if WebXR should be used instead of WebVR (if available)
  111963. */
  111964. useXR?: boolean;
  111965. }
  111966. /**
  111967. * Event containing information after VR has been entered
  111968. */
  111969. export class OnAfterEnteringVRObservableEvent {
  111970. /**
  111971. * If entering vr was successful
  111972. */
  111973. success: boolean;
  111974. }
  111975. /**
  111976. * Helps to quickly add VR support to an existing scene.
  111977. * See http://doc.babylonjs.com/how_to/webvr_helper
  111978. */
  111979. export class VRExperienceHelper {
  111980. /** Options to modify the vr experience helper's behavior. */
  111981. webVROptions: VRExperienceHelperOptions;
  111982. private _scene;
  111983. private _position;
  111984. private _btnVR;
  111985. private _btnVRDisplayed;
  111986. private _webVRsupported;
  111987. private _webVRready;
  111988. private _webVRrequesting;
  111989. private _webVRpresenting;
  111990. private _hasEnteredVR;
  111991. private _fullscreenVRpresenting;
  111992. private _inputElement;
  111993. private _webVRCamera;
  111994. private _vrDeviceOrientationCamera;
  111995. private _deviceOrientationCamera;
  111996. private _existingCamera;
  111997. private _onKeyDown;
  111998. private _onVrDisplayPresentChange;
  111999. private _onVRDisplayChanged;
  112000. private _onVRRequestPresentStart;
  112001. private _onVRRequestPresentComplete;
  112002. /**
  112003. * 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)
  112004. */
  112005. enableGazeEvenWhenNoPointerLock: boolean;
  112006. /**
  112007. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112008. */
  112009. exitVROnDoubleTap: boolean;
  112010. /**
  112011. * Observable raised right before entering VR.
  112012. */
  112013. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112014. /**
  112015. * Observable raised when entering VR has completed.
  112016. */
  112017. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112018. /**
  112019. * Observable raised when exiting VR.
  112020. */
  112021. onExitingVRObservable: Observable<VRExperienceHelper>;
  112022. /**
  112023. * Observable raised when controller mesh is loaded.
  112024. */
  112025. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112026. /** Return this.onEnteringVRObservable
  112027. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112028. */
  112029. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112030. /** Return this.onExitingVRObservable
  112031. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112032. */
  112033. readonly onExitingVR: Observable<VRExperienceHelper>;
  112034. /** Return this.onControllerMeshLoadedObservable
  112035. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112036. */
  112037. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112038. private _rayLength;
  112039. private _useCustomVRButton;
  112040. private _teleportationRequested;
  112041. private _teleportActive;
  112042. private _floorMeshName;
  112043. private _floorMeshesCollection;
  112044. private _teleportationMode;
  112045. private _teleportationTime;
  112046. private _teleportationSpeed;
  112047. private _teleportationEasing;
  112048. private _rotationAllowed;
  112049. private _teleportBackwardsVector;
  112050. private _teleportationTarget;
  112051. private _isDefaultTeleportationTarget;
  112052. private _postProcessMove;
  112053. private _teleportationFillColor;
  112054. private _teleportationBorderColor;
  112055. private _rotationAngle;
  112056. private _haloCenter;
  112057. private _cameraGazer;
  112058. private _padSensibilityUp;
  112059. private _padSensibilityDown;
  112060. private _leftController;
  112061. private _rightController;
  112062. /**
  112063. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112064. */
  112065. onNewMeshSelected: Observable<AbstractMesh>;
  112066. /**
  112067. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112068. * This observable will provide the mesh and the controller used to select the mesh
  112069. */
  112070. onMeshSelectedWithController: Observable<{
  112071. mesh: AbstractMesh;
  112072. controller: WebVRController;
  112073. }>;
  112074. /**
  112075. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112076. */
  112077. onNewMeshPicked: Observable<PickingInfo>;
  112078. private _circleEase;
  112079. /**
  112080. * Observable raised before camera teleportation
  112081. */
  112082. onBeforeCameraTeleport: Observable<Vector3>;
  112083. /**
  112084. * Observable raised after camera teleportation
  112085. */
  112086. onAfterCameraTeleport: Observable<Vector3>;
  112087. /**
  112088. * Observable raised when current selected mesh gets unselected
  112089. */
  112090. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112091. private _raySelectionPredicate;
  112092. /**
  112093. * To be optionaly changed by user to define custom ray selection
  112094. */
  112095. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112096. /**
  112097. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112098. */
  112099. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112100. /**
  112101. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112102. */
  112103. teleportationEnabled: boolean;
  112104. private _defaultHeight;
  112105. private _teleportationInitialized;
  112106. private _interactionsEnabled;
  112107. private _interactionsRequested;
  112108. private _displayGaze;
  112109. private _displayLaserPointer;
  112110. /**
  112111. * The mesh used to display where the user is going to teleport.
  112112. */
  112113. /**
  112114. * Sets the mesh to be used to display where the user is going to teleport.
  112115. */
  112116. teleportationTarget: Mesh;
  112117. /**
  112118. * 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
  112119. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112120. * See http://doc.babylonjs.com/resources/baking_transformations
  112121. */
  112122. gazeTrackerMesh: Mesh;
  112123. /**
  112124. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112125. */
  112126. updateGazeTrackerScale: boolean;
  112127. /**
  112128. * If the gaze trackers color should be updated when selecting meshes
  112129. */
  112130. updateGazeTrackerColor: boolean;
  112131. /**
  112132. * If the controller laser color should be updated when selecting meshes
  112133. */
  112134. updateControllerLaserColor: boolean;
  112135. /**
  112136. * The gaze tracking mesh corresponding to the left controller
  112137. */
  112138. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112139. /**
  112140. * The gaze tracking mesh corresponding to the right controller
  112141. */
  112142. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112143. /**
  112144. * If the ray of the gaze should be displayed.
  112145. */
  112146. /**
  112147. * Sets if the ray of the gaze should be displayed.
  112148. */
  112149. displayGaze: boolean;
  112150. /**
  112151. * If the ray of the LaserPointer should be displayed.
  112152. */
  112153. /**
  112154. * Sets if the ray of the LaserPointer should be displayed.
  112155. */
  112156. displayLaserPointer: boolean;
  112157. /**
  112158. * The deviceOrientationCamera used as the camera when not in VR.
  112159. */
  112160. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112161. /**
  112162. * Based on the current WebVR support, returns the current VR camera used.
  112163. */
  112164. readonly currentVRCamera: Nullable<Camera>;
  112165. /**
  112166. * The webVRCamera which is used when in VR.
  112167. */
  112168. readonly webVRCamera: WebVRFreeCamera;
  112169. /**
  112170. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112171. */
  112172. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112173. /**
  112174. * The html button that is used to trigger entering into VR.
  112175. */
  112176. readonly vrButton: Nullable<HTMLButtonElement>;
  112177. private readonly _teleportationRequestInitiated;
  112178. /**
  112179. * Defines wether or not Pointer lock should be requested when switching to
  112180. * full screen.
  112181. */
  112182. requestPointerLockOnFullScreen: boolean;
  112183. /**
  112184. * If asking to force XR, this will be populated with the default xr experience
  112185. */
  112186. xr: WebXRDefaultExperience;
  112187. /**
  112188. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112189. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112190. */
  112191. xrTestDone: boolean;
  112192. /**
  112193. * Instantiates a VRExperienceHelper.
  112194. * Helps to quickly add VR support to an existing scene.
  112195. * @param scene The scene the VRExperienceHelper belongs to.
  112196. * @param webVROptions Options to modify the vr experience helper's behavior.
  112197. */
  112198. constructor(scene: Scene,
  112199. /** Options to modify the vr experience helper's behavior. */
  112200. webVROptions?: VRExperienceHelperOptions);
  112201. private completeVRInit;
  112202. private _onDefaultMeshLoaded;
  112203. private _onResize;
  112204. private _onFullscreenChange;
  112205. /**
  112206. * Gets a value indicating if we are currently in VR mode.
  112207. */
  112208. readonly isInVRMode: boolean;
  112209. private onVrDisplayPresentChange;
  112210. private onVRDisplayChanged;
  112211. private moveButtonToBottomRight;
  112212. private displayVRButton;
  112213. private updateButtonVisibility;
  112214. private _cachedAngularSensibility;
  112215. /**
  112216. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112217. * Otherwise, will use the fullscreen API.
  112218. */
  112219. enterVR(): void;
  112220. /**
  112221. * Attempt to exit VR, or fullscreen.
  112222. */
  112223. exitVR(): void;
  112224. /**
  112225. * The position of the vr experience helper.
  112226. */
  112227. /**
  112228. * Sets the position of the vr experience helper.
  112229. */
  112230. position: Vector3;
  112231. /**
  112232. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112233. */
  112234. enableInteractions(): void;
  112235. private readonly _noControllerIsActive;
  112236. private beforeRender;
  112237. private _isTeleportationFloor;
  112238. /**
  112239. * Adds a floor mesh to be used for teleportation.
  112240. * @param floorMesh the mesh to be used for teleportation.
  112241. */
  112242. addFloorMesh(floorMesh: Mesh): void;
  112243. /**
  112244. * Removes a floor mesh from being used for teleportation.
  112245. * @param floorMesh the mesh to be removed.
  112246. */
  112247. removeFloorMesh(floorMesh: Mesh): void;
  112248. /**
  112249. * Enables interactions and teleportation using the VR controllers and gaze.
  112250. * @param vrTeleportationOptions options to modify teleportation behavior.
  112251. */
  112252. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112253. private _onNewGamepadConnected;
  112254. private _tryEnableInteractionOnController;
  112255. private _onNewGamepadDisconnected;
  112256. private _enableInteractionOnController;
  112257. private _checkTeleportWithRay;
  112258. private _checkRotate;
  112259. private _checkTeleportBackwards;
  112260. private _enableTeleportationOnController;
  112261. private _createTeleportationCircles;
  112262. private _displayTeleportationTarget;
  112263. private _hideTeleportationTarget;
  112264. private _rotateCamera;
  112265. private _moveTeleportationSelectorTo;
  112266. private _workingVector;
  112267. private _workingQuaternion;
  112268. private _workingMatrix;
  112269. /**
  112270. * Time Constant Teleportation Mode
  112271. */
  112272. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112273. /**
  112274. * Speed Constant Teleportation Mode
  112275. */
  112276. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112277. /**
  112278. * Teleports the users feet to the desired location
  112279. * @param location The location where the user's feet should be placed
  112280. */
  112281. teleportCamera(location: Vector3): void;
  112282. private _convertNormalToDirectionOfRay;
  112283. private _castRayAndSelectObject;
  112284. private _notifySelectedMeshUnselected;
  112285. /**
  112286. * Sets the color of the laser ray from the vr controllers.
  112287. * @param color new color for the ray.
  112288. */
  112289. changeLaserColor(color: Color3): void;
  112290. /**
  112291. * Sets the color of the ray from the vr headsets gaze.
  112292. * @param color new color for the ray.
  112293. */
  112294. changeGazeColor(color: Color3): void;
  112295. /**
  112296. * Exits VR and disposes of the vr experience helper
  112297. */
  112298. dispose(): void;
  112299. /**
  112300. * Gets the name of the VRExperienceHelper class
  112301. * @returns "VRExperienceHelper"
  112302. */
  112303. getClassName(): string;
  112304. }
  112305. }
  112306. declare module BABYLON {
  112307. /**
  112308. * Contains an array of blocks representing the octree
  112309. */
  112310. export interface IOctreeContainer<T> {
  112311. /**
  112312. * Blocks within the octree
  112313. */
  112314. blocks: Array<OctreeBlock<T>>;
  112315. }
  112316. /**
  112317. * Class used to store a cell in an octree
  112318. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112319. */
  112320. export class OctreeBlock<T> {
  112321. /**
  112322. * Gets the content of the current block
  112323. */
  112324. entries: T[];
  112325. /**
  112326. * Gets the list of block children
  112327. */
  112328. blocks: Array<OctreeBlock<T>>;
  112329. private _depth;
  112330. private _maxDepth;
  112331. private _capacity;
  112332. private _minPoint;
  112333. private _maxPoint;
  112334. private _boundingVectors;
  112335. private _creationFunc;
  112336. /**
  112337. * Creates a new block
  112338. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112339. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112340. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112341. * @param depth defines the current depth of this block in the octree
  112342. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112343. * @param creationFunc defines a callback to call when an element is added to the block
  112344. */
  112345. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112346. /**
  112347. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112348. */
  112349. readonly capacity: number;
  112350. /**
  112351. * Gets the minimum vector (in world space) of the block's bounding box
  112352. */
  112353. readonly minPoint: Vector3;
  112354. /**
  112355. * Gets the maximum vector (in world space) of the block's bounding box
  112356. */
  112357. readonly maxPoint: Vector3;
  112358. /**
  112359. * Add a new element to this block
  112360. * @param entry defines the element to add
  112361. */
  112362. addEntry(entry: T): void;
  112363. /**
  112364. * Remove an element from this block
  112365. * @param entry defines the element to remove
  112366. */
  112367. removeEntry(entry: T): void;
  112368. /**
  112369. * Add an array of elements to this block
  112370. * @param entries defines the array of elements to add
  112371. */
  112372. addEntries(entries: T[]): void;
  112373. /**
  112374. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  112375. * @param frustumPlanes defines the frustum planes to test
  112376. * @param selection defines the array to store current content if selection is positive
  112377. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112378. */
  112379. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112380. /**
  112381. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  112382. * @param sphereCenter defines the bounding sphere center
  112383. * @param sphereRadius defines the bounding sphere radius
  112384. * @param selection defines the array to store current content if selection is positive
  112385. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112386. */
  112387. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  112388. /**
  112389. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  112390. * @param ray defines the ray to test with
  112391. * @param selection defines the array to store current content if selection is positive
  112392. */
  112393. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  112394. /**
  112395. * Subdivide the content into child blocks (this block will then be empty)
  112396. */
  112397. createInnerBlocks(): void;
  112398. /**
  112399. * @hidden
  112400. */
  112401. 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;
  112402. }
  112403. }
  112404. declare module BABYLON {
  112405. /**
  112406. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  112407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112408. */
  112409. export class Octree<T> {
  112410. /** 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.) */
  112411. maxDepth: number;
  112412. /**
  112413. * Blocks within the octree containing objects
  112414. */
  112415. blocks: Array<OctreeBlock<T>>;
  112416. /**
  112417. * Content stored in the octree
  112418. */
  112419. dynamicContent: T[];
  112420. private _maxBlockCapacity;
  112421. private _selectionContent;
  112422. private _creationFunc;
  112423. /**
  112424. * Creates a octree
  112425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112426. * @param creationFunc function to be used to instatiate the octree
  112427. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  112428. * @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.)
  112429. */
  112430. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  112431. /** 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.) */
  112432. maxDepth?: number);
  112433. /**
  112434. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  112435. * @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);
  112436. * @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);
  112437. * @param entries meshes to be added to the octree blocks
  112438. */
  112439. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  112440. /**
  112441. * Adds a mesh to the octree
  112442. * @param entry Mesh to add to the octree
  112443. */
  112444. addMesh(entry: T): void;
  112445. /**
  112446. * Remove an element from the octree
  112447. * @param entry defines the element to remove
  112448. */
  112449. removeMesh(entry: T): void;
  112450. /**
  112451. * Selects an array of meshes within the frustum
  112452. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  112453. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  112454. * @returns array of meshes within the frustum
  112455. */
  112456. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  112457. /**
  112458. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  112459. * @param sphereCenter defines the bounding sphere center
  112460. * @param sphereRadius defines the bounding sphere radius
  112461. * @param allowDuplicate defines if the selection array can contains duplicated entries
  112462. * @returns an array of objects that intersect the sphere
  112463. */
  112464. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  112465. /**
  112466. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  112467. * @param ray defines the ray to test with
  112468. * @returns array of intersected objects
  112469. */
  112470. intersectsRay(ray: Ray): SmartArray<T>;
  112471. /**
  112472. * Adds a mesh into the octree block if it intersects the block
  112473. */
  112474. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  112475. /**
  112476. * Adds a submesh into the octree block if it intersects the block
  112477. */
  112478. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  112479. }
  112480. }
  112481. declare module BABYLON {
  112482. interface Scene {
  112483. /**
  112484. * @hidden
  112485. * Backing Filed
  112486. */
  112487. _selectionOctree: Octree<AbstractMesh>;
  112488. /**
  112489. * Gets the octree used to boost mesh selection (picking)
  112490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112491. */
  112492. selectionOctree: Octree<AbstractMesh>;
  112493. /**
  112494. * Creates or updates the octree used to boost selection (picking)
  112495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112496. * @param maxCapacity defines the maximum capacity per leaf
  112497. * @param maxDepth defines the maximum depth of the octree
  112498. * @returns an octree of AbstractMesh
  112499. */
  112500. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  112501. }
  112502. interface AbstractMesh {
  112503. /**
  112504. * @hidden
  112505. * Backing Field
  112506. */
  112507. _submeshesOctree: Octree<SubMesh>;
  112508. /**
  112509. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  112510. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112511. * @param maxCapacity defines the maximum size of each block (64 by default)
  112512. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  112513. * @returns the new octree
  112514. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  112515. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112516. */
  112517. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  112518. }
  112519. /**
  112520. * Defines the octree scene component responsible to manage any octrees
  112521. * in a given scene.
  112522. */
  112523. export class OctreeSceneComponent {
  112524. /**
  112525. * The component name help to identify the component in the list of scene components.
  112526. */
  112527. readonly name: string;
  112528. /**
  112529. * The scene the component belongs to.
  112530. */
  112531. scene: Scene;
  112532. /**
  112533. * Indicates if the meshes have been checked to make sure they are isEnabled()
  112534. */
  112535. readonly checksIsEnabled: boolean;
  112536. /**
  112537. * Creates a new instance of the component for the given scene
  112538. * @param scene Defines the scene to register the component in
  112539. */
  112540. constructor(scene: Scene);
  112541. /**
  112542. * Registers the component in a given scene
  112543. */
  112544. register(): void;
  112545. /**
  112546. * Return the list of active meshes
  112547. * @returns the list of active meshes
  112548. */
  112549. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  112550. /**
  112551. * Return the list of active sub meshes
  112552. * @param mesh The mesh to get the candidates sub meshes from
  112553. * @returns the list of active sub meshes
  112554. */
  112555. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  112556. private _tempRay;
  112557. /**
  112558. * Return the list of sub meshes intersecting with a given local ray
  112559. * @param mesh defines the mesh to find the submesh for
  112560. * @param localRay defines the ray in local space
  112561. * @returns the list of intersecting sub meshes
  112562. */
  112563. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  112564. /**
  112565. * Return the list of sub meshes colliding with a collider
  112566. * @param mesh defines the mesh to find the submesh for
  112567. * @param collider defines the collider to evaluate the collision against
  112568. * @returns the list of colliding sub meshes
  112569. */
  112570. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  112571. /**
  112572. * Rebuilds the elements related to this component in case of
  112573. * context lost for instance.
  112574. */
  112575. rebuild(): void;
  112576. /**
  112577. * Disposes the component and the associated ressources.
  112578. */
  112579. dispose(): void;
  112580. }
  112581. }
  112582. declare module BABYLON {
  112583. /**
  112584. * Renders a layer on top of an existing scene
  112585. */
  112586. export class UtilityLayerRenderer implements IDisposable {
  112587. /** the original scene that will be rendered on top of */
  112588. originalScene: Scene;
  112589. private _pointerCaptures;
  112590. private _lastPointerEvents;
  112591. private static _DefaultUtilityLayer;
  112592. private static _DefaultKeepDepthUtilityLayer;
  112593. private _sharedGizmoLight;
  112594. private _renderCamera;
  112595. /**
  112596. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  112597. * @returns the camera that is used when rendering the utility layer
  112598. */
  112599. getRenderCamera(): Nullable<Camera>;
  112600. /**
  112601. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  112602. * @param cam the camera that should be used when rendering the utility layer
  112603. */
  112604. setRenderCamera(cam: Nullable<Camera>): void;
  112605. /**
  112606. * @hidden
  112607. * Light which used by gizmos to get light shading
  112608. */
  112609. _getSharedGizmoLight(): HemisphericLight;
  112610. /**
  112611. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  112612. */
  112613. pickUtilitySceneFirst: boolean;
  112614. /**
  112615. * 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)
  112616. */
  112617. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  112618. /**
  112619. * 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)
  112620. */
  112621. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  112622. /**
  112623. * The scene that is rendered on top of the original scene
  112624. */
  112625. utilityLayerScene: Scene;
  112626. /**
  112627. * If the utility layer should automatically be rendered on top of existing scene
  112628. */
  112629. shouldRender: boolean;
  112630. /**
  112631. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  112632. */
  112633. onlyCheckPointerDownEvents: boolean;
  112634. /**
  112635. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  112636. */
  112637. processAllEvents: boolean;
  112638. /**
  112639. * Observable raised when the pointer move from the utility layer scene to the main scene
  112640. */
  112641. onPointerOutObservable: Observable<number>;
  112642. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  112643. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  112644. private _afterRenderObserver;
  112645. private _sceneDisposeObserver;
  112646. private _originalPointerObserver;
  112647. /**
  112648. * Instantiates a UtilityLayerRenderer
  112649. * @param originalScene the original scene that will be rendered on top of
  112650. * @param handleEvents boolean indicating if the utility layer should handle events
  112651. */
  112652. constructor(
  112653. /** the original scene that will be rendered on top of */
  112654. originalScene: Scene, handleEvents?: boolean);
  112655. private _notifyObservers;
  112656. /**
  112657. * Renders the utility layers scene on top of the original scene
  112658. */
  112659. render(): void;
  112660. /**
  112661. * Disposes of the renderer
  112662. */
  112663. dispose(): void;
  112664. private _updateCamera;
  112665. }
  112666. }
  112667. declare module BABYLON {
  112668. /**
  112669. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  112670. */
  112671. export class Gizmo implements IDisposable {
  112672. /** The utility layer the gizmo will be added to */
  112673. gizmoLayer: UtilityLayerRenderer;
  112674. /**
  112675. * The root mesh of the gizmo
  112676. */
  112677. _rootMesh: Mesh;
  112678. private _attachedMesh;
  112679. /**
  112680. * Ratio for the scale of the gizmo (Default: 1)
  112681. */
  112682. scaleRatio: number;
  112683. /**
  112684. * If a custom mesh has been set (Default: false)
  112685. */
  112686. protected _customMeshSet: boolean;
  112687. /**
  112688. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  112689. * * When set, interactions will be enabled
  112690. */
  112691. attachedMesh: Nullable<AbstractMesh>;
  112692. /**
  112693. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  112694. * @param mesh The mesh to replace the default mesh of the gizmo
  112695. */
  112696. setCustomMesh(mesh: Mesh): void;
  112697. /**
  112698. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  112699. */
  112700. updateGizmoRotationToMatchAttachedMesh: boolean;
  112701. /**
  112702. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  112703. */
  112704. updateGizmoPositionToMatchAttachedMesh: boolean;
  112705. /**
  112706. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  112707. */
  112708. updateScale: boolean;
  112709. protected _interactionsEnabled: boolean;
  112710. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112711. private _beforeRenderObserver;
  112712. private _tempVector;
  112713. /**
  112714. * Creates a gizmo
  112715. * @param gizmoLayer The utility layer the gizmo will be added to
  112716. */
  112717. constructor(
  112718. /** The utility layer the gizmo will be added to */
  112719. gizmoLayer?: UtilityLayerRenderer);
  112720. /**
  112721. * Updates the gizmo to match the attached mesh's position/rotation
  112722. */
  112723. protected _update(): void;
  112724. /**
  112725. * Disposes of the gizmo
  112726. */
  112727. dispose(): void;
  112728. }
  112729. }
  112730. declare module BABYLON {
  112731. /**
  112732. * Single plane drag gizmo
  112733. */
  112734. export class PlaneDragGizmo extends Gizmo {
  112735. /**
  112736. * Drag behavior responsible for the gizmos dragging interactions
  112737. */
  112738. dragBehavior: PointerDragBehavior;
  112739. private _pointerObserver;
  112740. /**
  112741. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112742. */
  112743. snapDistance: number;
  112744. /**
  112745. * Event that fires each time the gizmo snaps to a new location.
  112746. * * snapDistance is the the change in distance
  112747. */
  112748. onSnapObservable: Observable<{
  112749. snapDistance: number;
  112750. }>;
  112751. private _plane;
  112752. private _coloredMaterial;
  112753. private _hoverMaterial;
  112754. private _isEnabled;
  112755. private _parent;
  112756. /** @hidden */
  112757. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  112758. /** @hidden */
  112759. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112760. /**
  112761. * Creates a PlaneDragGizmo
  112762. * @param gizmoLayer The utility layer the gizmo will be added to
  112763. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  112764. * @param color The color of the gizmo
  112765. */
  112766. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112768. /**
  112769. * If the gizmo is enabled
  112770. */
  112771. isEnabled: boolean;
  112772. /**
  112773. * Disposes of the gizmo
  112774. */
  112775. dispose(): void;
  112776. }
  112777. }
  112778. declare module BABYLON {
  112779. /**
  112780. * Gizmo that enables dragging a mesh along 3 axis
  112781. */
  112782. export class PositionGizmo extends Gizmo {
  112783. /**
  112784. * Internal gizmo used for interactions on the x axis
  112785. */
  112786. xGizmo: AxisDragGizmo;
  112787. /**
  112788. * Internal gizmo used for interactions on the y axis
  112789. */
  112790. yGizmo: AxisDragGizmo;
  112791. /**
  112792. * Internal gizmo used for interactions on the z axis
  112793. */
  112794. zGizmo: AxisDragGizmo;
  112795. /**
  112796. * Internal gizmo used for interactions on the yz plane
  112797. */
  112798. xPlaneGizmo: PlaneDragGizmo;
  112799. /**
  112800. * Internal gizmo used for interactions on the xz plane
  112801. */
  112802. yPlaneGizmo: PlaneDragGizmo;
  112803. /**
  112804. * Internal gizmo used for interactions on the xy plane
  112805. */
  112806. zPlaneGizmo: PlaneDragGizmo;
  112807. /**
  112808. * private variables
  112809. */
  112810. private _meshAttached;
  112811. private _updateGizmoRotationToMatchAttachedMesh;
  112812. private _snapDistance;
  112813. private _scaleRatio;
  112814. /** Fires an event when any of it's sub gizmos are dragged */
  112815. onDragStartObservable: Observable<unknown>;
  112816. /** Fires an event when any of it's sub gizmos are released from dragging */
  112817. onDragEndObservable: Observable<unknown>;
  112818. /**
  112819. * If set to true, planar drag is enabled
  112820. */
  112821. private _planarGizmoEnabled;
  112822. attachedMesh: Nullable<AbstractMesh>;
  112823. /**
  112824. * Creates a PositionGizmo
  112825. * @param gizmoLayer The utility layer the gizmo will be added to
  112826. */
  112827. constructor(gizmoLayer?: UtilityLayerRenderer);
  112828. /**
  112829. * If the planar drag gizmo is enabled
  112830. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112831. */
  112832. planarGizmoEnabled: boolean;
  112833. updateGizmoRotationToMatchAttachedMesh: boolean;
  112834. /**
  112835. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112836. */
  112837. snapDistance: number;
  112838. /**
  112839. * Ratio for the scale of the gizmo (Default: 1)
  112840. */
  112841. scaleRatio: number;
  112842. /**
  112843. * Disposes of the gizmo
  112844. */
  112845. dispose(): void;
  112846. /**
  112847. * CustomMeshes are not supported by this gizmo
  112848. * @param mesh The mesh to replace the default mesh of the gizmo
  112849. */
  112850. setCustomMesh(mesh: Mesh): void;
  112851. }
  112852. }
  112853. declare module BABYLON {
  112854. /**
  112855. * Single axis drag gizmo
  112856. */
  112857. export class AxisDragGizmo extends Gizmo {
  112858. /**
  112859. * Drag behavior responsible for the gizmos dragging interactions
  112860. */
  112861. dragBehavior: PointerDragBehavior;
  112862. private _pointerObserver;
  112863. /**
  112864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112865. */
  112866. snapDistance: number;
  112867. /**
  112868. * Event that fires each time the gizmo snaps to a new location.
  112869. * * snapDistance is the the change in distance
  112870. */
  112871. onSnapObservable: Observable<{
  112872. snapDistance: number;
  112873. }>;
  112874. private _isEnabled;
  112875. private _parent;
  112876. private _arrow;
  112877. private _coloredMaterial;
  112878. private _hoverMaterial;
  112879. /** @hidden */
  112880. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112881. /** @hidden */
  112882. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112883. /**
  112884. * Creates an AxisDragGizmo
  112885. * @param gizmoLayer The utility layer the gizmo will be added to
  112886. * @param dragAxis The axis which the gizmo will be able to drag on
  112887. * @param color The color of the gizmo
  112888. */
  112889. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112890. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112891. /**
  112892. * If the gizmo is enabled
  112893. */
  112894. isEnabled: boolean;
  112895. /**
  112896. * Disposes of the gizmo
  112897. */
  112898. dispose(): void;
  112899. }
  112900. }
  112901. declare module BABYLON.Debug {
  112902. /**
  112903. * The Axes viewer will show 3 axes in a specific point in space
  112904. */
  112905. export class AxesViewer {
  112906. private _xAxis;
  112907. private _yAxis;
  112908. private _zAxis;
  112909. private _scaleLinesFactor;
  112910. private _instanced;
  112911. /**
  112912. * Gets the hosting scene
  112913. */
  112914. scene: Scene;
  112915. /**
  112916. * Gets or sets a number used to scale line length
  112917. */
  112918. scaleLines: number;
  112919. /** Gets the node hierarchy used to render x-axis */
  112920. readonly xAxis: TransformNode;
  112921. /** Gets the node hierarchy used to render y-axis */
  112922. readonly yAxis: TransformNode;
  112923. /** Gets the node hierarchy used to render z-axis */
  112924. readonly zAxis: TransformNode;
  112925. /**
  112926. * Creates a new AxesViewer
  112927. * @param scene defines the hosting scene
  112928. * @param scaleLines defines a number used to scale line length (1 by default)
  112929. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112930. * @param xAxis defines the node hierarchy used to render the x-axis
  112931. * @param yAxis defines the node hierarchy used to render the y-axis
  112932. * @param zAxis defines the node hierarchy used to render the z-axis
  112933. */
  112934. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112935. /**
  112936. * Force the viewer to update
  112937. * @param position defines the position of the viewer
  112938. * @param xaxis defines the x axis of the viewer
  112939. * @param yaxis defines the y axis of the viewer
  112940. * @param zaxis defines the z axis of the viewer
  112941. */
  112942. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112943. /**
  112944. * Creates an instance of this axes viewer.
  112945. * @returns a new axes viewer with instanced meshes
  112946. */
  112947. createInstance(): AxesViewer;
  112948. /** Releases resources */
  112949. dispose(): void;
  112950. private static _SetRenderingGroupId;
  112951. }
  112952. }
  112953. declare module BABYLON.Debug {
  112954. /**
  112955. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112956. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112957. */
  112958. export class BoneAxesViewer extends AxesViewer {
  112959. /**
  112960. * Gets or sets the target mesh where to display the axes viewer
  112961. */
  112962. mesh: Nullable<Mesh>;
  112963. /**
  112964. * Gets or sets the target bone where to display the axes viewer
  112965. */
  112966. bone: Nullable<Bone>;
  112967. /** Gets current position */
  112968. pos: Vector3;
  112969. /** Gets direction of X axis */
  112970. xaxis: Vector3;
  112971. /** Gets direction of Y axis */
  112972. yaxis: Vector3;
  112973. /** Gets direction of Z axis */
  112974. zaxis: Vector3;
  112975. /**
  112976. * Creates a new BoneAxesViewer
  112977. * @param scene defines the hosting scene
  112978. * @param bone defines the target bone
  112979. * @param mesh defines the target mesh
  112980. * @param scaleLines defines a scaling factor for line length (1 by default)
  112981. */
  112982. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112983. /**
  112984. * Force the viewer to update
  112985. */
  112986. update(): void;
  112987. /** Releases resources */
  112988. dispose(): void;
  112989. }
  112990. }
  112991. declare module BABYLON {
  112992. /**
  112993. * Interface used to define scene explorer extensibility option
  112994. */
  112995. export interface IExplorerExtensibilityOption {
  112996. /**
  112997. * Define the option label
  112998. */
  112999. label: string;
  113000. /**
  113001. * Defines the action to execute on click
  113002. */
  113003. action: (entity: any) => void;
  113004. }
  113005. /**
  113006. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113007. */
  113008. export interface IExplorerExtensibilityGroup {
  113009. /**
  113010. * Defines a predicate to test if a given type mut be extended
  113011. */
  113012. predicate: (entity: any) => boolean;
  113013. /**
  113014. * Gets the list of options added to a type
  113015. */
  113016. entries: IExplorerExtensibilityOption[];
  113017. }
  113018. /**
  113019. * Interface used to define the options to use to create the Inspector
  113020. */
  113021. export interface IInspectorOptions {
  113022. /**
  113023. * Display in overlay mode (default: false)
  113024. */
  113025. overlay?: boolean;
  113026. /**
  113027. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113028. */
  113029. globalRoot?: HTMLElement;
  113030. /**
  113031. * Display the Scene explorer
  113032. */
  113033. showExplorer?: boolean;
  113034. /**
  113035. * Display the property inspector
  113036. */
  113037. showInspector?: boolean;
  113038. /**
  113039. * Display in embed mode (both panes on the right)
  113040. */
  113041. embedMode?: boolean;
  113042. /**
  113043. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113044. */
  113045. handleResize?: boolean;
  113046. /**
  113047. * Allow the panes to popup (default: true)
  113048. */
  113049. enablePopup?: boolean;
  113050. /**
  113051. * Allow the panes to be closed by users (default: true)
  113052. */
  113053. enableClose?: boolean;
  113054. /**
  113055. * Optional list of extensibility entries
  113056. */
  113057. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113058. /**
  113059. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113060. */
  113061. inspectorURL?: string;
  113062. }
  113063. interface Scene {
  113064. /**
  113065. * @hidden
  113066. * Backing field
  113067. */
  113068. _debugLayer: DebugLayer;
  113069. /**
  113070. * Gets the debug layer (aka Inspector) associated with the scene
  113071. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113072. */
  113073. debugLayer: DebugLayer;
  113074. }
  113075. /**
  113076. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113077. * what is happening in your scene
  113078. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113079. */
  113080. export class DebugLayer {
  113081. /**
  113082. * Define the url to get the inspector script from.
  113083. * By default it uses the babylonjs CDN.
  113084. * @ignoreNaming
  113085. */
  113086. static InspectorURL: string;
  113087. private _scene;
  113088. private BJSINSPECTOR;
  113089. private _onPropertyChangedObservable?;
  113090. /**
  113091. * Observable triggered when a property is changed through the inspector.
  113092. */
  113093. readonly onPropertyChangedObservable: any;
  113094. /**
  113095. * Instantiates a new debug layer.
  113096. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113097. * what is happening in your scene
  113098. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113099. * @param scene Defines the scene to inspect
  113100. */
  113101. constructor(scene: Scene);
  113102. /** Creates the inspector window. */
  113103. private _createInspector;
  113104. /**
  113105. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113106. * @param entity defines the entity to select
  113107. * @param lineContainerTitle defines the specific block to highlight
  113108. */
  113109. select(entity: any, lineContainerTitle?: string): void;
  113110. /** Get the inspector from bundle or global */
  113111. private _getGlobalInspector;
  113112. /**
  113113. * Get if the inspector is visible or not.
  113114. * @returns true if visible otherwise, false
  113115. */
  113116. isVisible(): boolean;
  113117. /**
  113118. * Hide the inspector and close its window.
  113119. */
  113120. hide(): void;
  113121. /**
  113122. * Launch the debugLayer.
  113123. * @param config Define the configuration of the inspector
  113124. * @return a promise fulfilled when the debug layer is visible
  113125. */
  113126. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113127. }
  113128. }
  113129. declare module BABYLON {
  113130. /**
  113131. * Class containing static functions to help procedurally build meshes
  113132. */
  113133. export class BoxBuilder {
  113134. /**
  113135. * Creates a box mesh
  113136. * * The parameter `size` sets the size (float) of each box side (default 1)
  113137. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113138. * * 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)
  113139. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113143. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113144. * @param name defines the name of the mesh
  113145. * @param options defines the options used to create the mesh
  113146. * @param scene defines the hosting scene
  113147. * @returns the box mesh
  113148. */
  113149. static CreateBox(name: string, options: {
  113150. size?: number;
  113151. width?: number;
  113152. height?: number;
  113153. depth?: number;
  113154. faceUV?: Vector4[];
  113155. faceColors?: Color4[];
  113156. sideOrientation?: number;
  113157. frontUVs?: Vector4;
  113158. backUVs?: Vector4;
  113159. wrap?: boolean;
  113160. topBaseAt?: number;
  113161. bottomBaseAt?: number;
  113162. updatable?: boolean;
  113163. }, scene?: Nullable<Scene>): Mesh;
  113164. }
  113165. }
  113166. declare module BABYLON {
  113167. /**
  113168. * Class containing static functions to help procedurally build meshes
  113169. */
  113170. export class SphereBuilder {
  113171. /**
  113172. * Creates a sphere mesh
  113173. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113174. * * 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`)
  113175. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113176. * * 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
  113177. * * 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)
  113178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113181. * @param name defines the name of the mesh
  113182. * @param options defines the options used to create the mesh
  113183. * @param scene defines the hosting scene
  113184. * @returns the sphere mesh
  113185. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113186. */
  113187. static CreateSphere(name: string, options: {
  113188. segments?: number;
  113189. diameter?: number;
  113190. diameterX?: number;
  113191. diameterY?: number;
  113192. diameterZ?: number;
  113193. arc?: number;
  113194. slice?: number;
  113195. sideOrientation?: number;
  113196. frontUVs?: Vector4;
  113197. backUVs?: Vector4;
  113198. updatable?: boolean;
  113199. }, scene?: Nullable<Scene>): Mesh;
  113200. }
  113201. }
  113202. declare module BABYLON.Debug {
  113203. /**
  113204. * Used to show the physics impostor around the specific mesh
  113205. */
  113206. export class PhysicsViewer {
  113207. /** @hidden */
  113208. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113209. /** @hidden */
  113210. protected _meshes: Array<Nullable<AbstractMesh>>;
  113211. /** @hidden */
  113212. protected _scene: Nullable<Scene>;
  113213. /** @hidden */
  113214. protected _numMeshes: number;
  113215. /** @hidden */
  113216. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113217. private _renderFunction;
  113218. private _utilityLayer;
  113219. private _debugBoxMesh;
  113220. private _debugSphereMesh;
  113221. private _debugCylinderMesh;
  113222. private _debugMaterial;
  113223. private _debugMeshMeshes;
  113224. /**
  113225. * Creates a new PhysicsViewer
  113226. * @param scene defines the hosting scene
  113227. */
  113228. constructor(scene: Scene);
  113229. /** @hidden */
  113230. protected _updateDebugMeshes(): void;
  113231. /**
  113232. * Renders a specified physic impostor
  113233. * @param impostor defines the impostor to render
  113234. * @param targetMesh defines the mesh represented by the impostor
  113235. * @returns the new debug mesh used to render the impostor
  113236. */
  113237. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113238. /**
  113239. * Hides a specified physic impostor
  113240. * @param impostor defines the impostor to hide
  113241. */
  113242. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113243. private _getDebugMaterial;
  113244. private _getDebugBoxMesh;
  113245. private _getDebugSphereMesh;
  113246. private _getDebugCylinderMesh;
  113247. private _getDebugMeshMesh;
  113248. private _getDebugMesh;
  113249. /** Releases all resources */
  113250. dispose(): void;
  113251. }
  113252. }
  113253. declare module BABYLON {
  113254. /**
  113255. * Class containing static functions to help procedurally build meshes
  113256. */
  113257. export class LinesBuilder {
  113258. /**
  113259. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113260. * * 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
  113261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113262. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113263. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113264. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113265. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113266. * * 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
  113267. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113270. * @param name defines the name of the new line system
  113271. * @param options defines the options used to create the line system
  113272. * @param scene defines the hosting scene
  113273. * @returns a new line system mesh
  113274. */
  113275. static CreateLineSystem(name: string, options: {
  113276. lines: Vector3[][];
  113277. updatable?: boolean;
  113278. instance?: Nullable<LinesMesh>;
  113279. colors?: Nullable<Color4[][]>;
  113280. useVertexAlpha?: boolean;
  113281. }, scene: Nullable<Scene>): LinesMesh;
  113282. /**
  113283. * Creates a line mesh
  113284. * 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
  113285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113286. * * The parameter `points` is an array successive Vector3
  113287. * * 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
  113288. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113290. * * When updating an instance, remember that only point positions can change, not the number of points
  113291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113293. * @param name defines the name of the new line system
  113294. * @param options defines the options used to create the line system
  113295. * @param scene defines the hosting scene
  113296. * @returns a new line mesh
  113297. */
  113298. static CreateLines(name: string, options: {
  113299. points: Vector3[];
  113300. updatable?: boolean;
  113301. instance?: Nullable<LinesMesh>;
  113302. colors?: Color4[];
  113303. useVertexAlpha?: boolean;
  113304. }, scene?: Nullable<Scene>): LinesMesh;
  113305. /**
  113306. * Creates a dashed line mesh
  113307. * * 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
  113308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113309. * * The parameter `points` is an array successive Vector3
  113310. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113311. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113312. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113313. * * 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
  113314. * * When updating an instance, remember that only point positions can change, not the number of points
  113315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113316. * @param name defines the name of the mesh
  113317. * @param options defines the options used to create the mesh
  113318. * @param scene defines the hosting scene
  113319. * @returns the dashed line mesh
  113320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113321. */
  113322. static CreateDashedLines(name: string, options: {
  113323. points: Vector3[];
  113324. dashSize?: number;
  113325. gapSize?: number;
  113326. dashNb?: number;
  113327. updatable?: boolean;
  113328. instance?: LinesMesh;
  113329. }, scene?: Nullable<Scene>): LinesMesh;
  113330. }
  113331. }
  113332. declare module BABYLON {
  113333. /**
  113334. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113335. * in order to better appreciate the issue one might have.
  113336. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113337. */
  113338. export class RayHelper {
  113339. /**
  113340. * Defines the ray we are currently tryin to visualize.
  113341. */
  113342. ray: Nullable<Ray>;
  113343. private _renderPoints;
  113344. private _renderLine;
  113345. private _renderFunction;
  113346. private _scene;
  113347. private _updateToMeshFunction;
  113348. private _attachedToMesh;
  113349. private _meshSpaceDirection;
  113350. private _meshSpaceOrigin;
  113351. /**
  113352. * Helper function to create a colored helper in a scene in one line.
  113353. * @param ray Defines the ray we are currently tryin to visualize
  113354. * @param scene Defines the scene the ray is used in
  113355. * @param color Defines the color we want to see the ray in
  113356. * @returns The newly created ray helper.
  113357. */
  113358. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  113359. /**
  113360. * Instantiate a new ray helper.
  113361. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113362. * in order to better appreciate the issue one might have.
  113363. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113364. * @param ray Defines the ray we are currently tryin to visualize
  113365. */
  113366. constructor(ray: Ray);
  113367. /**
  113368. * Shows the ray we are willing to debug.
  113369. * @param scene Defines the scene the ray needs to be rendered in
  113370. * @param color Defines the color the ray needs to be rendered in
  113371. */
  113372. show(scene: Scene, color?: Color3): void;
  113373. /**
  113374. * Hides the ray we are debugging.
  113375. */
  113376. hide(): void;
  113377. private _render;
  113378. /**
  113379. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  113380. * @param mesh Defines the mesh we want the helper attached to
  113381. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  113382. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  113383. * @param length Defines the length of the ray
  113384. */
  113385. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  113386. /**
  113387. * Detach the ray helper from the mesh it has previously been attached to.
  113388. */
  113389. detachFromMesh(): void;
  113390. private _updateToMesh;
  113391. /**
  113392. * Dispose the helper and release its associated resources.
  113393. */
  113394. dispose(): void;
  113395. }
  113396. }
  113397. declare module BABYLON.Debug {
  113398. /**
  113399. * Class used to render a debug view of a given skeleton
  113400. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  113401. */
  113402. export class SkeletonViewer {
  113403. /** defines the skeleton to render */
  113404. skeleton: Skeleton;
  113405. /** defines the mesh attached to the skeleton */
  113406. mesh: AbstractMesh;
  113407. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113408. autoUpdateBonesMatrices: boolean;
  113409. /** defines the rendering group id to use with the viewer */
  113410. renderingGroupId: number;
  113411. /** Gets or sets the color used to render the skeleton */
  113412. color: Color3;
  113413. private _scene;
  113414. private _debugLines;
  113415. private _debugMesh;
  113416. private _isEnabled;
  113417. private _renderFunction;
  113418. private _utilityLayer;
  113419. /**
  113420. * Returns the mesh used to render the bones
  113421. */
  113422. readonly debugMesh: Nullable<LinesMesh>;
  113423. /**
  113424. * Creates a new SkeletonViewer
  113425. * @param skeleton defines the skeleton to render
  113426. * @param mesh defines the mesh attached to the skeleton
  113427. * @param scene defines the hosting scene
  113428. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  113429. * @param renderingGroupId defines the rendering group id to use with the viewer
  113430. */
  113431. constructor(
  113432. /** defines the skeleton to render */
  113433. skeleton: Skeleton,
  113434. /** defines the mesh attached to the skeleton */
  113435. mesh: AbstractMesh, scene: Scene,
  113436. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  113437. autoUpdateBonesMatrices?: boolean,
  113438. /** defines the rendering group id to use with the viewer */
  113439. renderingGroupId?: number);
  113440. /** Gets or sets a boolean indicating if the viewer is enabled */
  113441. isEnabled: boolean;
  113442. private _getBonePosition;
  113443. private _getLinesForBonesWithLength;
  113444. private _getLinesForBonesNoLength;
  113445. /** Update the viewer to sync with current skeleton state */
  113446. update(): void;
  113447. /** Release associated resources */
  113448. dispose(): void;
  113449. }
  113450. }
  113451. declare module BABYLON {
  113452. /**
  113453. * Options to create the null engine
  113454. */
  113455. export class NullEngineOptions {
  113456. /**
  113457. * Render width (Default: 512)
  113458. */
  113459. renderWidth: number;
  113460. /**
  113461. * Render height (Default: 256)
  113462. */
  113463. renderHeight: number;
  113464. /**
  113465. * Texture size (Default: 512)
  113466. */
  113467. textureSize: number;
  113468. /**
  113469. * If delta time between frames should be constant
  113470. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113471. */
  113472. deterministicLockstep: boolean;
  113473. /**
  113474. * Maximum about of steps between frames (Default: 4)
  113475. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113476. */
  113477. lockstepMaxSteps: number;
  113478. }
  113479. /**
  113480. * The null engine class provides support for headless version of babylon.js.
  113481. * This can be used in server side scenario or for testing purposes
  113482. */
  113483. export class NullEngine extends Engine {
  113484. private _options;
  113485. /**
  113486. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  113487. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113488. * @returns true if engine is in deterministic lock step mode
  113489. */
  113490. isDeterministicLockStep(): boolean;
  113491. /**
  113492. * Gets the max steps when engine is running in deterministic lock step
  113493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113494. * @returns the max steps
  113495. */
  113496. getLockstepMaxSteps(): number;
  113497. /**
  113498. * Gets the current hardware scaling level.
  113499. * By default the hardware scaling level is computed from the window device ratio.
  113500. * 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.
  113501. * @returns a number indicating the current hardware scaling level
  113502. */
  113503. getHardwareScalingLevel(): number;
  113504. constructor(options?: NullEngineOptions);
  113505. /**
  113506. * Creates a vertex buffer
  113507. * @param vertices the data for the vertex buffer
  113508. * @returns the new WebGL static buffer
  113509. */
  113510. createVertexBuffer(vertices: FloatArray): DataBuffer;
  113511. /**
  113512. * Creates a new index buffer
  113513. * @param indices defines the content of the index buffer
  113514. * @param updatable defines if the index buffer must be updatable
  113515. * @returns a new webGL buffer
  113516. */
  113517. createIndexBuffer(indices: IndicesArray): DataBuffer;
  113518. /**
  113519. * Clear the current render buffer or the current render target (if any is set up)
  113520. * @param color defines the color to use
  113521. * @param backBuffer defines if the back buffer must be cleared
  113522. * @param depth defines if the depth buffer must be cleared
  113523. * @param stencil defines if the stencil buffer must be cleared
  113524. */
  113525. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113526. /**
  113527. * Gets the current render width
  113528. * @param useScreen defines if screen size must be used (or the current render target if any)
  113529. * @returns a number defining the current render width
  113530. */
  113531. getRenderWidth(useScreen?: boolean): number;
  113532. /**
  113533. * Gets the current render height
  113534. * @param useScreen defines if screen size must be used (or the current render target if any)
  113535. * @returns a number defining the current render height
  113536. */
  113537. getRenderHeight(useScreen?: boolean): number;
  113538. /**
  113539. * Set the WebGL's viewport
  113540. * @param viewport defines the viewport element to be used
  113541. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113542. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113543. */
  113544. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113545. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  113546. /**
  113547. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113548. * @param pipelineContext defines the pipeline context to use
  113549. * @param uniformsNames defines the list of uniform names
  113550. * @returns an array of webGL uniform locations
  113551. */
  113552. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113553. /**
  113554. * Gets the lsit of active attributes for a given webGL program
  113555. * @param pipelineContext defines the pipeline context to use
  113556. * @param attributesNames defines the list of attribute names to get
  113557. * @returns an array of indices indicating the offset of each attribute
  113558. */
  113559. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113560. /**
  113561. * Binds an effect to the webGL context
  113562. * @param effect defines the effect to bind
  113563. */
  113564. bindSamplers(effect: Effect): void;
  113565. /**
  113566. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113567. * @param effect defines the effect to activate
  113568. */
  113569. enableEffect(effect: Effect): void;
  113570. /**
  113571. * Set various states to the webGL context
  113572. * @param culling defines backface culling state
  113573. * @param zOffset defines the value to apply to zOffset (0 by default)
  113574. * @param force defines if states must be applied even if cache is up to date
  113575. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  113576. */
  113577. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113578. /**
  113579. * Set the value of an uniform to an array of int32
  113580. * @param uniform defines the webGL uniform location where to store the value
  113581. * @param array defines the array of int32 to store
  113582. */
  113583. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113584. /**
  113585. * Set the value of an uniform to an array of int32 (stored as vec2)
  113586. * @param uniform defines the webGL uniform location where to store the value
  113587. * @param array defines the array of int32 to store
  113588. */
  113589. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113590. /**
  113591. * Set the value of an uniform to an array of int32 (stored as vec3)
  113592. * @param uniform defines the webGL uniform location where to store the value
  113593. * @param array defines the array of int32 to store
  113594. */
  113595. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113596. /**
  113597. * Set the value of an uniform to an array of int32 (stored as vec4)
  113598. * @param uniform defines the webGL uniform location where to store the value
  113599. * @param array defines the array of int32 to store
  113600. */
  113601. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113602. /**
  113603. * Set the value of an uniform to an array of float32
  113604. * @param uniform defines the webGL uniform location where to store the value
  113605. * @param array defines the array of float32 to store
  113606. */
  113607. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113608. /**
  113609. * Set the value of an uniform to an array of float32 (stored as vec2)
  113610. * @param uniform defines the webGL uniform location where to store the value
  113611. * @param array defines the array of float32 to store
  113612. */
  113613. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113614. /**
  113615. * Set the value of an uniform to an array of float32 (stored as vec3)
  113616. * @param uniform defines the webGL uniform location where to store the value
  113617. * @param array defines the array of float32 to store
  113618. */
  113619. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113620. /**
  113621. * Set the value of an uniform to an array of float32 (stored as vec4)
  113622. * @param uniform defines the webGL uniform location where to store the value
  113623. * @param array defines the array of float32 to store
  113624. */
  113625. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113626. /**
  113627. * Set the value of an uniform to an array of number
  113628. * @param uniform defines the webGL uniform location where to store the value
  113629. * @param array defines the array of number to store
  113630. */
  113631. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113632. /**
  113633. * Set the value of an uniform to an array of number (stored as vec2)
  113634. * @param uniform defines the webGL uniform location where to store the value
  113635. * @param array defines the array of number to store
  113636. */
  113637. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113638. /**
  113639. * Set the value of an uniform to an array of number (stored as vec3)
  113640. * @param uniform defines the webGL uniform location where to store the value
  113641. * @param array defines the array of number to store
  113642. */
  113643. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113644. /**
  113645. * Set the value of an uniform to an array of number (stored as vec4)
  113646. * @param uniform defines the webGL uniform location where to store the value
  113647. * @param array defines the array of number to store
  113648. */
  113649. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113650. /**
  113651. * Set the value of an uniform to an array of float32 (stored as matrices)
  113652. * @param uniform defines the webGL uniform location where to store the value
  113653. * @param matrices defines the array of float32 to store
  113654. */
  113655. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113656. /**
  113657. * Set the value of an uniform to a matrix (3x3)
  113658. * @param uniform defines the webGL uniform location where to store the value
  113659. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113660. */
  113661. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113662. /**
  113663. * Set the value of an uniform to a matrix (2x2)
  113664. * @param uniform defines the webGL uniform location where to store the value
  113665. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113666. */
  113667. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113668. /**
  113669. * Set the value of an uniform to a number (float)
  113670. * @param uniform defines the webGL uniform location where to store the value
  113671. * @param value defines the float number to store
  113672. */
  113673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113674. /**
  113675. * Set the value of an uniform to a vec2
  113676. * @param uniform defines the webGL uniform location where to store the value
  113677. * @param x defines the 1st component of the value
  113678. * @param y defines the 2nd component of the value
  113679. */
  113680. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113681. /**
  113682. * Set the value of an uniform to a vec3
  113683. * @param uniform defines the webGL uniform location where to store the value
  113684. * @param x defines the 1st component of the value
  113685. * @param y defines the 2nd component of the value
  113686. * @param z defines the 3rd component of the value
  113687. */
  113688. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113689. /**
  113690. * Set the value of an uniform to a boolean
  113691. * @param uniform defines the webGL uniform location where to store the value
  113692. * @param bool defines the boolean to store
  113693. */
  113694. setBool(uniform: WebGLUniformLocation, bool: number): void;
  113695. /**
  113696. * Set the value of an uniform to a vec4
  113697. * @param uniform defines the webGL uniform location where to store the value
  113698. * @param x defines the 1st component of the value
  113699. * @param y defines the 2nd component of the value
  113700. * @param z defines the 3rd component of the value
  113701. * @param w defines the 4th component of the value
  113702. */
  113703. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113704. /**
  113705. * Sets the current alpha mode
  113706. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113707. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113708. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113709. */
  113710. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113711. /**
  113712. * Bind webGl buffers directly to the webGL context
  113713. * @param vertexBuffers defines the vertex buffer to bind
  113714. * @param indexBuffer defines the index buffer to bind
  113715. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113716. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113717. * @param effect defines the effect associated with the vertex buffer
  113718. */
  113719. bindBuffers(vertexBuffers: {
  113720. [key: string]: VertexBuffer;
  113721. }, indexBuffer: DataBuffer, effect: Effect): void;
  113722. /**
  113723. * Force the entire cache to be cleared
  113724. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113725. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113726. */
  113727. wipeCaches(bruteForce?: boolean): void;
  113728. /**
  113729. * Send a draw order
  113730. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113731. * @param indexStart defines the starting index
  113732. * @param indexCount defines the number of index to draw
  113733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113734. */
  113735. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113736. /**
  113737. * Draw a list of indexed primitives
  113738. * @param fillMode defines the primitive to use
  113739. * @param indexStart defines the starting index
  113740. * @param indexCount defines the number of index to draw
  113741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113742. */
  113743. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113744. /**
  113745. * Draw a list of unindexed primitives
  113746. * @param fillMode defines the primitive to use
  113747. * @param verticesStart defines the index of first vertex to draw
  113748. * @param verticesCount defines the count of vertices to draw
  113749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113750. */
  113751. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113752. /** @hidden */
  113753. _createTexture(): WebGLTexture;
  113754. /** @hidden */
  113755. _releaseTexture(texture: InternalTexture): void;
  113756. /**
  113757. * Usually called from Texture.ts.
  113758. * Passed information to create a WebGLTexture
  113759. * @param urlArg defines a value which contains one of the following:
  113760. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113761. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113762. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113763. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113764. * @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)
  113765. * @param scene needed for loading to the correct scene
  113766. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113767. * @param onLoad optional callback to be called upon successful completion
  113768. * @param onError optional callback to be called upon failure
  113769. * @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
  113770. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113771. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113772. * @param forcedExtension defines the extension to use to pick the right loader
  113773. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  113774. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113775. */
  113776. 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;
  113777. /**
  113778. * Creates a new render target texture
  113779. * @param size defines the size of the texture
  113780. * @param options defines the options used to create the texture
  113781. * @returns a new render target texture stored in an InternalTexture
  113782. */
  113783. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  113784. /**
  113785. * Update the sampling mode of a given texture
  113786. * @param samplingMode defines the required sampling mode
  113787. * @param texture defines the texture to update
  113788. */
  113789. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113790. /**
  113791. * Binds the frame buffer to the specified texture.
  113792. * @param texture The texture to render to or null for the default canvas
  113793. * @param faceIndex The face of the texture to render to in case of cube texture
  113794. * @param requiredWidth The width of the target to render to
  113795. * @param requiredHeight The height of the target to render to
  113796. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113797. * @param depthStencilTexture The depth stencil texture to use to render
  113798. * @param lodLevel defines le lod level to bind to the frame buffer
  113799. */
  113800. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113801. /**
  113802. * Unbind the current render target texture from the webGL context
  113803. * @param texture defines the render target texture to unbind
  113804. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113805. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113806. */
  113807. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113808. /**
  113809. * Creates a dynamic vertex buffer
  113810. * @param vertices the data for the dynamic vertex buffer
  113811. * @returns the new WebGL dynamic buffer
  113812. */
  113813. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113814. /**
  113815. * Update the content of a dynamic texture
  113816. * @param texture defines the texture to update
  113817. * @param canvas defines the canvas containing the source
  113818. * @param invertY defines if data must be stored with Y axis inverted
  113819. * @param premulAlpha defines if alpha is stored as premultiplied
  113820. * @param format defines the format of the data
  113821. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113822. */
  113823. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113824. /**
  113825. * Gets a boolean indicating if all created effects are ready
  113826. * @returns true if all effects are ready
  113827. */
  113828. areAllEffectsReady(): boolean;
  113829. /**
  113830. * @hidden
  113831. * Get the current error code of the webGL context
  113832. * @returns the error code
  113833. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113834. */
  113835. getError(): number;
  113836. /** @hidden */
  113837. _getUnpackAlignement(): number;
  113838. /** @hidden */
  113839. _unpackFlipY(value: boolean): void;
  113840. /**
  113841. * Update a dynamic index buffer
  113842. * @param indexBuffer defines the target index buffer
  113843. * @param indices defines the data to update
  113844. * @param offset defines the offset in the target index buffer where update should start
  113845. */
  113846. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113847. /**
  113848. * Updates a dynamic vertex buffer.
  113849. * @param vertexBuffer the vertex buffer to update
  113850. * @param vertices the data used to update the vertex buffer
  113851. * @param byteOffset the byte offset of the data (optional)
  113852. * @param byteLength the byte length of the data (optional)
  113853. */
  113854. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113855. /** @hidden */
  113856. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113857. /** @hidden */
  113858. _bindTexture(channel: number, texture: InternalTexture): void;
  113859. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113860. /**
  113861. * 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
  113862. */
  113863. releaseEffects(): void;
  113864. displayLoadingUI(): void;
  113865. hideLoadingUI(): void;
  113866. /** @hidden */
  113867. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113868. /** @hidden */
  113869. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113870. /** @hidden */
  113871. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113872. /** @hidden */
  113873. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113874. }
  113875. }
  113876. declare module BABYLON {
  113877. /** @hidden */
  113878. export class _OcclusionDataStorage {
  113879. /** @hidden */
  113880. occlusionInternalRetryCounter: number;
  113881. /** @hidden */
  113882. isOcclusionQueryInProgress: boolean;
  113883. /** @hidden */
  113884. isOccluded: boolean;
  113885. /** @hidden */
  113886. occlusionRetryCount: number;
  113887. /** @hidden */
  113888. occlusionType: number;
  113889. /** @hidden */
  113890. occlusionQueryAlgorithmType: number;
  113891. }
  113892. interface Engine {
  113893. /**
  113894. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113895. * @return the new query
  113896. */
  113897. createQuery(): WebGLQuery;
  113898. /**
  113899. * Delete and release a webGL query
  113900. * @param query defines the query to delete
  113901. * @return the current engine
  113902. */
  113903. deleteQuery(query: WebGLQuery): Engine;
  113904. /**
  113905. * Check if a given query has resolved and got its value
  113906. * @param query defines the query to check
  113907. * @returns true if the query got its value
  113908. */
  113909. isQueryResultAvailable(query: WebGLQuery): boolean;
  113910. /**
  113911. * Gets the value of a given query
  113912. * @param query defines the query to check
  113913. * @returns the value of the query
  113914. */
  113915. getQueryResult(query: WebGLQuery): number;
  113916. /**
  113917. * Initiates an occlusion query
  113918. * @param algorithmType defines the algorithm to use
  113919. * @param query defines the query to use
  113920. * @returns the current engine
  113921. * @see http://doc.babylonjs.com/features/occlusionquery
  113922. */
  113923. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113924. /**
  113925. * Ends an occlusion query
  113926. * @see http://doc.babylonjs.com/features/occlusionquery
  113927. * @param algorithmType defines the algorithm to use
  113928. * @returns the current engine
  113929. */
  113930. endOcclusionQuery(algorithmType: number): Engine;
  113931. /**
  113932. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113933. * Please note that only one query can be issued at a time
  113934. * @returns a time token used to track the time span
  113935. */
  113936. startTimeQuery(): Nullable<_TimeToken>;
  113937. /**
  113938. * Ends a time query
  113939. * @param token defines the token used to measure the time span
  113940. * @returns the time spent (in ns)
  113941. */
  113942. endTimeQuery(token: _TimeToken): int;
  113943. /** @hidden */
  113944. _currentNonTimestampToken: Nullable<_TimeToken>;
  113945. /** @hidden */
  113946. _createTimeQuery(): WebGLQuery;
  113947. /** @hidden */
  113948. _deleteTimeQuery(query: WebGLQuery): void;
  113949. /** @hidden */
  113950. _getGlAlgorithmType(algorithmType: number): number;
  113951. /** @hidden */
  113952. _getTimeQueryResult(query: WebGLQuery): any;
  113953. /** @hidden */
  113954. _getTimeQueryAvailability(query: WebGLQuery): any;
  113955. }
  113956. interface AbstractMesh {
  113957. /**
  113958. * Backing filed
  113959. * @hidden
  113960. */
  113961. __occlusionDataStorage: _OcclusionDataStorage;
  113962. /**
  113963. * Access property
  113964. * @hidden
  113965. */
  113966. _occlusionDataStorage: _OcclusionDataStorage;
  113967. /**
  113968. * 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.
  113969. * The default value is -1 which means don't break the query and wait till the result
  113970. * @see http://doc.babylonjs.com/features/occlusionquery
  113971. */
  113972. occlusionRetryCount: number;
  113973. /**
  113974. * 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:
  113975. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113976. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113977. * * 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.
  113978. * @see http://doc.babylonjs.com/features/occlusionquery
  113979. */
  113980. occlusionType: number;
  113981. /**
  113982. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113983. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113984. * * 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.
  113985. * @see http://doc.babylonjs.com/features/occlusionquery
  113986. */
  113987. occlusionQueryAlgorithmType: number;
  113988. /**
  113989. * 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
  113990. * @see http://doc.babylonjs.com/features/occlusionquery
  113991. */
  113992. isOccluded: boolean;
  113993. /**
  113994. * Flag to check the progress status of the query
  113995. * @see http://doc.babylonjs.com/features/occlusionquery
  113996. */
  113997. isOcclusionQueryInProgress: boolean;
  113998. }
  113999. }
  114000. declare module BABYLON {
  114001. /** @hidden */
  114002. export var _forceTransformFeedbackToBundle: boolean;
  114003. interface Engine {
  114004. /**
  114005. * Creates a webGL transform feedback object
  114006. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114007. * @returns the webGL transform feedback object
  114008. */
  114009. createTransformFeedback(): WebGLTransformFeedback;
  114010. /**
  114011. * Delete a webGL transform feedback object
  114012. * @param value defines the webGL transform feedback object to delete
  114013. */
  114014. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114015. /**
  114016. * Bind a webGL transform feedback object to the webgl context
  114017. * @param value defines the webGL transform feedback object to bind
  114018. */
  114019. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114020. /**
  114021. * Begins a transform feedback operation
  114022. * @param usePoints defines if points or triangles must be used
  114023. */
  114024. beginTransformFeedback(usePoints: boolean): void;
  114025. /**
  114026. * Ends a transform feedback operation
  114027. */
  114028. endTransformFeedback(): void;
  114029. /**
  114030. * Specify the varyings to use with transform feedback
  114031. * @param program defines the associated webGL program
  114032. * @param value defines the list of strings representing the varying names
  114033. */
  114034. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114035. /**
  114036. * Bind a webGL buffer for a transform feedback operation
  114037. * @param value defines the webGL buffer to bind
  114038. */
  114039. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114040. }
  114041. }
  114042. declare module BABYLON {
  114043. /**
  114044. * Creation options of the multi render target texture.
  114045. */
  114046. export interface IMultiRenderTargetOptions {
  114047. /**
  114048. * Define if the texture needs to create mip maps after render.
  114049. */
  114050. generateMipMaps?: boolean;
  114051. /**
  114052. * Define the types of all the draw buffers we want to create
  114053. */
  114054. types?: number[];
  114055. /**
  114056. * Define the sampling modes of all the draw buffers we want to create
  114057. */
  114058. samplingModes?: number[];
  114059. /**
  114060. * Define if a depth buffer is required
  114061. */
  114062. generateDepthBuffer?: boolean;
  114063. /**
  114064. * Define if a stencil buffer is required
  114065. */
  114066. generateStencilBuffer?: boolean;
  114067. /**
  114068. * Define if a depth texture is required instead of a depth buffer
  114069. */
  114070. generateDepthTexture?: boolean;
  114071. /**
  114072. * Define the number of desired draw buffers
  114073. */
  114074. textureCount?: number;
  114075. /**
  114076. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114077. */
  114078. doNotChangeAspectRatio?: boolean;
  114079. /**
  114080. * Define the default type of the buffers we are creating
  114081. */
  114082. defaultType?: number;
  114083. }
  114084. /**
  114085. * A multi render target, like a render target provides the ability to render to a texture.
  114086. * Unlike the render target, it can render to several draw buffers in one draw.
  114087. * This is specially interesting in deferred rendering or for any effects requiring more than
  114088. * just one color from a single pass.
  114089. */
  114090. export class MultiRenderTarget extends RenderTargetTexture {
  114091. private _internalTextures;
  114092. private _textures;
  114093. private _multiRenderTargetOptions;
  114094. /**
  114095. * Get if draw buffers are currently supported by the used hardware and browser.
  114096. */
  114097. readonly isSupported: boolean;
  114098. /**
  114099. * Get the list of textures generated by the multi render target.
  114100. */
  114101. readonly textures: Texture[];
  114102. /**
  114103. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114104. */
  114105. readonly depthTexture: Texture;
  114106. /**
  114107. * Set the wrapping mode on U of all the textures we are rendering to.
  114108. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114109. */
  114110. wrapU: number;
  114111. /**
  114112. * Set the wrapping mode on V of all the textures we are rendering to.
  114113. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114114. */
  114115. wrapV: number;
  114116. /**
  114117. * Instantiate a new multi render target texture.
  114118. * A multi render target, like a render target provides the ability to render to a texture.
  114119. * Unlike the render target, it can render to several draw buffers in one draw.
  114120. * This is specially interesting in deferred rendering or for any effects requiring more than
  114121. * just one color from a single pass.
  114122. * @param name Define the name of the texture
  114123. * @param size Define the size of the buffers to render to
  114124. * @param count Define the number of target we are rendering into
  114125. * @param scene Define the scene the texture belongs to
  114126. * @param options Define the options used to create the multi render target
  114127. */
  114128. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114129. /** @hidden */
  114130. _rebuild(): void;
  114131. private _createInternalTextures;
  114132. private _createTextures;
  114133. /**
  114134. * Define the number of samples used if MSAA is enabled.
  114135. */
  114136. samples: number;
  114137. /**
  114138. * Resize all the textures in the multi render target.
  114139. * Be carrefull as it will recreate all the data in the new texture.
  114140. * @param size Define the new size
  114141. */
  114142. resize(size: any): void;
  114143. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114144. /**
  114145. * Dispose the render targets and their associated resources
  114146. */
  114147. dispose(): void;
  114148. /**
  114149. * Release all the underlying texture used as draw buffers.
  114150. */
  114151. releaseInternalTextures(): void;
  114152. }
  114153. }
  114154. declare module BABYLON {
  114155. interface ThinEngine {
  114156. /**
  114157. * Unbind a list of render target textures from the webGL context
  114158. * This is used only when drawBuffer extension or webGL2 are active
  114159. * @param textures defines the render target textures to unbind
  114160. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114161. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114162. */
  114163. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114164. /**
  114165. * Create a multi render target texture
  114166. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114167. * @param size defines the size of the texture
  114168. * @param options defines the creation options
  114169. * @returns the cube texture as an InternalTexture
  114170. */
  114171. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114172. /**
  114173. * Update the sample count for a given multiple render target texture
  114174. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114175. * @param textures defines the textures to update
  114176. * @param samples defines the sample count to set
  114177. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114178. */
  114179. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114180. }
  114181. }
  114182. declare module BABYLON {
  114183. /**
  114184. * Class used to define an additional view for the engine
  114185. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114186. */
  114187. export class EngineView {
  114188. /** Defines the canvas where to render the view */
  114189. target: HTMLCanvasElement;
  114190. /** Defines an optional camera used to render the view (will use active camera else) */
  114191. camera?: Camera;
  114192. }
  114193. interface Engine {
  114194. /**
  114195. * Gets or sets the HTML element to use for attaching events
  114196. */
  114197. inputElement: Nullable<HTMLElement>;
  114198. /**
  114199. * Gets the current engine view
  114200. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114201. */
  114202. activeView: Nullable<EngineView>;
  114203. /** Gets or sets the list of views */
  114204. views: EngineView[];
  114205. /**
  114206. * Register a new child canvas
  114207. * @param canvas defines the canvas to register
  114208. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114209. * @returns the associated view
  114210. */
  114211. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114212. /**
  114213. * Remove a registered child canvas
  114214. * @param canvas defines the canvas to remove
  114215. * @returns the current engine
  114216. */
  114217. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114218. }
  114219. }
  114220. declare module BABYLON {
  114221. /**
  114222. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114223. */
  114224. export interface CubeMapInfo {
  114225. /**
  114226. * The pixel array for the front face.
  114227. * This is stored in format, left to right, up to down format.
  114228. */
  114229. front: Nullable<ArrayBufferView>;
  114230. /**
  114231. * The pixel array for the back face.
  114232. * This is stored in format, left to right, up to down format.
  114233. */
  114234. back: Nullable<ArrayBufferView>;
  114235. /**
  114236. * The pixel array for the left face.
  114237. * This is stored in format, left to right, up to down format.
  114238. */
  114239. left: Nullable<ArrayBufferView>;
  114240. /**
  114241. * The pixel array for the right face.
  114242. * This is stored in format, left to right, up to down format.
  114243. */
  114244. right: Nullable<ArrayBufferView>;
  114245. /**
  114246. * The pixel array for the up face.
  114247. * This is stored in format, left to right, up to down format.
  114248. */
  114249. up: Nullable<ArrayBufferView>;
  114250. /**
  114251. * The pixel array for the down face.
  114252. * This is stored in format, left to right, up to down format.
  114253. */
  114254. down: Nullable<ArrayBufferView>;
  114255. /**
  114256. * The size of the cubemap stored.
  114257. *
  114258. * Each faces will be size * size pixels.
  114259. */
  114260. size: number;
  114261. /**
  114262. * The format of the texture.
  114263. *
  114264. * RGBA, RGB.
  114265. */
  114266. format: number;
  114267. /**
  114268. * The type of the texture data.
  114269. *
  114270. * UNSIGNED_INT, FLOAT.
  114271. */
  114272. type: number;
  114273. /**
  114274. * Specifies whether the texture is in gamma space.
  114275. */
  114276. gammaSpace: boolean;
  114277. }
  114278. /**
  114279. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114280. */
  114281. export class PanoramaToCubeMapTools {
  114282. private static FACE_FRONT;
  114283. private static FACE_BACK;
  114284. private static FACE_RIGHT;
  114285. private static FACE_LEFT;
  114286. private static FACE_DOWN;
  114287. private static FACE_UP;
  114288. /**
  114289. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114290. *
  114291. * @param float32Array The source data.
  114292. * @param inputWidth The width of the input panorama.
  114293. * @param inputHeight The height of the input panorama.
  114294. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114295. * @return The cubemap data
  114296. */
  114297. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114298. private static CreateCubemapTexture;
  114299. private static CalcProjectionSpherical;
  114300. }
  114301. }
  114302. declare module BABYLON {
  114303. /**
  114304. * Helper class dealing with the extraction of spherical polynomial dataArray
  114305. * from a cube map.
  114306. */
  114307. export class CubeMapToSphericalPolynomialTools {
  114308. private static FileFaces;
  114309. /**
  114310. * Converts a texture to the according Spherical Polynomial data.
  114311. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114312. *
  114313. * @param texture The texture to extract the information from.
  114314. * @return The Spherical Polynomial data.
  114315. */
  114316. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114317. /**
  114318. * Converts a cubemap to the according Spherical Polynomial data.
  114319. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114320. *
  114321. * @param cubeInfo The Cube map to extract the information from.
  114322. * @return The Spherical Polynomial data.
  114323. */
  114324. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114325. }
  114326. }
  114327. declare module BABYLON {
  114328. interface BaseTexture {
  114329. /**
  114330. * Get the polynomial representation of the texture data.
  114331. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114332. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114333. */
  114334. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114335. }
  114336. }
  114337. declare module BABYLON {
  114338. /** @hidden */
  114339. export var rgbdEncodePixelShader: {
  114340. name: string;
  114341. shader: string;
  114342. };
  114343. }
  114344. declare module BABYLON {
  114345. /** @hidden */
  114346. export var rgbdDecodePixelShader: {
  114347. name: string;
  114348. shader: string;
  114349. };
  114350. }
  114351. declare module BABYLON {
  114352. /**
  114353. * Raw texture data and descriptor sufficient for WebGL texture upload
  114354. */
  114355. export interface EnvironmentTextureInfo {
  114356. /**
  114357. * Version of the environment map
  114358. */
  114359. version: number;
  114360. /**
  114361. * Width of image
  114362. */
  114363. width: number;
  114364. /**
  114365. * Irradiance information stored in the file.
  114366. */
  114367. irradiance: any;
  114368. /**
  114369. * Specular information stored in the file.
  114370. */
  114371. specular: any;
  114372. }
  114373. /**
  114374. * Defines One Image in the file. It requires only the position in the file
  114375. * as well as the length.
  114376. */
  114377. interface BufferImageData {
  114378. /**
  114379. * Length of the image data.
  114380. */
  114381. length: number;
  114382. /**
  114383. * Position of the data from the null terminator delimiting the end of the JSON.
  114384. */
  114385. position: number;
  114386. }
  114387. /**
  114388. * Defines the specular data enclosed in the file.
  114389. * This corresponds to the version 1 of the data.
  114390. */
  114391. export interface EnvironmentTextureSpecularInfoV1 {
  114392. /**
  114393. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  114394. */
  114395. specularDataPosition?: number;
  114396. /**
  114397. * This contains all the images data needed to reconstruct the cubemap.
  114398. */
  114399. mipmaps: Array<BufferImageData>;
  114400. /**
  114401. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  114402. */
  114403. lodGenerationScale: number;
  114404. }
  114405. /**
  114406. * Sets of helpers addressing the serialization and deserialization of environment texture
  114407. * stored in a BabylonJS env file.
  114408. * Those files are usually stored as .env files.
  114409. */
  114410. export class EnvironmentTextureTools {
  114411. /**
  114412. * Magic number identifying the env file.
  114413. */
  114414. private static _MagicBytes;
  114415. /**
  114416. * Gets the environment info from an env file.
  114417. * @param data The array buffer containing the .env bytes.
  114418. * @returns the environment file info (the json header) if successfully parsed.
  114419. */
  114420. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  114421. /**
  114422. * Creates an environment texture from a loaded cube texture.
  114423. * @param texture defines the cube texture to convert in env file
  114424. * @return a promise containing the environment data if succesfull.
  114425. */
  114426. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  114427. /**
  114428. * Creates a JSON representation of the spherical data.
  114429. * @param texture defines the texture containing the polynomials
  114430. * @return the JSON representation of the spherical info
  114431. */
  114432. private static _CreateEnvTextureIrradiance;
  114433. /**
  114434. * Creates the ArrayBufferViews used for initializing environment texture image data.
  114435. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  114436. * @param info parameters that determine what views will be created for accessing the underlying buffer
  114437. * @return the views described by info providing access to the underlying buffer
  114438. */
  114439. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  114440. /**
  114441. * Uploads the texture info contained in the env file to the GPU.
  114442. * @param texture defines the internal texture to upload to
  114443. * @param arrayBuffer defines the buffer cotaining the data to load
  114444. * @param info defines the texture info retrieved through the GetEnvInfo method
  114445. * @returns a promise
  114446. */
  114447. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  114448. private static _OnImageReadyAsync;
  114449. /**
  114450. * Uploads the levels of image data to the GPU.
  114451. * @param texture defines the internal texture to upload to
  114452. * @param imageData defines the array buffer views of image data [mipmap][face]
  114453. * @returns a promise
  114454. */
  114455. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  114456. /**
  114457. * Uploads spherical polynomials information to the texture.
  114458. * @param texture defines the texture we are trying to upload the information to
  114459. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  114460. */
  114461. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  114462. /** @hidden */
  114463. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114464. }
  114465. }
  114466. declare module BABYLON {
  114467. /**
  114468. * Contains position and normal vectors for a vertex
  114469. */
  114470. export class PositionNormalVertex {
  114471. /** the position of the vertex (defaut: 0,0,0) */
  114472. position: Vector3;
  114473. /** the normal of the vertex (defaut: 0,1,0) */
  114474. normal: Vector3;
  114475. /**
  114476. * Creates a PositionNormalVertex
  114477. * @param position the position of the vertex (defaut: 0,0,0)
  114478. * @param normal the normal of the vertex (defaut: 0,1,0)
  114479. */
  114480. constructor(
  114481. /** the position of the vertex (defaut: 0,0,0) */
  114482. position?: Vector3,
  114483. /** the normal of the vertex (defaut: 0,1,0) */
  114484. normal?: Vector3);
  114485. /**
  114486. * Clones the PositionNormalVertex
  114487. * @returns the cloned PositionNormalVertex
  114488. */
  114489. clone(): PositionNormalVertex;
  114490. }
  114491. /**
  114492. * Contains position, normal and uv vectors for a vertex
  114493. */
  114494. export class PositionNormalTextureVertex {
  114495. /** the position of the vertex (defaut: 0,0,0) */
  114496. position: Vector3;
  114497. /** the normal of the vertex (defaut: 0,1,0) */
  114498. normal: Vector3;
  114499. /** the uv of the vertex (default: 0,0) */
  114500. uv: Vector2;
  114501. /**
  114502. * Creates a PositionNormalTextureVertex
  114503. * @param position the position of the vertex (defaut: 0,0,0)
  114504. * @param normal the normal of the vertex (defaut: 0,1,0)
  114505. * @param uv the uv of the vertex (default: 0,0)
  114506. */
  114507. constructor(
  114508. /** the position of the vertex (defaut: 0,0,0) */
  114509. position?: Vector3,
  114510. /** the normal of the vertex (defaut: 0,1,0) */
  114511. normal?: Vector3,
  114512. /** the uv of the vertex (default: 0,0) */
  114513. uv?: Vector2);
  114514. /**
  114515. * Clones the PositionNormalTextureVertex
  114516. * @returns the cloned PositionNormalTextureVertex
  114517. */
  114518. clone(): PositionNormalTextureVertex;
  114519. }
  114520. }
  114521. declare module BABYLON {
  114522. /** @hidden */
  114523. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  114524. private _genericAttributeLocation;
  114525. private _varyingLocationCount;
  114526. private _varyingLocationMap;
  114527. private _replacements;
  114528. private _textureCount;
  114529. private _uniforms;
  114530. lineProcessor(line: string): string;
  114531. attributeProcessor(attribute: string): string;
  114532. varyingProcessor(varying: string, isFragment: boolean): string;
  114533. uniformProcessor(uniform: string): string;
  114534. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  114535. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114536. }
  114537. }
  114538. declare module BABYLON {
  114539. /**
  114540. * Container for accessors for natively-stored mesh data buffers.
  114541. */
  114542. class NativeDataBuffer extends DataBuffer {
  114543. /**
  114544. * Accessor value used to identify/retrieve a natively-stored index buffer.
  114545. */
  114546. nativeIndexBuffer?: any;
  114547. /**
  114548. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  114549. */
  114550. nativeVertexBuffer?: any;
  114551. }
  114552. /** @hidden */
  114553. class NativeTexture extends InternalTexture {
  114554. getInternalTexture(): InternalTexture;
  114555. getViewCount(): number;
  114556. }
  114557. /** @hidden */
  114558. export class NativeEngine extends Engine {
  114559. private readonly _native;
  114560. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  114561. private readonly INVALID_HANDLE;
  114562. getHardwareScalingLevel(): number;
  114563. constructor();
  114564. /**
  114565. * Can be used to override the current requestAnimationFrame requester.
  114566. * @hidden
  114567. */
  114568. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114569. /**
  114570. * Override default engine behavior.
  114571. * @param color
  114572. * @param backBuffer
  114573. * @param depth
  114574. * @param stencil
  114575. */
  114576. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114577. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114578. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  114579. createVertexBuffer(data: DataArray): NativeDataBuffer;
  114580. recordVertexArrayObject(vertexBuffers: {
  114581. [key: string]: VertexBuffer;
  114582. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114583. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114584. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  114585. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114586. /**
  114587. * Draw a list of indexed primitives
  114588. * @param fillMode defines the primitive to use
  114589. * @param indexStart defines the starting index
  114590. * @param indexCount defines the number of index to draw
  114591. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114592. */
  114593. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114594. /**
  114595. * Draw a list of unindexed primitives
  114596. * @param fillMode defines the primitive to use
  114597. * @param verticesStart defines the index of first vertex to draw
  114598. * @param verticesCount defines the count of vertices to draw
  114599. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114600. */
  114601. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114602. createPipelineContext(): IPipelineContext;
  114603. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114604. /** @hidden */
  114605. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114606. /** @hidden */
  114607. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114608. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114609. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  114610. protected _setProgram(program: WebGLProgram): void;
  114611. _releaseEffect(effect: Effect): void;
  114612. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114613. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  114614. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  114615. bindSamplers(effect: Effect): void;
  114616. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  114617. getRenderWidth(useScreen?: boolean): number;
  114618. getRenderHeight(useScreen?: boolean): number;
  114619. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  114620. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114621. /**
  114622. * Set the z offset to apply to current rendering
  114623. * @param value defines the offset to apply
  114624. */
  114625. setZOffset(value: number): void;
  114626. /**
  114627. * Gets the current value of the zOffset
  114628. * @returns the current zOffset state
  114629. */
  114630. getZOffset(): number;
  114631. /**
  114632. * Enable or disable depth buffering
  114633. * @param enable defines the state to set
  114634. */
  114635. setDepthBuffer(enable: boolean): void;
  114636. /**
  114637. * Gets a boolean indicating if depth writing is enabled
  114638. * @returns the current depth writing state
  114639. */
  114640. getDepthWrite(): boolean;
  114641. /**
  114642. * Enable or disable depth writing
  114643. * @param enable defines the state to set
  114644. */
  114645. setDepthWrite(enable: boolean): void;
  114646. /**
  114647. * Enable or disable color writing
  114648. * @param enable defines the state to set
  114649. */
  114650. setColorWrite(enable: boolean): void;
  114651. /**
  114652. * Gets a boolean indicating if color writing is enabled
  114653. * @returns the current color writing state
  114654. */
  114655. getColorWrite(): boolean;
  114656. /**
  114657. * Sets alpha constants used by some alpha blending modes
  114658. * @param r defines the red component
  114659. * @param g defines the green component
  114660. * @param b defines the blue component
  114661. * @param a defines the alpha component
  114662. */
  114663. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114664. /**
  114665. * Sets the current alpha mode
  114666. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  114667. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114669. */
  114670. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114671. /**
  114672. * Gets the current alpha mode
  114673. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114674. * @returns the current alpha mode
  114675. */
  114676. getAlphaMode(): number;
  114677. setInt(uniform: WebGLUniformLocation, int: number): void;
  114678. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114679. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114680. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114681. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114682. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114683. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114684. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114685. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114686. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114687. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114688. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114689. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114690. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114691. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114692. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114693. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114694. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114695. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114696. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114697. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  114698. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  114699. wipeCaches(bruteForce?: boolean): void;
  114700. _createTexture(): WebGLTexture;
  114701. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114702. /**
  114703. * Usually called from BABYLON.Texture.ts.
  114704. * Passed information to create a WebGLTexture
  114705. * @param urlArg defines a value which contains one of the following:
  114706. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114707. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114708. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114709. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114710. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  114711. * @param scene needed for loading to the correct scene
  114712. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  114713. * @param onLoad optional callback to be called upon successful completion
  114714. * @param onError optional callback to be called upon failure
  114715. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  114716. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114717. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114718. * @param forcedExtension defines the extension to use to pick the right loader
  114719. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114720. */
  114721. 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;
  114722. /**
  114723. * Creates a cube texture
  114724. * @param rootUrl defines the url where the files to load is located
  114725. * @param scene defines the current scene
  114726. * @param files defines the list of files to load (1 per face)
  114727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  114728. * @param onLoad defines an optional callback raised when the texture is loaded
  114729. * @param onError defines an optional callback raised if there is an issue to load the texture
  114730. * @param format defines the format of the data
  114731. * @param forcedExtension defines the extension to use to pick the right loader
  114732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  114733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  114736. * @returns the cube texture as an InternalTexture
  114737. */
  114738. 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;
  114739. private _getSamplingFilter;
  114740. private static _GetNativeTextureFormat;
  114741. createRenderTargetTexture(size: number | {
  114742. width: number;
  114743. height: number;
  114744. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  114745. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114746. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114747. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114748. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114749. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114750. /**
  114751. * Updates a dynamic vertex buffer.
  114752. * @param vertexBuffer the vertex buffer to update
  114753. * @param data the data used to update the vertex buffer
  114754. * @param byteOffset the byte offset of the data (optional)
  114755. * @param byteLength the byte length of the data (optional)
  114756. */
  114757. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114758. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114759. private _updateAnisotropicLevel;
  114760. private _getAddressMode;
  114761. /** @hidden */
  114762. _bindTexture(channel: number, texture: InternalTexture): void;
  114763. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  114764. releaseEffects(): void;
  114765. /** @hidden */
  114766. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114767. /** @hidden */
  114768. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114769. /** @hidden */
  114770. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114771. /** @hidden */
  114772. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114773. }
  114774. }
  114775. declare module BABYLON {
  114776. /**
  114777. * Gather the list of clipboard event types as constants.
  114778. */
  114779. export class ClipboardEventTypes {
  114780. /**
  114781. * The clipboard event is fired when a copy command is active (pressed).
  114782. */
  114783. static readonly COPY: number;
  114784. /**
  114785. * The clipboard event is fired when a cut command is active (pressed).
  114786. */
  114787. static readonly CUT: number;
  114788. /**
  114789. * The clipboard event is fired when a paste command is active (pressed).
  114790. */
  114791. static readonly PASTE: number;
  114792. }
  114793. /**
  114794. * This class is used to store clipboard related info for the onClipboardObservable event.
  114795. */
  114796. export class ClipboardInfo {
  114797. /**
  114798. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114799. */
  114800. type: number;
  114801. /**
  114802. * Defines the related dom event
  114803. */
  114804. event: ClipboardEvent;
  114805. /**
  114806. *Creates an instance of ClipboardInfo.
  114807. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114808. * @param event Defines the related dom event
  114809. */
  114810. constructor(
  114811. /**
  114812. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114813. */
  114814. type: number,
  114815. /**
  114816. * Defines the related dom event
  114817. */
  114818. event: ClipboardEvent);
  114819. /**
  114820. * Get the clipboard event's type from the keycode.
  114821. * @param keyCode Defines the keyCode for the current keyboard event.
  114822. * @return {number}
  114823. */
  114824. static GetTypeFromCharacter(keyCode: number): number;
  114825. }
  114826. }
  114827. declare module BABYLON {
  114828. /**
  114829. * Google Daydream controller
  114830. */
  114831. export class DaydreamController extends WebVRController {
  114832. /**
  114833. * Base Url for the controller model.
  114834. */
  114835. static MODEL_BASE_URL: string;
  114836. /**
  114837. * File name for the controller model.
  114838. */
  114839. static MODEL_FILENAME: string;
  114840. /**
  114841. * Gamepad Id prefix used to identify Daydream Controller.
  114842. */
  114843. static readonly GAMEPAD_ID_PREFIX: string;
  114844. /**
  114845. * Creates a new DaydreamController from a gamepad
  114846. * @param vrGamepad the gamepad that the controller should be created from
  114847. */
  114848. constructor(vrGamepad: any);
  114849. /**
  114850. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114851. * @param scene scene in which to add meshes
  114852. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114853. */
  114854. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114855. /**
  114856. * Called once for each button that changed state since the last frame
  114857. * @param buttonIdx Which button index changed
  114858. * @param state New state of the button
  114859. * @param changes Which properties on the state changed since last frame
  114860. */
  114861. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114862. }
  114863. }
  114864. declare module BABYLON {
  114865. /**
  114866. * Gear VR Controller
  114867. */
  114868. export class GearVRController extends WebVRController {
  114869. /**
  114870. * Base Url for the controller model.
  114871. */
  114872. static MODEL_BASE_URL: string;
  114873. /**
  114874. * File name for the controller model.
  114875. */
  114876. static MODEL_FILENAME: string;
  114877. /**
  114878. * Gamepad Id prefix used to identify this controller.
  114879. */
  114880. static readonly GAMEPAD_ID_PREFIX: string;
  114881. private readonly _buttonIndexToObservableNameMap;
  114882. /**
  114883. * Creates a new GearVRController from a gamepad
  114884. * @param vrGamepad the gamepad that the controller should be created from
  114885. */
  114886. constructor(vrGamepad: any);
  114887. /**
  114888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114889. * @param scene scene in which to add meshes
  114890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114891. */
  114892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114893. /**
  114894. * Called once for each button that changed state since the last frame
  114895. * @param buttonIdx Which button index changed
  114896. * @param state New state of the button
  114897. * @param changes Which properties on the state changed since last frame
  114898. */
  114899. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114900. }
  114901. }
  114902. declare module BABYLON {
  114903. /**
  114904. * Class containing static functions to help procedurally build meshes
  114905. */
  114906. export class PolyhedronBuilder {
  114907. /**
  114908. * Creates a polyhedron mesh
  114909. * * 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
  114910. * * The parameter `size` (positive float, default 1) sets the polygon size
  114911. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114912. * * 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`
  114913. * * 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
  114914. * * 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)`)
  114915. * * 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
  114916. * * 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
  114917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114920. * @param name defines the name of the mesh
  114921. * @param options defines the options used to create the mesh
  114922. * @param scene defines the hosting scene
  114923. * @returns the polyhedron mesh
  114924. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114925. */
  114926. static CreatePolyhedron(name: string, options: {
  114927. type?: number;
  114928. size?: number;
  114929. sizeX?: number;
  114930. sizeY?: number;
  114931. sizeZ?: number;
  114932. custom?: any;
  114933. faceUV?: Vector4[];
  114934. faceColors?: Color4[];
  114935. flat?: boolean;
  114936. updatable?: boolean;
  114937. sideOrientation?: number;
  114938. frontUVs?: Vector4;
  114939. backUVs?: Vector4;
  114940. }, scene?: Nullable<Scene>): Mesh;
  114941. }
  114942. }
  114943. declare module BABYLON {
  114944. /**
  114945. * Gizmo that enables scaling a mesh along 3 axis
  114946. */
  114947. export class ScaleGizmo extends Gizmo {
  114948. /**
  114949. * Internal gizmo used for interactions on the x axis
  114950. */
  114951. xGizmo: AxisScaleGizmo;
  114952. /**
  114953. * Internal gizmo used for interactions on the y axis
  114954. */
  114955. yGizmo: AxisScaleGizmo;
  114956. /**
  114957. * Internal gizmo used for interactions on the z axis
  114958. */
  114959. zGizmo: AxisScaleGizmo;
  114960. /**
  114961. * Internal gizmo used to scale all axis equally
  114962. */
  114963. uniformScaleGizmo: AxisScaleGizmo;
  114964. private _meshAttached;
  114965. private _updateGizmoRotationToMatchAttachedMesh;
  114966. private _snapDistance;
  114967. private _scaleRatio;
  114968. private _uniformScalingMesh;
  114969. private _octahedron;
  114970. private _sensitivity;
  114971. /** Fires an event when any of it's sub gizmos are dragged */
  114972. onDragStartObservable: Observable<unknown>;
  114973. /** Fires an event when any of it's sub gizmos are released from dragging */
  114974. onDragEndObservable: Observable<unknown>;
  114975. attachedMesh: Nullable<AbstractMesh>;
  114976. /**
  114977. * Creates a ScaleGizmo
  114978. * @param gizmoLayer The utility layer the gizmo will be added to
  114979. */
  114980. constructor(gizmoLayer?: UtilityLayerRenderer);
  114981. updateGizmoRotationToMatchAttachedMesh: boolean;
  114982. /**
  114983. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114984. */
  114985. snapDistance: number;
  114986. /**
  114987. * Ratio for the scale of the gizmo (Default: 1)
  114988. */
  114989. scaleRatio: number;
  114990. /**
  114991. * Sensitivity factor for dragging (Default: 1)
  114992. */
  114993. sensitivity: number;
  114994. /**
  114995. * Disposes of the gizmo
  114996. */
  114997. dispose(): void;
  114998. }
  114999. }
  115000. declare module BABYLON {
  115001. /**
  115002. * Single axis scale gizmo
  115003. */
  115004. export class AxisScaleGizmo extends Gizmo {
  115005. /**
  115006. * Drag behavior responsible for the gizmos dragging interactions
  115007. */
  115008. dragBehavior: PointerDragBehavior;
  115009. private _pointerObserver;
  115010. /**
  115011. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115012. */
  115013. snapDistance: number;
  115014. /**
  115015. * Event that fires each time the gizmo snaps to a new location.
  115016. * * snapDistance is the the change in distance
  115017. */
  115018. onSnapObservable: Observable<{
  115019. snapDistance: number;
  115020. }>;
  115021. /**
  115022. * If the scaling operation should be done on all axis (default: false)
  115023. */
  115024. uniformScaling: boolean;
  115025. /**
  115026. * Custom sensitivity value for the drag strength
  115027. */
  115028. sensitivity: number;
  115029. private _isEnabled;
  115030. private _parent;
  115031. private _arrow;
  115032. private _coloredMaterial;
  115033. private _hoverMaterial;
  115034. /**
  115035. * Creates an AxisScaleGizmo
  115036. * @param gizmoLayer The utility layer the gizmo will be added to
  115037. * @param dragAxis The axis which the gizmo will be able to scale on
  115038. * @param color The color of the gizmo
  115039. */
  115040. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115041. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115042. /**
  115043. * If the gizmo is enabled
  115044. */
  115045. isEnabled: boolean;
  115046. /**
  115047. * Disposes of the gizmo
  115048. */
  115049. dispose(): void;
  115050. /**
  115051. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115052. * @param mesh The mesh to replace the default mesh of the gizmo
  115053. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115054. */
  115055. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115056. }
  115057. }
  115058. declare module BABYLON {
  115059. /**
  115060. * Bounding box gizmo
  115061. */
  115062. export class BoundingBoxGizmo extends Gizmo {
  115063. private _lineBoundingBox;
  115064. private _rotateSpheresParent;
  115065. private _scaleBoxesParent;
  115066. private _boundingDimensions;
  115067. private _renderObserver;
  115068. private _pointerObserver;
  115069. private _scaleDragSpeed;
  115070. private _tmpQuaternion;
  115071. private _tmpVector;
  115072. private _tmpRotationMatrix;
  115073. /**
  115074. * 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)
  115075. */
  115076. ignoreChildren: boolean;
  115077. /**
  115078. * 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)
  115079. */
  115080. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115081. /**
  115082. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115083. */
  115084. rotationSphereSize: number;
  115085. /**
  115086. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115087. */
  115088. scaleBoxSize: number;
  115089. /**
  115090. * 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)
  115091. */
  115092. fixedDragMeshScreenSize: boolean;
  115093. /**
  115094. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115095. */
  115096. fixedDragMeshScreenSizeDistanceFactor: number;
  115097. /**
  115098. * Fired when a rotation sphere or scale box is dragged
  115099. */
  115100. onDragStartObservable: Observable<{}>;
  115101. /**
  115102. * Fired when a scale box is dragged
  115103. */
  115104. onScaleBoxDragObservable: Observable<{}>;
  115105. /**
  115106. * Fired when a scale box drag is ended
  115107. */
  115108. onScaleBoxDragEndObservable: Observable<{}>;
  115109. /**
  115110. * Fired when a rotation sphere is dragged
  115111. */
  115112. onRotationSphereDragObservable: Observable<{}>;
  115113. /**
  115114. * Fired when a rotation sphere drag is ended
  115115. */
  115116. onRotationSphereDragEndObservable: Observable<{}>;
  115117. /**
  115118. * 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)
  115119. */
  115120. scalePivot: Nullable<Vector3>;
  115121. /**
  115122. * Mesh used as a pivot to rotate the attached mesh
  115123. */
  115124. private _anchorMesh;
  115125. private _existingMeshScale;
  115126. private _dragMesh;
  115127. private pointerDragBehavior;
  115128. private coloredMaterial;
  115129. private hoverColoredMaterial;
  115130. /**
  115131. * Sets the color of the bounding box gizmo
  115132. * @param color the color to set
  115133. */
  115134. setColor(color: Color3): void;
  115135. /**
  115136. * Creates an BoundingBoxGizmo
  115137. * @param gizmoLayer The utility layer the gizmo will be added to
  115138. * @param color The color of the gizmo
  115139. */
  115140. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115141. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115142. private _selectNode;
  115143. /**
  115144. * Updates the bounding box information for the Gizmo
  115145. */
  115146. updateBoundingBox(): void;
  115147. private _updateRotationSpheres;
  115148. private _updateScaleBoxes;
  115149. /**
  115150. * Enables rotation on the specified axis and disables rotation on the others
  115151. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115152. */
  115153. setEnabledRotationAxis(axis: string): void;
  115154. /**
  115155. * Enables/disables scaling
  115156. * @param enable if scaling should be enabled
  115157. */
  115158. setEnabledScaling(enable: boolean): void;
  115159. private _updateDummy;
  115160. /**
  115161. * Enables a pointer drag behavior on the bounding box of the gizmo
  115162. */
  115163. enableDragBehavior(): void;
  115164. /**
  115165. * Disposes of the gizmo
  115166. */
  115167. dispose(): void;
  115168. /**
  115169. * 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)
  115170. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115171. * @returns the bounding box mesh with the passed in mesh as a child
  115172. */
  115173. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115174. /**
  115175. * CustomMeshes are not supported by this gizmo
  115176. * @param mesh The mesh to replace the default mesh of the gizmo
  115177. */
  115178. setCustomMesh(mesh: Mesh): void;
  115179. }
  115180. }
  115181. declare module BABYLON {
  115182. /**
  115183. * Single plane rotation gizmo
  115184. */
  115185. export class PlaneRotationGizmo extends Gizmo {
  115186. /**
  115187. * Drag behavior responsible for the gizmos dragging interactions
  115188. */
  115189. dragBehavior: PointerDragBehavior;
  115190. private _pointerObserver;
  115191. /**
  115192. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115193. */
  115194. snapDistance: number;
  115195. /**
  115196. * Event that fires each time the gizmo snaps to a new location.
  115197. * * snapDistance is the the change in distance
  115198. */
  115199. onSnapObservable: Observable<{
  115200. snapDistance: number;
  115201. }>;
  115202. private _isEnabled;
  115203. private _parent;
  115204. /**
  115205. * Creates a PlaneRotationGizmo
  115206. * @param gizmoLayer The utility layer the gizmo will be added to
  115207. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115208. * @param color The color of the gizmo
  115209. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115210. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115211. */
  115212. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115213. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115214. /**
  115215. * If the gizmo is enabled
  115216. */
  115217. isEnabled: boolean;
  115218. /**
  115219. * Disposes of the gizmo
  115220. */
  115221. dispose(): void;
  115222. }
  115223. }
  115224. declare module BABYLON {
  115225. /**
  115226. * Gizmo that enables rotating a mesh along 3 axis
  115227. */
  115228. export class RotationGizmo extends Gizmo {
  115229. /**
  115230. * Internal gizmo used for interactions on the x axis
  115231. */
  115232. xGizmo: PlaneRotationGizmo;
  115233. /**
  115234. * Internal gizmo used for interactions on the y axis
  115235. */
  115236. yGizmo: PlaneRotationGizmo;
  115237. /**
  115238. * Internal gizmo used for interactions on the z axis
  115239. */
  115240. zGizmo: PlaneRotationGizmo;
  115241. /** Fires an event when any of it's sub gizmos are dragged */
  115242. onDragStartObservable: Observable<unknown>;
  115243. /** Fires an event when any of it's sub gizmos are released from dragging */
  115244. onDragEndObservable: Observable<unknown>;
  115245. private _meshAttached;
  115246. attachedMesh: Nullable<AbstractMesh>;
  115247. /**
  115248. * Creates a RotationGizmo
  115249. * @param gizmoLayer The utility layer the gizmo will be added to
  115250. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115251. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115252. */
  115253. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115254. updateGizmoRotationToMatchAttachedMesh: boolean;
  115255. /**
  115256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115257. */
  115258. snapDistance: number;
  115259. /**
  115260. * Ratio for the scale of the gizmo (Default: 1)
  115261. */
  115262. scaleRatio: number;
  115263. /**
  115264. * Disposes of the gizmo
  115265. */
  115266. dispose(): void;
  115267. /**
  115268. * CustomMeshes are not supported by this gizmo
  115269. * @param mesh The mesh to replace the default mesh of the gizmo
  115270. */
  115271. setCustomMesh(mesh: Mesh): void;
  115272. }
  115273. }
  115274. declare module BABYLON {
  115275. /**
  115276. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115277. */
  115278. export class GizmoManager implements IDisposable {
  115279. private scene;
  115280. /**
  115281. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115282. */
  115283. gizmos: {
  115284. positionGizmo: Nullable<PositionGizmo>;
  115285. rotationGizmo: Nullable<RotationGizmo>;
  115286. scaleGizmo: Nullable<ScaleGizmo>;
  115287. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115288. };
  115289. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115290. clearGizmoOnEmptyPointerEvent: boolean;
  115291. /** Fires an event when the manager is attached to a mesh */
  115292. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115293. private _gizmosEnabled;
  115294. private _pointerObserver;
  115295. private _attachedMesh;
  115296. private _boundingBoxColor;
  115297. private _defaultUtilityLayer;
  115298. private _defaultKeepDepthUtilityLayer;
  115299. /**
  115300. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115301. */
  115302. boundingBoxDragBehavior: SixDofDragBehavior;
  115303. /**
  115304. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115305. */
  115306. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115307. /**
  115308. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115309. */
  115310. usePointerToAttachGizmos: boolean;
  115311. /**
  115312. * Utility layer that the bounding box gizmo belongs to
  115313. */
  115314. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115315. /**
  115316. * Utility layer that all gizmos besides bounding box belong to
  115317. */
  115318. readonly utilityLayer: UtilityLayerRenderer;
  115319. /**
  115320. * Instatiates a gizmo manager
  115321. * @param scene the scene to overlay the gizmos on top of
  115322. */
  115323. constructor(scene: Scene);
  115324. /**
  115325. * Attaches a set of gizmos to the specified mesh
  115326. * @param mesh The mesh the gizmo's should be attached to
  115327. */
  115328. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115329. /**
  115330. * If the position gizmo is enabled
  115331. */
  115332. positionGizmoEnabled: boolean;
  115333. /**
  115334. * If the rotation gizmo is enabled
  115335. */
  115336. rotationGizmoEnabled: boolean;
  115337. /**
  115338. * If the scale gizmo is enabled
  115339. */
  115340. scaleGizmoEnabled: boolean;
  115341. /**
  115342. * If the boundingBox gizmo is enabled
  115343. */
  115344. boundingBoxGizmoEnabled: boolean;
  115345. /**
  115346. * Disposes of the gizmo manager
  115347. */
  115348. dispose(): void;
  115349. }
  115350. }
  115351. declare module BABYLON {
  115352. /**
  115353. * A directional light is defined by a direction (what a surprise!).
  115354. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  115355. * 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.
  115356. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115357. */
  115358. export class DirectionalLight extends ShadowLight {
  115359. private _shadowFrustumSize;
  115360. /**
  115361. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  115362. */
  115363. /**
  115364. * Specifies a fix frustum size for the shadow generation.
  115365. */
  115366. shadowFrustumSize: number;
  115367. private _shadowOrthoScale;
  115368. /**
  115369. * Gets the shadow projection scale against the optimal computed one.
  115370. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115371. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115372. */
  115373. /**
  115374. * Sets the shadow projection scale against the optimal computed one.
  115375. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  115376. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  115377. */
  115378. shadowOrthoScale: number;
  115379. /**
  115380. * Automatically compute the projection matrix to best fit (including all the casters)
  115381. * on each frame.
  115382. */
  115383. autoUpdateExtends: boolean;
  115384. private _orthoLeft;
  115385. private _orthoRight;
  115386. private _orthoTop;
  115387. private _orthoBottom;
  115388. /**
  115389. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  115390. * The directional light is emitted from everywhere in the given direction.
  115391. * It can cast shadows.
  115392. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115393. * @param name The friendly name of the light
  115394. * @param direction The direction of the light
  115395. * @param scene The scene the light belongs to
  115396. */
  115397. constructor(name: string, direction: Vector3, scene: Scene);
  115398. /**
  115399. * Returns the string "DirectionalLight".
  115400. * @return The class name
  115401. */
  115402. getClassName(): string;
  115403. /**
  115404. * Returns the integer 1.
  115405. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115406. */
  115407. getTypeID(): number;
  115408. /**
  115409. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  115410. * Returns the DirectionalLight Shadow projection matrix.
  115411. */
  115412. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115413. /**
  115414. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  115415. * Returns the DirectionalLight Shadow projection matrix.
  115416. */
  115417. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  115418. /**
  115419. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  115420. * Returns the DirectionalLight Shadow projection matrix.
  115421. */
  115422. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115423. protected _buildUniformLayout(): void;
  115424. /**
  115425. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  115426. * @param effect The effect to update
  115427. * @param lightIndex The index of the light in the effect to update
  115428. * @returns The directional light
  115429. */
  115430. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  115431. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  115432. /**
  115433. * Gets the minZ used for shadow according to both the scene and the light.
  115434. *
  115435. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115436. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115437. * @param activeCamera The camera we are returning the min for
  115438. * @returns the depth min z
  115439. */
  115440. getDepthMinZ(activeCamera: Camera): number;
  115441. /**
  115442. * Gets the maxZ used for shadow according to both the scene and the light.
  115443. *
  115444. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  115445. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  115446. * @param activeCamera The camera we are returning the max for
  115447. * @returns the depth max z
  115448. */
  115449. getDepthMaxZ(activeCamera: Camera): number;
  115450. /**
  115451. * Prepares the list of defines specific to the light type.
  115452. * @param defines the list of defines
  115453. * @param lightIndex defines the index of the light for the effect
  115454. */
  115455. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115456. }
  115457. }
  115458. declare module BABYLON {
  115459. /**
  115460. * Class containing static functions to help procedurally build meshes
  115461. */
  115462. export class HemisphereBuilder {
  115463. /**
  115464. * Creates a hemisphere mesh
  115465. * @param name defines the name of the mesh
  115466. * @param options defines the options used to create the mesh
  115467. * @param scene defines the hosting scene
  115468. * @returns the hemisphere mesh
  115469. */
  115470. static CreateHemisphere(name: string, options: {
  115471. segments?: number;
  115472. diameter?: number;
  115473. sideOrientation?: number;
  115474. }, scene: any): Mesh;
  115475. }
  115476. }
  115477. declare module BABYLON {
  115478. /**
  115479. * A spot light is defined by a position, a direction, an angle, and an exponent.
  115480. * These values define a cone of light starting from the position, emitting toward the direction.
  115481. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  115482. * and the exponent defines the speed of the decay of the light with distance (reach).
  115483. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115484. */
  115485. export class SpotLight extends ShadowLight {
  115486. private _angle;
  115487. private _innerAngle;
  115488. private _cosHalfAngle;
  115489. private _lightAngleScale;
  115490. private _lightAngleOffset;
  115491. /**
  115492. * Gets the cone angle of the spot light in Radians.
  115493. */
  115494. /**
  115495. * Sets the cone angle of the spot light in Radians.
  115496. */
  115497. angle: number;
  115498. /**
  115499. * Only used in gltf falloff mode, this defines the angle where
  115500. * the directional falloff will start before cutting at angle which could be seen
  115501. * as outer angle.
  115502. */
  115503. /**
  115504. * Only used in gltf falloff mode, this defines the angle where
  115505. * the directional falloff will start before cutting at angle which could be seen
  115506. * as outer angle.
  115507. */
  115508. innerAngle: number;
  115509. private _shadowAngleScale;
  115510. /**
  115511. * Allows scaling the angle of the light for shadow generation only.
  115512. */
  115513. /**
  115514. * Allows scaling the angle of the light for shadow generation only.
  115515. */
  115516. shadowAngleScale: number;
  115517. /**
  115518. * The light decay speed with the distance from the emission spot.
  115519. */
  115520. exponent: number;
  115521. private _projectionTextureMatrix;
  115522. /**
  115523. * Allows reading the projecton texture
  115524. */
  115525. readonly projectionTextureMatrix: Matrix;
  115526. protected _projectionTextureLightNear: number;
  115527. /**
  115528. * Gets the near clip of the Spotlight for texture projection.
  115529. */
  115530. /**
  115531. * Sets the near clip of the Spotlight for texture projection.
  115532. */
  115533. projectionTextureLightNear: number;
  115534. protected _projectionTextureLightFar: number;
  115535. /**
  115536. * Gets the far clip of the Spotlight for texture projection.
  115537. */
  115538. /**
  115539. * Sets the far clip of the Spotlight for texture projection.
  115540. */
  115541. projectionTextureLightFar: number;
  115542. protected _projectionTextureUpDirection: Vector3;
  115543. /**
  115544. * Gets the Up vector of the Spotlight for texture projection.
  115545. */
  115546. /**
  115547. * Sets the Up vector of the Spotlight for texture projection.
  115548. */
  115549. projectionTextureUpDirection: Vector3;
  115550. private _projectionTexture;
  115551. /**
  115552. * Gets the projection texture of the light.
  115553. */
  115554. /**
  115555. * Sets the projection texture of the light.
  115556. */
  115557. projectionTexture: Nullable<BaseTexture>;
  115558. private _projectionTextureViewLightDirty;
  115559. private _projectionTextureProjectionLightDirty;
  115560. private _projectionTextureDirty;
  115561. private _projectionTextureViewTargetVector;
  115562. private _projectionTextureViewLightMatrix;
  115563. private _projectionTextureProjectionLightMatrix;
  115564. private _projectionTextureScalingMatrix;
  115565. /**
  115566. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  115567. * It can cast shadows.
  115568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115569. * @param name The light friendly name
  115570. * @param position The position of the spot light in the scene
  115571. * @param direction The direction of the light in the scene
  115572. * @param angle The cone angle of the light in Radians
  115573. * @param exponent The light decay speed with the distance from the emission spot
  115574. * @param scene The scene the lights belongs to
  115575. */
  115576. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  115577. /**
  115578. * Returns the string "SpotLight".
  115579. * @returns the class name
  115580. */
  115581. getClassName(): string;
  115582. /**
  115583. * Returns the integer 2.
  115584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115585. */
  115586. getTypeID(): number;
  115587. /**
  115588. * Overrides the direction setter to recompute the projection texture view light Matrix.
  115589. */
  115590. protected _setDirection(value: Vector3): void;
  115591. /**
  115592. * Overrides the position setter to recompute the projection texture view light Matrix.
  115593. */
  115594. protected _setPosition(value: Vector3): void;
  115595. /**
  115596. * 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.
  115597. * Returns the SpotLight.
  115598. */
  115599. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115600. protected _computeProjectionTextureViewLightMatrix(): void;
  115601. protected _computeProjectionTextureProjectionLightMatrix(): void;
  115602. /**
  115603. * Main function for light texture projection matrix computing.
  115604. */
  115605. protected _computeProjectionTextureMatrix(): void;
  115606. protected _buildUniformLayout(): void;
  115607. private _computeAngleValues;
  115608. /**
  115609. * Sets the passed Effect "effect" with the Light textures.
  115610. * @param effect The effect to update
  115611. * @param lightIndex The index of the light in the effect to update
  115612. * @returns The light
  115613. */
  115614. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  115615. /**
  115616. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  115617. * @param effect The effect to update
  115618. * @param lightIndex The index of the light in the effect to update
  115619. * @returns The spot light
  115620. */
  115621. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  115622. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115623. /**
  115624. * Disposes the light and the associated resources.
  115625. */
  115626. dispose(): void;
  115627. /**
  115628. * Prepares the list of defines specific to the light type.
  115629. * @param defines the list of defines
  115630. * @param lightIndex defines the index of the light for the effect
  115631. */
  115632. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115633. }
  115634. }
  115635. declare module BABYLON {
  115636. /**
  115637. * Gizmo that enables viewing a light
  115638. */
  115639. export class LightGizmo extends Gizmo {
  115640. private _lightMesh;
  115641. private _material;
  115642. private _cachedPosition;
  115643. private _cachedForward;
  115644. private _attachedMeshParent;
  115645. /**
  115646. * Creates a LightGizmo
  115647. * @param gizmoLayer The utility layer the gizmo will be added to
  115648. */
  115649. constructor(gizmoLayer?: UtilityLayerRenderer);
  115650. private _light;
  115651. /**
  115652. * The light that the gizmo is attached to
  115653. */
  115654. light: Nullable<Light>;
  115655. /**
  115656. * Gets the material used to render the light gizmo
  115657. */
  115658. readonly material: StandardMaterial;
  115659. /**
  115660. * @hidden
  115661. * Updates the gizmo to match the attached mesh's position/rotation
  115662. */
  115663. protected _update(): void;
  115664. private static _Scale;
  115665. /**
  115666. * Creates the lines for a light mesh
  115667. */
  115668. private static _CreateLightLines;
  115669. /**
  115670. * Disposes of the light gizmo
  115671. */
  115672. dispose(): void;
  115673. private static _CreateHemisphericLightMesh;
  115674. private static _CreatePointLightMesh;
  115675. private static _CreateSpotLightMesh;
  115676. private static _CreateDirectionalLightMesh;
  115677. }
  115678. }
  115679. declare module BABYLON {
  115680. /** @hidden */
  115681. export var backgroundFragmentDeclaration: {
  115682. name: string;
  115683. shader: string;
  115684. };
  115685. }
  115686. declare module BABYLON {
  115687. /** @hidden */
  115688. export var backgroundUboDeclaration: {
  115689. name: string;
  115690. shader: string;
  115691. };
  115692. }
  115693. declare module BABYLON {
  115694. /** @hidden */
  115695. export var backgroundPixelShader: {
  115696. name: string;
  115697. shader: string;
  115698. };
  115699. }
  115700. declare module BABYLON {
  115701. /** @hidden */
  115702. export var backgroundVertexDeclaration: {
  115703. name: string;
  115704. shader: string;
  115705. };
  115706. }
  115707. declare module BABYLON {
  115708. /** @hidden */
  115709. export var backgroundVertexShader: {
  115710. name: string;
  115711. shader: string;
  115712. };
  115713. }
  115714. declare module BABYLON {
  115715. /**
  115716. * Background material used to create an efficient environement around your scene.
  115717. */
  115718. export class BackgroundMaterial extends PushMaterial {
  115719. /**
  115720. * Standard reflectance value at parallel view angle.
  115721. */
  115722. static StandardReflectance0: number;
  115723. /**
  115724. * Standard reflectance value at grazing angle.
  115725. */
  115726. static StandardReflectance90: number;
  115727. protected _primaryColor: Color3;
  115728. /**
  115729. * Key light Color (multiply against the environement texture)
  115730. */
  115731. primaryColor: Color3;
  115732. protected __perceptualColor: Nullable<Color3>;
  115733. /**
  115734. * Experimental Internal Use Only.
  115735. *
  115736. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  115737. * This acts as a helper to set the primary color to a more "human friendly" value.
  115738. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  115739. * output color as close as possible from the chosen value.
  115740. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  115741. * part of lighting setup.)
  115742. */
  115743. _perceptualColor: Nullable<Color3>;
  115744. protected _primaryColorShadowLevel: float;
  115745. /**
  115746. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  115747. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  115748. */
  115749. primaryColorShadowLevel: float;
  115750. protected _primaryColorHighlightLevel: float;
  115751. /**
  115752. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  115753. * The primary color is used at the level chosen to define what the white area would look.
  115754. */
  115755. primaryColorHighlightLevel: float;
  115756. protected _reflectionTexture: Nullable<BaseTexture>;
  115757. /**
  115758. * Reflection Texture used in the material.
  115759. * Should be author in a specific way for the best result (refer to the documentation).
  115760. */
  115761. reflectionTexture: Nullable<BaseTexture>;
  115762. protected _reflectionBlur: float;
  115763. /**
  115764. * Reflection Texture level of blur.
  115765. *
  115766. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  115767. * texture twice.
  115768. */
  115769. reflectionBlur: float;
  115770. protected _diffuseTexture: Nullable<BaseTexture>;
  115771. /**
  115772. * Diffuse Texture used in the material.
  115773. * Should be author in a specific way for the best result (refer to the documentation).
  115774. */
  115775. diffuseTexture: Nullable<BaseTexture>;
  115776. protected _shadowLights: Nullable<IShadowLight[]>;
  115777. /**
  115778. * Specify the list of lights casting shadow on the material.
  115779. * All scene shadow lights will be included if null.
  115780. */
  115781. shadowLights: Nullable<IShadowLight[]>;
  115782. protected _shadowLevel: float;
  115783. /**
  115784. * Helps adjusting the shadow to a softer level if required.
  115785. * 0 means black shadows and 1 means no shadows.
  115786. */
  115787. shadowLevel: float;
  115788. protected _sceneCenter: Vector3;
  115789. /**
  115790. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  115791. * It is usually zero but might be interesting to modify according to your setup.
  115792. */
  115793. sceneCenter: Vector3;
  115794. protected _opacityFresnel: boolean;
  115795. /**
  115796. * This helps specifying that the material is falling off to the sky box at grazing angle.
  115797. * This helps ensuring a nice transition when the camera goes under the ground.
  115798. */
  115799. opacityFresnel: boolean;
  115800. protected _reflectionFresnel: boolean;
  115801. /**
  115802. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  115803. * This helps adding a mirror texture on the ground.
  115804. */
  115805. reflectionFresnel: boolean;
  115806. protected _reflectionFalloffDistance: number;
  115807. /**
  115808. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115809. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115810. */
  115811. reflectionFalloffDistance: number;
  115812. protected _reflectionAmount: number;
  115813. /**
  115814. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115815. */
  115816. reflectionAmount: number;
  115817. protected _reflectionReflectance0: number;
  115818. /**
  115819. * This specifies the weight of the reflection at grazing angle.
  115820. */
  115821. reflectionReflectance0: number;
  115822. protected _reflectionReflectance90: number;
  115823. /**
  115824. * This specifies the weight of the reflection at a perpendicular point of view.
  115825. */
  115826. reflectionReflectance90: number;
  115827. /**
  115828. * Sets the reflection reflectance fresnel values according to the default standard
  115829. * empirically know to work well :-)
  115830. */
  115831. reflectionStandardFresnelWeight: number;
  115832. protected _useRGBColor: boolean;
  115833. /**
  115834. * Helps to directly use the maps channels instead of their level.
  115835. */
  115836. useRGBColor: boolean;
  115837. protected _enableNoise: boolean;
  115838. /**
  115839. * This helps reducing the banding effect that could occur on the background.
  115840. */
  115841. enableNoise: boolean;
  115842. /**
  115843. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115844. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115845. * Recommended to be keep at 1.0 except for special cases.
  115846. */
  115847. fovMultiplier: number;
  115848. private _fovMultiplier;
  115849. /**
  115850. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115851. */
  115852. useEquirectangularFOV: boolean;
  115853. private _maxSimultaneousLights;
  115854. /**
  115855. * Number of Simultaneous lights allowed on the material.
  115856. */
  115857. maxSimultaneousLights: int;
  115858. /**
  115859. * Default configuration related to image processing available in the Background Material.
  115860. */
  115861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115862. /**
  115863. * Keep track of the image processing observer to allow dispose and replace.
  115864. */
  115865. private _imageProcessingObserver;
  115866. /**
  115867. * Attaches a new image processing configuration to the PBR Material.
  115868. * @param configuration (if null the scene configuration will be use)
  115869. */
  115870. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115871. /**
  115872. * Gets the image processing configuration used either in this material.
  115873. */
  115874. /**
  115875. * Sets the Default image processing configuration used either in the this material.
  115876. *
  115877. * If sets to null, the scene one is in use.
  115878. */
  115879. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115880. /**
  115881. * Gets wether the color curves effect is enabled.
  115882. */
  115883. /**
  115884. * Sets wether the color curves effect is enabled.
  115885. */
  115886. cameraColorCurvesEnabled: boolean;
  115887. /**
  115888. * Gets wether the color grading effect is enabled.
  115889. */
  115890. /**
  115891. * Gets wether the color grading effect is enabled.
  115892. */
  115893. cameraColorGradingEnabled: boolean;
  115894. /**
  115895. * Gets wether tonemapping is enabled or not.
  115896. */
  115897. /**
  115898. * Sets wether tonemapping is enabled or not
  115899. */
  115900. cameraToneMappingEnabled: boolean;
  115901. /**
  115902. * The camera exposure used on this material.
  115903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115904. * This corresponds to a photographic exposure.
  115905. */
  115906. /**
  115907. * The camera exposure used on this material.
  115908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115909. * This corresponds to a photographic exposure.
  115910. */
  115911. cameraExposure: float;
  115912. /**
  115913. * Gets The camera contrast used on this material.
  115914. */
  115915. /**
  115916. * Sets The camera contrast used on this material.
  115917. */
  115918. cameraContrast: float;
  115919. /**
  115920. * Gets the Color Grading 2D Lookup Texture.
  115921. */
  115922. /**
  115923. * Sets the Color Grading 2D Lookup Texture.
  115924. */
  115925. cameraColorGradingTexture: Nullable<BaseTexture>;
  115926. /**
  115927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115929. * 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;
  115930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115931. */
  115932. /**
  115933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115935. * 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;
  115936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115937. */
  115938. cameraColorCurves: Nullable<ColorCurves>;
  115939. /**
  115940. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115941. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115942. */
  115943. switchToBGR: boolean;
  115944. private _renderTargets;
  115945. private _reflectionControls;
  115946. private _white;
  115947. private _primaryShadowColor;
  115948. private _primaryHighlightColor;
  115949. /**
  115950. * Instantiates a Background Material in the given scene
  115951. * @param name The friendly name of the material
  115952. * @param scene The scene to add the material to
  115953. */
  115954. constructor(name: string, scene: Scene);
  115955. /**
  115956. * Gets a boolean indicating that current material needs to register RTT
  115957. */
  115958. readonly hasRenderTargetTextures: boolean;
  115959. /**
  115960. * The entire material has been created in order to prevent overdraw.
  115961. * @returns false
  115962. */
  115963. needAlphaTesting(): boolean;
  115964. /**
  115965. * The entire material has been created in order to prevent overdraw.
  115966. * @returns true if blending is enable
  115967. */
  115968. needAlphaBlending(): boolean;
  115969. /**
  115970. * Checks wether the material is ready to be rendered for a given mesh.
  115971. * @param mesh The mesh to render
  115972. * @param subMesh The submesh to check against
  115973. * @param useInstances Specify wether or not the material is used with instances
  115974. * @returns true if all the dependencies are ready (Textures, Effects...)
  115975. */
  115976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115977. /**
  115978. * Compute the primary color according to the chosen perceptual color.
  115979. */
  115980. private _computePrimaryColorFromPerceptualColor;
  115981. /**
  115982. * Compute the highlights and shadow colors according to their chosen levels.
  115983. */
  115984. private _computePrimaryColors;
  115985. /**
  115986. * Build the uniform buffer used in the material.
  115987. */
  115988. buildUniformLayout(): void;
  115989. /**
  115990. * Unbind the material.
  115991. */
  115992. unbind(): void;
  115993. /**
  115994. * Bind only the world matrix to the material.
  115995. * @param world The world matrix to bind.
  115996. */
  115997. bindOnlyWorldMatrix(world: Matrix): void;
  115998. /**
  115999. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116000. * @param world The world matrix to bind.
  116001. * @param subMesh The submesh to bind for.
  116002. */
  116003. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116004. /**
  116005. * Checks to see if a texture is used in the material.
  116006. * @param texture - Base texture to use.
  116007. * @returns - Boolean specifying if a texture is used in the material.
  116008. */
  116009. hasTexture(texture: BaseTexture): boolean;
  116010. /**
  116011. * Dispose the material.
  116012. * @param forceDisposeEffect Force disposal of the associated effect.
  116013. * @param forceDisposeTextures Force disposal of the associated textures.
  116014. */
  116015. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116016. /**
  116017. * Clones the material.
  116018. * @param name The cloned name.
  116019. * @returns The cloned material.
  116020. */
  116021. clone(name: string): BackgroundMaterial;
  116022. /**
  116023. * Serializes the current material to its JSON representation.
  116024. * @returns The JSON representation.
  116025. */
  116026. serialize(): any;
  116027. /**
  116028. * Gets the class name of the material
  116029. * @returns "BackgroundMaterial"
  116030. */
  116031. getClassName(): string;
  116032. /**
  116033. * Parse a JSON input to create back a background material.
  116034. * @param source The JSON data to parse
  116035. * @param scene The scene to create the parsed material in
  116036. * @param rootUrl The root url of the assets the material depends upon
  116037. * @returns the instantiated BackgroundMaterial.
  116038. */
  116039. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116040. }
  116041. }
  116042. declare module BABYLON {
  116043. /**
  116044. * Represents the different options available during the creation of
  116045. * a Environment helper.
  116046. *
  116047. * This can control the default ground, skybox and image processing setup of your scene.
  116048. */
  116049. export interface IEnvironmentHelperOptions {
  116050. /**
  116051. * Specifies wether or not to create a ground.
  116052. * True by default.
  116053. */
  116054. createGround: boolean;
  116055. /**
  116056. * Specifies the ground size.
  116057. * 15 by default.
  116058. */
  116059. groundSize: number;
  116060. /**
  116061. * The texture used on the ground for the main color.
  116062. * Comes from the BabylonJS CDN by default.
  116063. *
  116064. * Remarks: Can be either a texture or a url.
  116065. */
  116066. groundTexture: string | BaseTexture;
  116067. /**
  116068. * The color mixed in the ground texture by default.
  116069. * BabylonJS clearColor by default.
  116070. */
  116071. groundColor: Color3;
  116072. /**
  116073. * Specifies the ground opacity.
  116074. * 1 by default.
  116075. */
  116076. groundOpacity: number;
  116077. /**
  116078. * Enables the ground to receive shadows.
  116079. * True by default.
  116080. */
  116081. enableGroundShadow: boolean;
  116082. /**
  116083. * Helps preventing the shadow to be fully black on the ground.
  116084. * 0.5 by default.
  116085. */
  116086. groundShadowLevel: number;
  116087. /**
  116088. * Creates a mirror texture attach to the ground.
  116089. * false by default.
  116090. */
  116091. enableGroundMirror: boolean;
  116092. /**
  116093. * Specifies the ground mirror size ratio.
  116094. * 0.3 by default as the default kernel is 64.
  116095. */
  116096. groundMirrorSizeRatio: number;
  116097. /**
  116098. * Specifies the ground mirror blur kernel size.
  116099. * 64 by default.
  116100. */
  116101. groundMirrorBlurKernel: number;
  116102. /**
  116103. * Specifies the ground mirror visibility amount.
  116104. * 1 by default
  116105. */
  116106. groundMirrorAmount: number;
  116107. /**
  116108. * Specifies the ground mirror reflectance weight.
  116109. * This uses the standard weight of the background material to setup the fresnel effect
  116110. * of the mirror.
  116111. * 1 by default.
  116112. */
  116113. groundMirrorFresnelWeight: number;
  116114. /**
  116115. * Specifies the ground mirror Falloff distance.
  116116. * This can helps reducing the size of the reflection.
  116117. * 0 by Default.
  116118. */
  116119. groundMirrorFallOffDistance: number;
  116120. /**
  116121. * Specifies the ground mirror texture type.
  116122. * Unsigned Int by Default.
  116123. */
  116124. groundMirrorTextureType: number;
  116125. /**
  116126. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116127. * the shown objects.
  116128. */
  116129. groundYBias: number;
  116130. /**
  116131. * Specifies wether or not to create a skybox.
  116132. * True by default.
  116133. */
  116134. createSkybox: boolean;
  116135. /**
  116136. * Specifies the skybox size.
  116137. * 20 by default.
  116138. */
  116139. skyboxSize: number;
  116140. /**
  116141. * The texture used on the skybox for the main color.
  116142. * Comes from the BabylonJS CDN by default.
  116143. *
  116144. * Remarks: Can be either a texture or a url.
  116145. */
  116146. skyboxTexture: string | BaseTexture;
  116147. /**
  116148. * The color mixed in the skybox texture by default.
  116149. * BabylonJS clearColor by default.
  116150. */
  116151. skyboxColor: Color3;
  116152. /**
  116153. * The background rotation around the Y axis of the scene.
  116154. * This helps aligning the key lights of your scene with the background.
  116155. * 0 by default.
  116156. */
  116157. backgroundYRotation: number;
  116158. /**
  116159. * Compute automatically the size of the elements to best fit with the scene.
  116160. */
  116161. sizeAuto: boolean;
  116162. /**
  116163. * Default position of the rootMesh if autoSize is not true.
  116164. */
  116165. rootPosition: Vector3;
  116166. /**
  116167. * Sets up the image processing in the scene.
  116168. * true by default.
  116169. */
  116170. setupImageProcessing: boolean;
  116171. /**
  116172. * The texture used as your environment texture in the scene.
  116173. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116174. *
  116175. * Remarks: Can be either a texture or a url.
  116176. */
  116177. environmentTexture: string | BaseTexture;
  116178. /**
  116179. * The value of the exposure to apply to the scene.
  116180. * 0.6 by default if setupImageProcessing is true.
  116181. */
  116182. cameraExposure: number;
  116183. /**
  116184. * The value of the contrast to apply to the scene.
  116185. * 1.6 by default if setupImageProcessing is true.
  116186. */
  116187. cameraContrast: number;
  116188. /**
  116189. * Specifies wether or not tonemapping should be enabled in the scene.
  116190. * true by default if setupImageProcessing is true.
  116191. */
  116192. toneMappingEnabled: boolean;
  116193. }
  116194. /**
  116195. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116196. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116197. * It also helps with the default setup of your imageProcessing configuration.
  116198. */
  116199. export class EnvironmentHelper {
  116200. /**
  116201. * Default ground texture URL.
  116202. */
  116203. private static _groundTextureCDNUrl;
  116204. /**
  116205. * Default skybox texture URL.
  116206. */
  116207. private static _skyboxTextureCDNUrl;
  116208. /**
  116209. * Default environment texture URL.
  116210. */
  116211. private static _environmentTextureCDNUrl;
  116212. /**
  116213. * Creates the default options for the helper.
  116214. */
  116215. private static _getDefaultOptions;
  116216. private _rootMesh;
  116217. /**
  116218. * Gets the root mesh created by the helper.
  116219. */
  116220. readonly rootMesh: Mesh;
  116221. private _skybox;
  116222. /**
  116223. * Gets the skybox created by the helper.
  116224. */
  116225. readonly skybox: Nullable<Mesh>;
  116226. private _skyboxTexture;
  116227. /**
  116228. * Gets the skybox texture created by the helper.
  116229. */
  116230. readonly skyboxTexture: Nullable<BaseTexture>;
  116231. private _skyboxMaterial;
  116232. /**
  116233. * Gets the skybox material created by the helper.
  116234. */
  116235. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116236. private _ground;
  116237. /**
  116238. * Gets the ground mesh created by the helper.
  116239. */
  116240. readonly ground: Nullable<Mesh>;
  116241. private _groundTexture;
  116242. /**
  116243. * Gets the ground texture created by the helper.
  116244. */
  116245. readonly groundTexture: Nullable<BaseTexture>;
  116246. private _groundMirror;
  116247. /**
  116248. * Gets the ground mirror created by the helper.
  116249. */
  116250. readonly groundMirror: Nullable<MirrorTexture>;
  116251. /**
  116252. * Gets the ground mirror render list to helps pushing the meshes
  116253. * you wish in the ground reflection.
  116254. */
  116255. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116256. private _groundMaterial;
  116257. /**
  116258. * Gets the ground material created by the helper.
  116259. */
  116260. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116261. /**
  116262. * Stores the creation options.
  116263. */
  116264. private readonly _scene;
  116265. private _options;
  116266. /**
  116267. * This observable will be notified with any error during the creation of the environment,
  116268. * mainly texture creation errors.
  116269. */
  116270. onErrorObservable: Observable<{
  116271. message?: string;
  116272. exception?: any;
  116273. }>;
  116274. /**
  116275. * constructor
  116276. * @param options Defines the options we want to customize the helper
  116277. * @param scene The scene to add the material to
  116278. */
  116279. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116280. /**
  116281. * Updates the background according to the new options
  116282. * @param options
  116283. */
  116284. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116285. /**
  116286. * Sets the primary color of all the available elements.
  116287. * @param color the main color to affect to the ground and the background
  116288. */
  116289. setMainColor(color: Color3): void;
  116290. /**
  116291. * Setup the image processing according to the specified options.
  116292. */
  116293. private _setupImageProcessing;
  116294. /**
  116295. * Setup the environment texture according to the specified options.
  116296. */
  116297. private _setupEnvironmentTexture;
  116298. /**
  116299. * Setup the background according to the specified options.
  116300. */
  116301. private _setupBackground;
  116302. /**
  116303. * Get the scene sizes according to the setup.
  116304. */
  116305. private _getSceneSize;
  116306. /**
  116307. * Setup the ground according to the specified options.
  116308. */
  116309. private _setupGround;
  116310. /**
  116311. * Setup the ground material according to the specified options.
  116312. */
  116313. private _setupGroundMaterial;
  116314. /**
  116315. * Setup the ground diffuse texture according to the specified options.
  116316. */
  116317. private _setupGroundDiffuseTexture;
  116318. /**
  116319. * Setup the ground mirror texture according to the specified options.
  116320. */
  116321. private _setupGroundMirrorTexture;
  116322. /**
  116323. * Setup the ground to receive the mirror texture.
  116324. */
  116325. private _setupMirrorInGroundMaterial;
  116326. /**
  116327. * Setup the skybox according to the specified options.
  116328. */
  116329. private _setupSkybox;
  116330. /**
  116331. * Setup the skybox material according to the specified options.
  116332. */
  116333. private _setupSkyboxMaterial;
  116334. /**
  116335. * Setup the skybox reflection texture according to the specified options.
  116336. */
  116337. private _setupSkyboxReflectionTexture;
  116338. private _errorHandler;
  116339. /**
  116340. * Dispose all the elements created by the Helper.
  116341. */
  116342. dispose(): void;
  116343. }
  116344. }
  116345. declare module BABYLON {
  116346. /**
  116347. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  116348. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  116349. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  116350. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  116351. */
  116352. export class PhotoDome extends TransformNode {
  116353. /**
  116354. * Define the image as a Monoscopic panoramic 360 image.
  116355. */
  116356. static readonly MODE_MONOSCOPIC: number;
  116357. /**
  116358. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116359. */
  116360. static readonly MODE_TOPBOTTOM: number;
  116361. /**
  116362. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116363. */
  116364. static readonly MODE_SIDEBYSIDE: number;
  116365. private _useDirectMapping;
  116366. /**
  116367. * The texture being displayed on the sphere
  116368. */
  116369. protected _photoTexture: Texture;
  116370. /**
  116371. * Gets or sets the texture being displayed on the sphere
  116372. */
  116373. photoTexture: Texture;
  116374. /**
  116375. * Observable raised when an error occured while loading the 360 image
  116376. */
  116377. onLoadErrorObservable: Observable<string>;
  116378. /**
  116379. * The skybox material
  116380. */
  116381. protected _material: BackgroundMaterial;
  116382. /**
  116383. * The surface used for the skybox
  116384. */
  116385. protected _mesh: Mesh;
  116386. /**
  116387. * Gets the mesh used for the skybox.
  116388. */
  116389. readonly mesh: Mesh;
  116390. /**
  116391. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116392. * Also see the options.resolution property.
  116393. */
  116394. fovMultiplier: number;
  116395. private _imageMode;
  116396. /**
  116397. * Gets or set the current video mode for the video. It can be:
  116398. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  116399. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  116400. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  116401. */
  116402. imageMode: number;
  116403. /**
  116404. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  116405. * @param name Element's name, child elements will append suffixes for their own names.
  116406. * @param urlsOfPhoto defines the url of the photo to display
  116407. * @param options defines an object containing optional or exposed sub element properties
  116408. * @param onError defines a callback called when an error occured while loading the texture
  116409. */
  116410. constructor(name: string, urlOfPhoto: string, options: {
  116411. resolution?: number;
  116412. size?: number;
  116413. useDirectMapping?: boolean;
  116414. faceForward?: boolean;
  116415. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  116416. private _onBeforeCameraRenderObserver;
  116417. private _changeImageMode;
  116418. /**
  116419. * Releases resources associated with this node.
  116420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  116421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  116422. */
  116423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  116424. }
  116425. }
  116426. declare module BABYLON {
  116427. /**
  116428. * Class used to host RGBD texture specific utilities
  116429. */
  116430. export class RGBDTextureTools {
  116431. /**
  116432. * Expand the RGBD Texture from RGBD to Half Float if possible.
  116433. * @param texture the texture to expand.
  116434. */
  116435. static ExpandRGBDTexture(texture: Texture): void;
  116436. }
  116437. }
  116438. declare module BABYLON {
  116439. /**
  116440. * Class used to host texture specific utilities
  116441. */
  116442. export class BRDFTextureTools {
  116443. /**
  116444. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  116445. * @param scene defines the hosting scene
  116446. * @returns the environment BRDF texture
  116447. */
  116448. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  116449. private static _environmentBRDFBase64Texture;
  116450. }
  116451. }
  116452. declare module BABYLON {
  116453. /**
  116454. * @hidden
  116455. */
  116456. export interface IMaterialClearCoatDefines {
  116457. CLEARCOAT: boolean;
  116458. CLEARCOAT_DEFAULTIOR: boolean;
  116459. CLEARCOAT_TEXTURE: boolean;
  116460. CLEARCOAT_TEXTUREDIRECTUV: number;
  116461. CLEARCOAT_BUMP: boolean;
  116462. CLEARCOAT_BUMPDIRECTUV: number;
  116463. CLEARCOAT_TINT: boolean;
  116464. CLEARCOAT_TINT_TEXTURE: boolean;
  116465. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116466. /** @hidden */
  116467. _areTexturesDirty: boolean;
  116468. }
  116469. /**
  116470. * Define the code related to the clear coat parameters of the pbr material.
  116471. */
  116472. export class PBRClearCoatConfiguration {
  116473. /**
  116474. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116475. * The default fits with a polyurethane material.
  116476. */
  116477. private static readonly _DefaultIndexOfRefraction;
  116478. private _isEnabled;
  116479. /**
  116480. * Defines if the clear coat is enabled in the material.
  116481. */
  116482. isEnabled: boolean;
  116483. /**
  116484. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  116485. */
  116486. intensity: number;
  116487. /**
  116488. * Defines the clear coat layer roughness.
  116489. */
  116490. roughness: number;
  116491. private _indexOfRefraction;
  116492. /**
  116493. * Defines the index of refraction of the clear coat.
  116494. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  116495. * The default fits with a polyurethane material.
  116496. * Changing the default value is more performance intensive.
  116497. */
  116498. indexOfRefraction: number;
  116499. private _texture;
  116500. /**
  116501. * Stores the clear coat values in a texture.
  116502. */
  116503. texture: Nullable<BaseTexture>;
  116504. private _bumpTexture;
  116505. /**
  116506. * Define the clear coat specific bump texture.
  116507. */
  116508. bumpTexture: Nullable<BaseTexture>;
  116509. private _isTintEnabled;
  116510. /**
  116511. * Defines if the clear coat tint is enabled in the material.
  116512. */
  116513. isTintEnabled: boolean;
  116514. /**
  116515. * Defines the clear coat tint of the material.
  116516. * This is only use if tint is enabled
  116517. */
  116518. tintColor: Color3;
  116519. /**
  116520. * Defines the distance at which the tint color should be found in the
  116521. * clear coat media.
  116522. * This is only use if tint is enabled
  116523. */
  116524. tintColorAtDistance: number;
  116525. /**
  116526. * Defines the clear coat layer thickness.
  116527. * This is only use if tint is enabled
  116528. */
  116529. tintThickness: number;
  116530. private _tintTexture;
  116531. /**
  116532. * Stores the clear tint values in a texture.
  116533. * rgb is tint
  116534. * a is a thickness factor
  116535. */
  116536. tintTexture: Nullable<BaseTexture>;
  116537. /** @hidden */
  116538. private _internalMarkAllSubMeshesAsTexturesDirty;
  116539. /** @hidden */
  116540. _markAllSubMeshesAsTexturesDirty(): void;
  116541. /**
  116542. * Instantiate a new istance of clear coat configuration.
  116543. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116544. */
  116545. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116546. /**
  116547. * Gets wehter the submesh is ready to be used or not.
  116548. * @param defines the list of "defines" to update.
  116549. * @param scene defines the scene the material belongs to.
  116550. * @param engine defines the engine the material belongs to.
  116551. * @param disableBumpMap defines wether the material disables bump or not.
  116552. * @returns - boolean indicating that the submesh is ready or not.
  116553. */
  116554. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  116555. /**
  116556. * Checks to see if a texture is used in the material.
  116557. * @param defines the list of "defines" to update.
  116558. * @param scene defines the scene to the material belongs to.
  116559. */
  116560. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  116561. /**
  116562. * Binds the material data.
  116563. * @param uniformBuffer defines the Uniform buffer to fill in.
  116564. * @param scene defines the scene the material belongs to.
  116565. * @param engine defines the engine the material belongs to.
  116566. * @param disableBumpMap defines wether the material disables bump or not.
  116567. * @param isFrozen defines wether the material is frozen or not.
  116568. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116569. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116570. */
  116571. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  116572. /**
  116573. * Checks to see if a texture is used in the material.
  116574. * @param texture - Base texture to use.
  116575. * @returns - Boolean specifying if a texture is used in the material.
  116576. */
  116577. hasTexture(texture: BaseTexture): boolean;
  116578. /**
  116579. * Returns an array of the actively used textures.
  116580. * @param activeTextures Array of BaseTextures
  116581. */
  116582. getActiveTextures(activeTextures: BaseTexture[]): void;
  116583. /**
  116584. * Returns the animatable textures.
  116585. * @param animatables Array of animatable textures.
  116586. */
  116587. getAnimatables(animatables: IAnimatable[]): void;
  116588. /**
  116589. * Disposes the resources of the material.
  116590. * @param forceDisposeTextures - Forces the disposal of all textures.
  116591. */
  116592. dispose(forceDisposeTextures?: boolean): void;
  116593. /**
  116594. * Get the current class name of the texture useful for serialization or dynamic coding.
  116595. * @returns "PBRClearCoatConfiguration"
  116596. */
  116597. getClassName(): string;
  116598. /**
  116599. * Add fallbacks to the effect fallbacks list.
  116600. * @param defines defines the Base texture to use.
  116601. * @param fallbacks defines the current fallback list.
  116602. * @param currentRank defines the current fallback rank.
  116603. * @returns the new fallback rank.
  116604. */
  116605. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116606. /**
  116607. * Add the required uniforms to the current list.
  116608. * @param uniforms defines the current uniform list.
  116609. */
  116610. static AddUniforms(uniforms: string[]): void;
  116611. /**
  116612. * Add the required samplers to the current list.
  116613. * @param samplers defines the current sampler list.
  116614. */
  116615. static AddSamplers(samplers: string[]): void;
  116616. /**
  116617. * Add the required uniforms to the current buffer.
  116618. * @param uniformBuffer defines the current uniform buffer.
  116619. */
  116620. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116621. /**
  116622. * Makes a duplicate of the current configuration into another one.
  116623. * @param clearCoatConfiguration define the config where to copy the info
  116624. */
  116625. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  116626. /**
  116627. * Serializes this clear coat configuration.
  116628. * @returns - An object with the serialized config.
  116629. */
  116630. serialize(): any;
  116631. /**
  116632. * Parses a anisotropy Configuration from a serialized object.
  116633. * @param source - Serialized object.
  116634. * @param scene Defines the scene we are parsing for
  116635. * @param rootUrl Defines the rootUrl to load from
  116636. */
  116637. parse(source: any, scene: Scene, rootUrl: string): void;
  116638. }
  116639. }
  116640. declare module BABYLON {
  116641. /**
  116642. * @hidden
  116643. */
  116644. export interface IMaterialAnisotropicDefines {
  116645. ANISOTROPIC: boolean;
  116646. ANISOTROPIC_TEXTURE: boolean;
  116647. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116648. MAINUV1: boolean;
  116649. _areTexturesDirty: boolean;
  116650. _needUVs: boolean;
  116651. }
  116652. /**
  116653. * Define the code related to the anisotropic parameters of the pbr material.
  116654. */
  116655. export class PBRAnisotropicConfiguration {
  116656. private _isEnabled;
  116657. /**
  116658. * Defines if the anisotropy is enabled in the material.
  116659. */
  116660. isEnabled: boolean;
  116661. /**
  116662. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  116663. */
  116664. intensity: number;
  116665. /**
  116666. * Defines if the effect is along the tangents, bitangents or in between.
  116667. * By default, the effect is "strectching" the highlights along the tangents.
  116668. */
  116669. direction: Vector2;
  116670. private _texture;
  116671. /**
  116672. * Stores the anisotropy values in a texture.
  116673. * rg is direction (like normal from -1 to 1)
  116674. * b is a intensity
  116675. */
  116676. texture: Nullable<BaseTexture>;
  116677. /** @hidden */
  116678. private _internalMarkAllSubMeshesAsTexturesDirty;
  116679. /** @hidden */
  116680. _markAllSubMeshesAsTexturesDirty(): void;
  116681. /**
  116682. * Instantiate a new istance of anisotropy configuration.
  116683. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116684. */
  116685. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116686. /**
  116687. * Specifies that the submesh is ready to be used.
  116688. * @param defines the list of "defines" to update.
  116689. * @param scene defines the scene the material belongs to.
  116690. * @returns - boolean indicating that the submesh is ready or not.
  116691. */
  116692. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  116693. /**
  116694. * Checks to see if a texture is used in the material.
  116695. * @param defines the list of "defines" to update.
  116696. * @param mesh the mesh we are preparing the defines for.
  116697. * @param scene defines the scene the material belongs to.
  116698. */
  116699. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  116700. /**
  116701. * Binds the material data.
  116702. * @param uniformBuffer defines the Uniform buffer to fill in.
  116703. * @param scene defines the scene the material belongs to.
  116704. * @param isFrozen defines wether the material is frozen or not.
  116705. */
  116706. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116707. /**
  116708. * Checks to see if a texture is used in the material.
  116709. * @param texture - Base texture to use.
  116710. * @returns - Boolean specifying if a texture is used in the material.
  116711. */
  116712. hasTexture(texture: BaseTexture): boolean;
  116713. /**
  116714. * Returns an array of the actively used textures.
  116715. * @param activeTextures Array of BaseTextures
  116716. */
  116717. getActiveTextures(activeTextures: BaseTexture[]): void;
  116718. /**
  116719. * Returns the animatable textures.
  116720. * @param animatables Array of animatable textures.
  116721. */
  116722. getAnimatables(animatables: IAnimatable[]): void;
  116723. /**
  116724. * Disposes the resources of the material.
  116725. * @param forceDisposeTextures - Forces the disposal of all textures.
  116726. */
  116727. dispose(forceDisposeTextures?: boolean): void;
  116728. /**
  116729. * Get the current class name of the texture useful for serialization or dynamic coding.
  116730. * @returns "PBRAnisotropicConfiguration"
  116731. */
  116732. getClassName(): string;
  116733. /**
  116734. * Add fallbacks to the effect fallbacks list.
  116735. * @param defines defines the Base texture to use.
  116736. * @param fallbacks defines the current fallback list.
  116737. * @param currentRank defines the current fallback rank.
  116738. * @returns the new fallback rank.
  116739. */
  116740. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116741. /**
  116742. * Add the required uniforms to the current list.
  116743. * @param uniforms defines the current uniform list.
  116744. */
  116745. static AddUniforms(uniforms: string[]): void;
  116746. /**
  116747. * Add the required uniforms to the current buffer.
  116748. * @param uniformBuffer defines the current uniform buffer.
  116749. */
  116750. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116751. /**
  116752. * Add the required samplers to the current list.
  116753. * @param samplers defines the current sampler list.
  116754. */
  116755. static AddSamplers(samplers: string[]): void;
  116756. /**
  116757. * Makes a duplicate of the current configuration into another one.
  116758. * @param anisotropicConfiguration define the config where to copy the info
  116759. */
  116760. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  116761. /**
  116762. * Serializes this anisotropy configuration.
  116763. * @returns - An object with the serialized config.
  116764. */
  116765. serialize(): any;
  116766. /**
  116767. * Parses a anisotropy Configuration from a serialized object.
  116768. * @param source - Serialized object.
  116769. * @param scene Defines the scene we are parsing for
  116770. * @param rootUrl Defines the rootUrl to load from
  116771. */
  116772. parse(source: any, scene: Scene, rootUrl: string): void;
  116773. }
  116774. }
  116775. declare module BABYLON {
  116776. /**
  116777. * @hidden
  116778. */
  116779. export interface IMaterialBRDFDefines {
  116780. BRDF_V_HEIGHT_CORRELATED: boolean;
  116781. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116782. SPHERICAL_HARMONICS: boolean;
  116783. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116784. /** @hidden */
  116785. _areMiscDirty: boolean;
  116786. }
  116787. /**
  116788. * Define the code related to the BRDF parameters of the pbr material.
  116789. */
  116790. export class PBRBRDFConfiguration {
  116791. /**
  116792. * Default value used for the energy conservation.
  116793. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116794. */
  116795. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  116796. /**
  116797. * Default value used for the Smith Visibility Height Correlated mode.
  116798. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  116799. */
  116800. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  116801. /**
  116802. * Default value used for the IBL diffuse part.
  116803. * This can help switching back to the polynomials mode globally which is a tiny bit
  116804. * less GPU intensive at the drawback of a lower quality.
  116805. */
  116806. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116807. /**
  116808. * Default value used for activating energy conservation for the specular workflow.
  116809. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116810. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116811. */
  116812. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116813. private _useEnergyConservation;
  116814. /**
  116815. * Defines if the material uses energy conservation.
  116816. */
  116817. useEnergyConservation: boolean;
  116818. private _useSmithVisibilityHeightCorrelated;
  116819. /**
  116820. * LEGACY Mode set to false
  116821. * Defines if the material uses height smith correlated visibility term.
  116822. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116823. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116824. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116825. * Not relying on height correlated will also disable energy conservation.
  116826. */
  116827. useSmithVisibilityHeightCorrelated: boolean;
  116828. private _useSphericalHarmonics;
  116829. /**
  116830. * LEGACY Mode set to false
  116831. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116832. * diffuse part of the IBL.
  116833. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116834. * to the ground truth.
  116835. */
  116836. useSphericalHarmonics: boolean;
  116837. private _useSpecularGlossinessInputEnergyConservation;
  116838. /**
  116839. * Defines if the material uses energy conservation, when the specular workflow is active.
  116840. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116841. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116842. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116843. */
  116844. useSpecularGlossinessInputEnergyConservation: boolean;
  116845. /** @hidden */
  116846. private _internalMarkAllSubMeshesAsMiscDirty;
  116847. /** @hidden */
  116848. _markAllSubMeshesAsMiscDirty(): void;
  116849. /**
  116850. * Instantiate a new istance of clear coat configuration.
  116851. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116852. */
  116853. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116854. /**
  116855. * Checks to see if a texture is used in the material.
  116856. * @param defines the list of "defines" to update.
  116857. */
  116858. prepareDefines(defines: IMaterialBRDFDefines): void;
  116859. /**
  116860. * Get the current class name of the texture useful for serialization or dynamic coding.
  116861. * @returns "PBRClearCoatConfiguration"
  116862. */
  116863. getClassName(): string;
  116864. /**
  116865. * Makes a duplicate of the current configuration into another one.
  116866. * @param brdfConfiguration define the config where to copy the info
  116867. */
  116868. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116869. /**
  116870. * Serializes this BRDF configuration.
  116871. * @returns - An object with the serialized config.
  116872. */
  116873. serialize(): any;
  116874. /**
  116875. * Parses a anisotropy Configuration from a serialized object.
  116876. * @param source - Serialized object.
  116877. * @param scene Defines the scene we are parsing for
  116878. * @param rootUrl Defines the rootUrl to load from
  116879. */
  116880. parse(source: any, scene: Scene, rootUrl: string): void;
  116881. }
  116882. }
  116883. declare module BABYLON {
  116884. /**
  116885. * @hidden
  116886. */
  116887. export interface IMaterialSheenDefines {
  116888. SHEEN: boolean;
  116889. SHEEN_TEXTURE: boolean;
  116890. SHEEN_TEXTUREDIRECTUV: number;
  116891. SHEEN_LINKWITHALBEDO: boolean;
  116892. /** @hidden */
  116893. _areTexturesDirty: boolean;
  116894. }
  116895. /**
  116896. * Define the code related to the Sheen parameters of the pbr material.
  116897. */
  116898. export class PBRSheenConfiguration {
  116899. private _isEnabled;
  116900. /**
  116901. * Defines if the material uses sheen.
  116902. */
  116903. isEnabled: boolean;
  116904. private _linkSheenWithAlbedo;
  116905. /**
  116906. * Defines if the sheen is linked to the sheen color.
  116907. */
  116908. linkSheenWithAlbedo: boolean;
  116909. /**
  116910. * Defines the sheen intensity.
  116911. */
  116912. intensity: number;
  116913. /**
  116914. * Defines the sheen color.
  116915. */
  116916. color: Color3;
  116917. private _texture;
  116918. /**
  116919. * Stores the sheen tint values in a texture.
  116920. * rgb is tint
  116921. * a is a intensity
  116922. */
  116923. texture: Nullable<BaseTexture>;
  116924. /** @hidden */
  116925. private _internalMarkAllSubMeshesAsTexturesDirty;
  116926. /** @hidden */
  116927. _markAllSubMeshesAsTexturesDirty(): void;
  116928. /**
  116929. * Instantiate a new istance of clear coat configuration.
  116930. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116931. */
  116932. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116933. /**
  116934. * Specifies that the submesh is ready to be used.
  116935. * @param defines the list of "defines" to update.
  116936. * @param scene defines the scene the material belongs to.
  116937. * @returns - boolean indicating that the submesh is ready or not.
  116938. */
  116939. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116940. /**
  116941. * Checks to see if a texture is used in the material.
  116942. * @param defines the list of "defines" to update.
  116943. * @param scene defines the scene the material belongs to.
  116944. */
  116945. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116946. /**
  116947. * Binds the material data.
  116948. * @param uniformBuffer defines the Uniform buffer to fill in.
  116949. * @param scene defines the scene the material belongs to.
  116950. * @param isFrozen defines wether the material is frozen or not.
  116951. */
  116952. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116953. /**
  116954. * Checks to see if a texture is used in the material.
  116955. * @param texture - Base texture to use.
  116956. * @returns - Boolean specifying if a texture is used in the material.
  116957. */
  116958. hasTexture(texture: BaseTexture): boolean;
  116959. /**
  116960. * Returns an array of the actively used textures.
  116961. * @param activeTextures Array of BaseTextures
  116962. */
  116963. getActiveTextures(activeTextures: BaseTexture[]): void;
  116964. /**
  116965. * Returns the animatable textures.
  116966. * @param animatables Array of animatable textures.
  116967. */
  116968. getAnimatables(animatables: IAnimatable[]): void;
  116969. /**
  116970. * Disposes the resources of the material.
  116971. * @param forceDisposeTextures - Forces the disposal of all textures.
  116972. */
  116973. dispose(forceDisposeTextures?: boolean): void;
  116974. /**
  116975. * Get the current class name of the texture useful for serialization or dynamic coding.
  116976. * @returns "PBRSheenConfiguration"
  116977. */
  116978. getClassName(): string;
  116979. /**
  116980. * Add fallbacks to the effect fallbacks list.
  116981. * @param defines defines the Base texture to use.
  116982. * @param fallbacks defines the current fallback list.
  116983. * @param currentRank defines the current fallback rank.
  116984. * @returns the new fallback rank.
  116985. */
  116986. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116987. /**
  116988. * Add the required uniforms to the current list.
  116989. * @param uniforms defines the current uniform list.
  116990. */
  116991. static AddUniforms(uniforms: string[]): void;
  116992. /**
  116993. * Add the required uniforms to the current buffer.
  116994. * @param uniformBuffer defines the current uniform buffer.
  116995. */
  116996. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116997. /**
  116998. * Add the required samplers to the current list.
  116999. * @param samplers defines the current sampler list.
  117000. */
  117001. static AddSamplers(samplers: string[]): void;
  117002. /**
  117003. * Makes a duplicate of the current configuration into another one.
  117004. * @param sheenConfiguration define the config where to copy the info
  117005. */
  117006. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117007. /**
  117008. * Serializes this BRDF configuration.
  117009. * @returns - An object with the serialized config.
  117010. */
  117011. serialize(): any;
  117012. /**
  117013. * Parses a anisotropy Configuration from a serialized object.
  117014. * @param source - Serialized object.
  117015. * @param scene Defines the scene we are parsing for
  117016. * @param rootUrl Defines the rootUrl to load from
  117017. */
  117018. parse(source: any, scene: Scene, rootUrl: string): void;
  117019. }
  117020. }
  117021. declare module BABYLON {
  117022. /**
  117023. * @hidden
  117024. */
  117025. export interface IMaterialSubSurfaceDefines {
  117026. SUBSURFACE: boolean;
  117027. SS_REFRACTION: boolean;
  117028. SS_TRANSLUCENCY: boolean;
  117029. SS_SCATERRING: boolean;
  117030. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117031. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117032. SS_REFRACTIONMAP_3D: boolean;
  117033. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117034. SS_LODINREFRACTIONALPHA: boolean;
  117035. SS_GAMMAREFRACTION: boolean;
  117036. SS_RGBDREFRACTION: boolean;
  117037. SS_LINEARSPECULARREFRACTION: boolean;
  117038. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117039. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117040. /** @hidden */
  117041. _areTexturesDirty: boolean;
  117042. }
  117043. /**
  117044. * Define the code related to the sub surface parameters of the pbr material.
  117045. */
  117046. export class PBRSubSurfaceConfiguration {
  117047. private _isRefractionEnabled;
  117048. /**
  117049. * Defines if the refraction is enabled in the material.
  117050. */
  117051. isRefractionEnabled: boolean;
  117052. private _isTranslucencyEnabled;
  117053. /**
  117054. * Defines if the translucency is enabled in the material.
  117055. */
  117056. isTranslucencyEnabled: boolean;
  117057. private _isScatteringEnabled;
  117058. /**
  117059. * Defines the refraction intensity of the material.
  117060. * The refraction when enabled replaces the Diffuse part of the material.
  117061. * The intensity helps transitionning between diffuse and refraction.
  117062. */
  117063. refractionIntensity: number;
  117064. /**
  117065. * Defines the translucency intensity of the material.
  117066. * When translucency has been enabled, this defines how much of the "translucency"
  117067. * is addded to the diffuse part of the material.
  117068. */
  117069. translucencyIntensity: number;
  117070. /**
  117071. * Defines the scattering intensity of the material.
  117072. * When scattering has been enabled, this defines how much of the "scattered light"
  117073. * is addded to the diffuse part of the material.
  117074. */
  117075. scatteringIntensity: number;
  117076. private _thicknessTexture;
  117077. /**
  117078. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117079. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117080. * 0 would mean minimumThickness
  117081. * 1 would mean maximumThickness
  117082. * The other channels might be use as a mask to vary the different effects intensity.
  117083. */
  117084. thicknessTexture: Nullable<BaseTexture>;
  117085. private _refractionTexture;
  117086. /**
  117087. * Defines the texture to use for refraction.
  117088. */
  117089. refractionTexture: Nullable<BaseTexture>;
  117090. private _indexOfRefraction;
  117091. /**
  117092. * Defines the index of refraction used in the material.
  117093. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117094. */
  117095. indexOfRefraction: number;
  117096. private _invertRefractionY;
  117097. /**
  117098. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117099. */
  117100. invertRefractionY: boolean;
  117101. private _linkRefractionWithTransparency;
  117102. /**
  117103. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117104. * Materials half opaque for instance using refraction could benefit from this control.
  117105. */
  117106. linkRefractionWithTransparency: boolean;
  117107. /**
  117108. * Defines the minimum thickness stored in the thickness map.
  117109. * If no thickness map is defined, this value will be used to simulate thickness.
  117110. */
  117111. minimumThickness: number;
  117112. /**
  117113. * Defines the maximum thickness stored in the thickness map.
  117114. */
  117115. maximumThickness: number;
  117116. /**
  117117. * Defines the volume tint of the material.
  117118. * This is used for both translucency and scattering.
  117119. */
  117120. tintColor: Color3;
  117121. /**
  117122. * Defines the distance at which the tint color should be found in the media.
  117123. * This is used for refraction only.
  117124. */
  117125. tintColorAtDistance: number;
  117126. /**
  117127. * Defines how far each channel transmit through the media.
  117128. * It is defined as a color to simplify it selection.
  117129. */
  117130. diffusionDistance: Color3;
  117131. private _useMaskFromThicknessTexture;
  117132. /**
  117133. * Stores the intensity of the different subsurface effects in the thickness texture.
  117134. * * the green channel is the translucency intensity.
  117135. * * the blue channel is the scattering intensity.
  117136. * * the alpha channel is the refraction intensity.
  117137. */
  117138. useMaskFromThicknessTexture: boolean;
  117139. /** @hidden */
  117140. private _internalMarkAllSubMeshesAsTexturesDirty;
  117141. /** @hidden */
  117142. _markAllSubMeshesAsTexturesDirty(): void;
  117143. /**
  117144. * Instantiate a new istance of sub surface configuration.
  117145. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117146. */
  117147. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117148. /**
  117149. * Gets wehter the submesh is ready to be used or not.
  117150. * @param defines the list of "defines" to update.
  117151. * @param scene defines the scene the material belongs to.
  117152. * @returns - boolean indicating that the submesh is ready or not.
  117153. */
  117154. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117155. /**
  117156. * Checks to see if a texture is used in the material.
  117157. * @param defines the list of "defines" to update.
  117158. * @param scene defines the scene to the material belongs to.
  117159. */
  117160. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117161. /**
  117162. * Binds the material data.
  117163. * @param uniformBuffer defines the Uniform buffer to fill in.
  117164. * @param scene defines the scene the material belongs to.
  117165. * @param engine defines the engine the material belongs to.
  117166. * @param isFrozen defines wether the material is frozen or not.
  117167. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117168. */
  117169. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117170. /**
  117171. * Unbinds the material from the mesh.
  117172. * @param activeEffect defines the effect that should be unbound from.
  117173. * @returns true if unbound, otherwise false
  117174. */
  117175. unbind(activeEffect: Effect): boolean;
  117176. /**
  117177. * Returns the texture used for refraction or null if none is used.
  117178. * @param scene defines the scene the material belongs to.
  117179. * @returns - Refraction texture if present. If no refraction texture and refraction
  117180. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117181. */
  117182. private _getRefractionTexture;
  117183. /**
  117184. * Returns true if alpha blending should be disabled.
  117185. */
  117186. readonly disableAlphaBlending: boolean;
  117187. /**
  117188. * Fills the list of render target textures.
  117189. * @param renderTargets the list of render targets to update
  117190. */
  117191. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117192. /**
  117193. * Checks to see if a texture is used in the material.
  117194. * @param texture - Base texture to use.
  117195. * @returns - Boolean specifying if a texture is used in the material.
  117196. */
  117197. hasTexture(texture: BaseTexture): boolean;
  117198. /**
  117199. * Gets a boolean indicating that current material needs to register RTT
  117200. * @returns true if this uses a render target otherwise false.
  117201. */
  117202. hasRenderTargetTextures(): boolean;
  117203. /**
  117204. * Returns an array of the actively used textures.
  117205. * @param activeTextures Array of BaseTextures
  117206. */
  117207. getActiveTextures(activeTextures: BaseTexture[]): void;
  117208. /**
  117209. * Returns the animatable textures.
  117210. * @param animatables Array of animatable textures.
  117211. */
  117212. getAnimatables(animatables: IAnimatable[]): void;
  117213. /**
  117214. * Disposes the resources of the material.
  117215. * @param forceDisposeTextures - Forces the disposal of all textures.
  117216. */
  117217. dispose(forceDisposeTextures?: boolean): void;
  117218. /**
  117219. * Get the current class name of the texture useful for serialization or dynamic coding.
  117220. * @returns "PBRSubSurfaceConfiguration"
  117221. */
  117222. getClassName(): string;
  117223. /**
  117224. * Add fallbacks to the effect fallbacks list.
  117225. * @param defines defines the Base texture to use.
  117226. * @param fallbacks defines the current fallback list.
  117227. * @param currentRank defines the current fallback rank.
  117228. * @returns the new fallback rank.
  117229. */
  117230. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117231. /**
  117232. * Add the required uniforms to the current list.
  117233. * @param uniforms defines the current uniform list.
  117234. */
  117235. static AddUniforms(uniforms: string[]): void;
  117236. /**
  117237. * Add the required samplers to the current list.
  117238. * @param samplers defines the current sampler list.
  117239. */
  117240. static AddSamplers(samplers: string[]): void;
  117241. /**
  117242. * Add the required uniforms to the current buffer.
  117243. * @param uniformBuffer defines the current uniform buffer.
  117244. */
  117245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117246. /**
  117247. * Makes a duplicate of the current configuration into another one.
  117248. * @param configuration define the config where to copy the info
  117249. */
  117250. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117251. /**
  117252. * Serializes this Sub Surface configuration.
  117253. * @returns - An object with the serialized config.
  117254. */
  117255. serialize(): any;
  117256. /**
  117257. * Parses a anisotropy Configuration from a serialized object.
  117258. * @param source - Serialized object.
  117259. * @param scene Defines the scene we are parsing for
  117260. * @param rootUrl Defines the rootUrl to load from
  117261. */
  117262. parse(source: any, scene: Scene, rootUrl: string): void;
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /** @hidden */
  117267. export var pbrFragmentDeclaration: {
  117268. name: string;
  117269. shader: string;
  117270. };
  117271. }
  117272. declare module BABYLON {
  117273. /** @hidden */
  117274. export var pbrUboDeclaration: {
  117275. name: string;
  117276. shader: string;
  117277. };
  117278. }
  117279. declare module BABYLON {
  117280. /** @hidden */
  117281. export var pbrFragmentExtraDeclaration: {
  117282. name: string;
  117283. shader: string;
  117284. };
  117285. }
  117286. declare module BABYLON {
  117287. /** @hidden */
  117288. export var pbrFragmentSamplersDeclaration: {
  117289. name: string;
  117290. shader: string;
  117291. };
  117292. }
  117293. declare module BABYLON {
  117294. /** @hidden */
  117295. export var pbrHelperFunctions: {
  117296. name: string;
  117297. shader: string;
  117298. };
  117299. }
  117300. declare module BABYLON {
  117301. /** @hidden */
  117302. export var harmonicsFunctions: {
  117303. name: string;
  117304. shader: string;
  117305. };
  117306. }
  117307. declare module BABYLON {
  117308. /** @hidden */
  117309. export var pbrDirectLightingSetupFunctions: {
  117310. name: string;
  117311. shader: string;
  117312. };
  117313. }
  117314. declare module BABYLON {
  117315. /** @hidden */
  117316. export var pbrDirectLightingFalloffFunctions: {
  117317. name: string;
  117318. shader: string;
  117319. };
  117320. }
  117321. declare module BABYLON {
  117322. /** @hidden */
  117323. export var pbrBRDFFunctions: {
  117324. name: string;
  117325. shader: string;
  117326. };
  117327. }
  117328. declare module BABYLON {
  117329. /** @hidden */
  117330. export var pbrDirectLightingFunctions: {
  117331. name: string;
  117332. shader: string;
  117333. };
  117334. }
  117335. declare module BABYLON {
  117336. /** @hidden */
  117337. export var pbrIBLFunctions: {
  117338. name: string;
  117339. shader: string;
  117340. };
  117341. }
  117342. declare module BABYLON {
  117343. /** @hidden */
  117344. export var pbrDebug: {
  117345. name: string;
  117346. shader: string;
  117347. };
  117348. }
  117349. declare module BABYLON {
  117350. /** @hidden */
  117351. export var pbrPixelShader: {
  117352. name: string;
  117353. shader: string;
  117354. };
  117355. }
  117356. declare module BABYLON {
  117357. /** @hidden */
  117358. export var pbrVertexDeclaration: {
  117359. name: string;
  117360. shader: string;
  117361. };
  117362. }
  117363. declare module BABYLON {
  117364. /** @hidden */
  117365. export var pbrVertexShader: {
  117366. name: string;
  117367. shader: string;
  117368. };
  117369. }
  117370. declare module BABYLON {
  117371. /**
  117372. * Manages the defines for the PBR Material.
  117373. * @hidden
  117374. */
  117375. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  117376. PBR: boolean;
  117377. MAINUV1: boolean;
  117378. MAINUV2: boolean;
  117379. UV1: boolean;
  117380. UV2: boolean;
  117381. ALBEDO: boolean;
  117382. ALBEDODIRECTUV: number;
  117383. VERTEXCOLOR: boolean;
  117384. AMBIENT: boolean;
  117385. AMBIENTDIRECTUV: number;
  117386. AMBIENTINGRAYSCALE: boolean;
  117387. OPACITY: boolean;
  117388. VERTEXALPHA: boolean;
  117389. OPACITYDIRECTUV: number;
  117390. OPACITYRGB: boolean;
  117391. ALPHATEST: boolean;
  117392. DEPTHPREPASS: boolean;
  117393. ALPHABLEND: boolean;
  117394. ALPHAFROMALBEDO: boolean;
  117395. ALPHATESTVALUE: string;
  117396. SPECULAROVERALPHA: boolean;
  117397. RADIANCEOVERALPHA: boolean;
  117398. ALPHAFRESNEL: boolean;
  117399. LINEARALPHAFRESNEL: boolean;
  117400. PREMULTIPLYALPHA: boolean;
  117401. EMISSIVE: boolean;
  117402. EMISSIVEDIRECTUV: number;
  117403. REFLECTIVITY: boolean;
  117404. REFLECTIVITYDIRECTUV: number;
  117405. SPECULARTERM: boolean;
  117406. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  117407. MICROSURFACEAUTOMATIC: boolean;
  117408. LODBASEDMICROSFURACE: boolean;
  117409. MICROSURFACEMAP: boolean;
  117410. MICROSURFACEMAPDIRECTUV: number;
  117411. METALLICWORKFLOW: boolean;
  117412. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  117413. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  117414. METALLNESSSTOREINMETALMAPBLUE: boolean;
  117415. AOSTOREINMETALMAPRED: boolean;
  117416. METALLICF0FACTORFROMMETALLICMAP: boolean;
  117417. ENVIRONMENTBRDF: boolean;
  117418. ENVIRONMENTBRDF_RGBD: boolean;
  117419. NORMAL: boolean;
  117420. TANGENT: boolean;
  117421. BUMP: boolean;
  117422. BUMPDIRECTUV: number;
  117423. OBJECTSPACE_NORMALMAP: boolean;
  117424. PARALLAX: boolean;
  117425. PARALLAXOCCLUSION: boolean;
  117426. NORMALXYSCALE: boolean;
  117427. LIGHTMAP: boolean;
  117428. LIGHTMAPDIRECTUV: number;
  117429. USELIGHTMAPASSHADOWMAP: boolean;
  117430. GAMMALIGHTMAP: boolean;
  117431. RGBDLIGHTMAP: boolean;
  117432. REFLECTION: boolean;
  117433. REFLECTIONMAP_3D: boolean;
  117434. REFLECTIONMAP_SPHERICAL: boolean;
  117435. REFLECTIONMAP_PLANAR: boolean;
  117436. REFLECTIONMAP_CUBIC: boolean;
  117437. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  117438. REFLECTIONMAP_PROJECTION: boolean;
  117439. REFLECTIONMAP_SKYBOX: boolean;
  117440. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  117441. REFLECTIONMAP_EXPLICIT: boolean;
  117442. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  117443. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  117444. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  117445. INVERTCUBICMAP: boolean;
  117446. USESPHERICALFROMREFLECTIONMAP: boolean;
  117447. USEIRRADIANCEMAP: boolean;
  117448. SPHERICAL_HARMONICS: boolean;
  117449. USESPHERICALINVERTEX: boolean;
  117450. REFLECTIONMAP_OPPOSITEZ: boolean;
  117451. LODINREFLECTIONALPHA: boolean;
  117452. GAMMAREFLECTION: boolean;
  117453. RGBDREFLECTION: boolean;
  117454. LINEARSPECULARREFLECTION: boolean;
  117455. RADIANCEOCCLUSION: boolean;
  117456. HORIZONOCCLUSION: boolean;
  117457. INSTANCES: boolean;
  117458. NUM_BONE_INFLUENCERS: number;
  117459. BonesPerMesh: number;
  117460. BONETEXTURE: boolean;
  117461. NONUNIFORMSCALING: boolean;
  117462. MORPHTARGETS: boolean;
  117463. MORPHTARGETS_NORMAL: boolean;
  117464. MORPHTARGETS_TANGENT: boolean;
  117465. MORPHTARGETS_UV: boolean;
  117466. NUM_MORPH_INFLUENCERS: number;
  117467. IMAGEPROCESSING: boolean;
  117468. VIGNETTE: boolean;
  117469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  117470. VIGNETTEBLENDMODEOPAQUE: boolean;
  117471. TONEMAPPING: boolean;
  117472. TONEMAPPING_ACES: boolean;
  117473. CONTRAST: boolean;
  117474. COLORCURVES: boolean;
  117475. COLORGRADING: boolean;
  117476. COLORGRADING3D: boolean;
  117477. SAMPLER3DGREENDEPTH: boolean;
  117478. SAMPLER3DBGRMAP: boolean;
  117479. IMAGEPROCESSINGPOSTPROCESS: boolean;
  117480. EXPOSURE: boolean;
  117481. MULTIVIEW: boolean;
  117482. USEPHYSICALLIGHTFALLOFF: boolean;
  117483. USEGLTFLIGHTFALLOFF: boolean;
  117484. TWOSIDEDLIGHTING: boolean;
  117485. SHADOWFLOAT: boolean;
  117486. CLIPPLANE: boolean;
  117487. CLIPPLANE2: boolean;
  117488. CLIPPLANE3: boolean;
  117489. CLIPPLANE4: boolean;
  117490. POINTSIZE: boolean;
  117491. FOG: boolean;
  117492. LOGARITHMICDEPTH: boolean;
  117493. FORCENORMALFORWARD: boolean;
  117494. SPECULARAA: boolean;
  117495. CLEARCOAT: boolean;
  117496. CLEARCOAT_DEFAULTIOR: boolean;
  117497. CLEARCOAT_TEXTURE: boolean;
  117498. CLEARCOAT_TEXTUREDIRECTUV: number;
  117499. CLEARCOAT_BUMP: boolean;
  117500. CLEARCOAT_BUMPDIRECTUV: number;
  117501. CLEARCOAT_TINT: boolean;
  117502. CLEARCOAT_TINT_TEXTURE: boolean;
  117503. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117504. ANISOTROPIC: boolean;
  117505. ANISOTROPIC_TEXTURE: boolean;
  117506. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117507. BRDF_V_HEIGHT_CORRELATED: boolean;
  117508. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117509. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117510. SHEEN: boolean;
  117511. SHEEN_TEXTURE: boolean;
  117512. SHEEN_TEXTUREDIRECTUV: number;
  117513. SHEEN_LINKWITHALBEDO: boolean;
  117514. SUBSURFACE: boolean;
  117515. SS_REFRACTION: boolean;
  117516. SS_TRANSLUCENCY: boolean;
  117517. SS_SCATERRING: boolean;
  117518. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117519. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117520. SS_REFRACTIONMAP_3D: boolean;
  117521. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117522. SS_LODINREFRACTIONALPHA: boolean;
  117523. SS_GAMMAREFRACTION: boolean;
  117524. SS_RGBDREFRACTION: boolean;
  117525. SS_LINEARSPECULARREFRACTION: boolean;
  117526. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117527. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117528. UNLIT: boolean;
  117529. DEBUGMODE: number;
  117530. /**
  117531. * Initializes the PBR Material defines.
  117532. */
  117533. constructor();
  117534. /**
  117535. * Resets the PBR Material defines.
  117536. */
  117537. reset(): void;
  117538. }
  117539. /**
  117540. * The Physically based material base class of BJS.
  117541. *
  117542. * This offers the main features of a standard PBR material.
  117543. * For more information, please refer to the documentation :
  117544. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117545. */
  117546. export abstract class PBRBaseMaterial extends PushMaterial {
  117547. /**
  117548. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117549. */
  117550. static readonly PBRMATERIAL_OPAQUE: number;
  117551. /**
  117552. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117553. */
  117554. static readonly PBRMATERIAL_ALPHATEST: number;
  117555. /**
  117556. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117557. */
  117558. static readonly PBRMATERIAL_ALPHABLEND: number;
  117559. /**
  117560. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117561. * They are also discarded below the alpha cutoff threshold to improve performances.
  117562. */
  117563. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117564. /**
  117565. * Defines the default value of how much AO map is occluding the analytical lights
  117566. * (point spot...).
  117567. */
  117568. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117569. /**
  117570. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  117571. */
  117572. static readonly LIGHTFALLOFF_PHYSICAL: number;
  117573. /**
  117574. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  117575. * to enhance interoperability with other engines.
  117576. */
  117577. static readonly LIGHTFALLOFF_GLTF: number;
  117578. /**
  117579. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  117580. * to enhance interoperability with other materials.
  117581. */
  117582. static readonly LIGHTFALLOFF_STANDARD: number;
  117583. /**
  117584. * Intensity of the direct lights e.g. the four lights available in your scene.
  117585. * This impacts both the direct diffuse and specular highlights.
  117586. */
  117587. protected _directIntensity: number;
  117588. /**
  117589. * Intensity of the emissive part of the material.
  117590. * This helps controlling the emissive effect without modifying the emissive color.
  117591. */
  117592. protected _emissiveIntensity: number;
  117593. /**
  117594. * Intensity of the environment e.g. how much the environment will light the object
  117595. * either through harmonics for rough material or through the refelction for shiny ones.
  117596. */
  117597. protected _environmentIntensity: number;
  117598. /**
  117599. * This is a special control allowing the reduction of the specular highlights coming from the
  117600. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117601. */
  117602. protected _specularIntensity: number;
  117603. /**
  117604. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  117605. */
  117606. private _lightingInfos;
  117607. /**
  117608. * Debug Control allowing disabling the bump map on this material.
  117609. */
  117610. protected _disableBumpMap: boolean;
  117611. /**
  117612. * AKA Diffuse Texture in standard nomenclature.
  117613. */
  117614. protected _albedoTexture: Nullable<BaseTexture>;
  117615. /**
  117616. * AKA Occlusion Texture in other nomenclature.
  117617. */
  117618. protected _ambientTexture: Nullable<BaseTexture>;
  117619. /**
  117620. * AKA Occlusion Texture Intensity in other nomenclature.
  117621. */
  117622. protected _ambientTextureStrength: number;
  117623. /**
  117624. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117625. * 1 means it completely occludes it
  117626. * 0 mean it has no impact
  117627. */
  117628. protected _ambientTextureImpactOnAnalyticalLights: number;
  117629. /**
  117630. * Stores the alpha values in a texture.
  117631. */
  117632. protected _opacityTexture: Nullable<BaseTexture>;
  117633. /**
  117634. * Stores the reflection values in a texture.
  117635. */
  117636. protected _reflectionTexture: Nullable<BaseTexture>;
  117637. /**
  117638. * Stores the emissive values in a texture.
  117639. */
  117640. protected _emissiveTexture: Nullable<BaseTexture>;
  117641. /**
  117642. * AKA Specular texture in other nomenclature.
  117643. */
  117644. protected _reflectivityTexture: Nullable<BaseTexture>;
  117645. /**
  117646. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117647. */
  117648. protected _metallicTexture: Nullable<BaseTexture>;
  117649. /**
  117650. * Specifies the metallic scalar of the metallic/roughness workflow.
  117651. * Can also be used to scale the metalness values of the metallic texture.
  117652. */
  117653. protected _metallic: Nullable<number>;
  117654. /**
  117655. * Specifies the roughness scalar of the metallic/roughness workflow.
  117656. * Can also be used to scale the roughness values of the metallic texture.
  117657. */
  117658. protected _roughness: Nullable<number>;
  117659. /**
  117660. * Specifies the an F0 factor to help configuring the material F0.
  117661. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117662. * to 0.5 the previously hard coded value stays the same.
  117663. * Can also be used to scale the F0 values of the metallic texture.
  117664. */
  117665. protected _metallicF0Factor: number;
  117666. /**
  117667. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117668. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117669. * your expectation as it multiplies with the texture data.
  117670. */
  117671. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  117672. /**
  117673. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117674. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117675. */
  117676. protected _microSurfaceTexture: Nullable<BaseTexture>;
  117677. /**
  117678. * Stores surface normal data used to displace a mesh in a texture.
  117679. */
  117680. protected _bumpTexture: Nullable<BaseTexture>;
  117681. /**
  117682. * Stores the pre-calculated light information of a mesh in a texture.
  117683. */
  117684. protected _lightmapTexture: Nullable<BaseTexture>;
  117685. /**
  117686. * The color of a material in ambient lighting.
  117687. */
  117688. protected _ambientColor: Color3;
  117689. /**
  117690. * AKA Diffuse Color in other nomenclature.
  117691. */
  117692. protected _albedoColor: Color3;
  117693. /**
  117694. * AKA Specular Color in other nomenclature.
  117695. */
  117696. protected _reflectivityColor: Color3;
  117697. /**
  117698. * The color applied when light is reflected from a material.
  117699. */
  117700. protected _reflectionColor: Color3;
  117701. /**
  117702. * The color applied when light is emitted from a material.
  117703. */
  117704. protected _emissiveColor: Color3;
  117705. /**
  117706. * AKA Glossiness in other nomenclature.
  117707. */
  117708. protected _microSurface: number;
  117709. /**
  117710. * Specifies that the material will use the light map as a show map.
  117711. */
  117712. protected _useLightmapAsShadowmap: boolean;
  117713. /**
  117714. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117715. * makes the reflect vector face the model (under horizon).
  117716. */
  117717. protected _useHorizonOcclusion: boolean;
  117718. /**
  117719. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117720. * too much the area relying on ambient texture to define their ambient occlusion.
  117721. */
  117722. protected _useRadianceOcclusion: boolean;
  117723. /**
  117724. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117725. */
  117726. protected _useAlphaFromAlbedoTexture: boolean;
  117727. /**
  117728. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  117729. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117730. */
  117731. protected _useSpecularOverAlpha: boolean;
  117732. /**
  117733. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117734. */
  117735. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117736. /**
  117737. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117738. */
  117739. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  117740. /**
  117741. * Specifies if the metallic texture contains the roughness information in its green channel.
  117742. */
  117743. protected _useRoughnessFromMetallicTextureGreen: boolean;
  117744. /**
  117745. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117746. */
  117747. protected _useMetallnessFromMetallicTextureBlue: boolean;
  117748. /**
  117749. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117750. */
  117751. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  117752. /**
  117753. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117754. */
  117755. protected _useAmbientInGrayScale: boolean;
  117756. /**
  117757. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117758. * The material will try to infer what glossiness each pixel should be.
  117759. */
  117760. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  117761. /**
  117762. * Defines the falloff type used in this material.
  117763. * It by default is Physical.
  117764. */
  117765. protected _lightFalloff: number;
  117766. /**
  117767. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117768. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117769. */
  117770. protected _useRadianceOverAlpha: boolean;
  117771. /**
  117772. * Allows using an object space normal map (instead of tangent space).
  117773. */
  117774. protected _useObjectSpaceNormalMap: boolean;
  117775. /**
  117776. * Allows using the bump map in parallax mode.
  117777. */
  117778. protected _useParallax: boolean;
  117779. /**
  117780. * Allows using the bump map in parallax occlusion mode.
  117781. */
  117782. protected _useParallaxOcclusion: boolean;
  117783. /**
  117784. * Controls the scale bias of the parallax mode.
  117785. */
  117786. protected _parallaxScaleBias: number;
  117787. /**
  117788. * If sets to true, disables all the lights affecting the material.
  117789. */
  117790. protected _disableLighting: boolean;
  117791. /**
  117792. * Number of Simultaneous lights allowed on the material.
  117793. */
  117794. protected _maxSimultaneousLights: number;
  117795. /**
  117796. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117797. */
  117798. protected _invertNormalMapX: boolean;
  117799. /**
  117800. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117801. */
  117802. protected _invertNormalMapY: boolean;
  117803. /**
  117804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117805. */
  117806. protected _twoSidedLighting: boolean;
  117807. /**
  117808. * Defines the alpha limits in alpha test mode.
  117809. */
  117810. protected _alphaCutOff: number;
  117811. /**
  117812. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117813. */
  117814. protected _forceAlphaTest: boolean;
  117815. /**
  117816. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117817. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117818. */
  117819. protected _useAlphaFresnel: boolean;
  117820. /**
  117821. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117822. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117823. */
  117824. protected _useLinearAlphaFresnel: boolean;
  117825. /**
  117826. * The transparency mode of the material.
  117827. */
  117828. protected _transparencyMode: Nullable<number>;
  117829. /**
  117830. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117831. * from cos thetav and roughness:
  117832. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117833. */
  117834. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117835. /**
  117836. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117837. */
  117838. protected _forceIrradianceInFragment: boolean;
  117839. /**
  117840. * Force normal to face away from face.
  117841. */
  117842. protected _forceNormalForward: boolean;
  117843. /**
  117844. * Enables specular anti aliasing in the PBR shader.
  117845. * It will both interacts on the Geometry for analytical and IBL lighting.
  117846. * It also prefilter the roughness map based on the bump values.
  117847. */
  117848. protected _enableSpecularAntiAliasing: boolean;
  117849. /**
  117850. * Default configuration related to image processing available in the PBR Material.
  117851. */
  117852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117853. /**
  117854. * Keep track of the image processing observer to allow dispose and replace.
  117855. */
  117856. private _imageProcessingObserver;
  117857. /**
  117858. * Attaches a new image processing configuration to the PBR Material.
  117859. * @param configuration
  117860. */
  117861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117862. /**
  117863. * Stores the available render targets.
  117864. */
  117865. private _renderTargets;
  117866. /**
  117867. * Sets the global ambient color for the material used in lighting calculations.
  117868. */
  117869. private _globalAmbientColor;
  117870. /**
  117871. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117872. */
  117873. private _useLogarithmicDepth;
  117874. /**
  117875. * If set to true, no lighting calculations will be applied.
  117876. */
  117877. private _unlit;
  117878. private _debugMode;
  117879. /**
  117880. * @hidden
  117881. * This is reserved for the inspector.
  117882. * Defines the material debug mode.
  117883. * It helps seeing only some components of the material while troubleshooting.
  117884. */
  117885. debugMode: number;
  117886. /**
  117887. * @hidden
  117888. * This is reserved for the inspector.
  117889. * Specify from where on screen the debug mode should start.
  117890. * The value goes from -1 (full screen) to 1 (not visible)
  117891. * It helps with side by side comparison against the final render
  117892. * This defaults to -1
  117893. */
  117894. private debugLimit;
  117895. /**
  117896. * @hidden
  117897. * This is reserved for the inspector.
  117898. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117899. * You can use the factor to better multiply the final value.
  117900. */
  117901. private debugFactor;
  117902. /**
  117903. * Defines the clear coat layer parameters for the material.
  117904. */
  117905. readonly clearCoat: PBRClearCoatConfiguration;
  117906. /**
  117907. * Defines the anisotropic parameters for the material.
  117908. */
  117909. readonly anisotropy: PBRAnisotropicConfiguration;
  117910. /**
  117911. * Defines the BRDF parameters for the material.
  117912. */
  117913. readonly brdf: PBRBRDFConfiguration;
  117914. /**
  117915. * Defines the Sheen parameters for the material.
  117916. */
  117917. readonly sheen: PBRSheenConfiguration;
  117918. /**
  117919. * Defines the SubSurface parameters for the material.
  117920. */
  117921. readonly subSurface: PBRSubSurfaceConfiguration;
  117922. /**
  117923. * Custom callback helping to override the default shader used in the material.
  117924. */
  117925. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117926. protected _rebuildInParallel: boolean;
  117927. /**
  117928. * Instantiates a new PBRMaterial instance.
  117929. *
  117930. * @param name The material name
  117931. * @param scene The scene the material will be use in.
  117932. */
  117933. constructor(name: string, scene: Scene);
  117934. /**
  117935. * Gets a boolean indicating that current material needs to register RTT
  117936. */
  117937. readonly hasRenderTargetTextures: boolean;
  117938. /**
  117939. * Gets the name of the material class.
  117940. */
  117941. getClassName(): string;
  117942. /**
  117943. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117944. */
  117945. /**
  117946. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117947. */
  117948. useLogarithmicDepth: boolean;
  117949. /**
  117950. * Gets the current transparency mode.
  117951. */
  117952. /**
  117953. * Sets the transparency mode of the material.
  117954. *
  117955. * | Value | Type | Description |
  117956. * | ----- | ----------------------------------- | ----------- |
  117957. * | 0 | OPAQUE | |
  117958. * | 1 | ALPHATEST | |
  117959. * | 2 | ALPHABLEND | |
  117960. * | 3 | ALPHATESTANDBLEND | |
  117961. *
  117962. */
  117963. transparencyMode: Nullable<number>;
  117964. /**
  117965. * Returns true if alpha blending should be disabled.
  117966. */
  117967. private readonly _disableAlphaBlending;
  117968. /**
  117969. * Specifies whether or not this material should be rendered in alpha blend mode.
  117970. */
  117971. needAlphaBlending(): boolean;
  117972. /**
  117973. * Specifies if the mesh will require alpha blending.
  117974. * @param mesh - BJS mesh.
  117975. */
  117976. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117977. /**
  117978. * Specifies whether or not this material should be rendered in alpha test mode.
  117979. */
  117980. needAlphaTesting(): boolean;
  117981. /**
  117982. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117983. */
  117984. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117985. /**
  117986. * Gets the texture used for the alpha test.
  117987. */
  117988. getAlphaTestTexture(): Nullable<BaseTexture>;
  117989. /**
  117990. * Specifies that the submesh is ready to be used.
  117991. * @param mesh - BJS mesh.
  117992. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117993. * @param useInstances - Specifies that instances should be used.
  117994. * @returns - boolean indicating that the submesh is ready or not.
  117995. */
  117996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117997. /**
  117998. * Specifies if the material uses metallic roughness workflow.
  117999. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118000. */
  118001. isMetallicWorkflow(): boolean;
  118002. private _prepareEffect;
  118003. private _prepareDefines;
  118004. /**
  118005. * Force shader compilation
  118006. */
  118007. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118008. /**
  118009. * Initializes the uniform buffer layout for the shader.
  118010. */
  118011. buildUniformLayout(): void;
  118012. /**
  118013. * Unbinds the material from the mesh
  118014. */
  118015. unbind(): void;
  118016. /**
  118017. * Binds the submesh data.
  118018. * @param world - The world matrix.
  118019. * @param mesh - The BJS mesh.
  118020. * @param subMesh - A submesh of the BJS mesh.
  118021. */
  118022. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118023. /**
  118024. * Returns the animatable textures.
  118025. * @returns - Array of animatable textures.
  118026. */
  118027. getAnimatables(): IAnimatable[];
  118028. /**
  118029. * Returns the texture used for reflections.
  118030. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118031. */
  118032. private _getReflectionTexture;
  118033. /**
  118034. * Returns an array of the actively used textures.
  118035. * @returns - Array of BaseTextures
  118036. */
  118037. getActiveTextures(): BaseTexture[];
  118038. /**
  118039. * Checks to see if a texture is used in the material.
  118040. * @param texture - Base texture to use.
  118041. * @returns - Boolean specifying if a texture is used in the material.
  118042. */
  118043. hasTexture(texture: BaseTexture): boolean;
  118044. /**
  118045. * Disposes the resources of the material.
  118046. * @param forceDisposeEffect - Forces the disposal of effects.
  118047. * @param forceDisposeTextures - Forces the disposal of all textures.
  118048. */
  118049. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118050. }
  118051. }
  118052. declare module BABYLON {
  118053. /**
  118054. * The Physically based material of BJS.
  118055. *
  118056. * This offers the main features of a standard PBR material.
  118057. * For more information, please refer to the documentation :
  118058. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118059. */
  118060. export class PBRMaterial extends PBRBaseMaterial {
  118061. /**
  118062. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118063. */
  118064. static readonly PBRMATERIAL_OPAQUE: number;
  118065. /**
  118066. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118067. */
  118068. static readonly PBRMATERIAL_ALPHATEST: number;
  118069. /**
  118070. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118071. */
  118072. static readonly PBRMATERIAL_ALPHABLEND: number;
  118073. /**
  118074. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118075. * They are also discarded below the alpha cutoff threshold to improve performances.
  118076. */
  118077. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118078. /**
  118079. * Defines the default value of how much AO map is occluding the analytical lights
  118080. * (point spot...).
  118081. */
  118082. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118083. /**
  118084. * Intensity of the direct lights e.g. the four lights available in your scene.
  118085. * This impacts both the direct diffuse and specular highlights.
  118086. */
  118087. directIntensity: number;
  118088. /**
  118089. * Intensity of the emissive part of the material.
  118090. * This helps controlling the emissive effect without modifying the emissive color.
  118091. */
  118092. emissiveIntensity: number;
  118093. /**
  118094. * Intensity of the environment e.g. how much the environment will light the object
  118095. * either through harmonics for rough material or through the refelction for shiny ones.
  118096. */
  118097. environmentIntensity: number;
  118098. /**
  118099. * This is a special control allowing the reduction of the specular highlights coming from the
  118100. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118101. */
  118102. specularIntensity: number;
  118103. /**
  118104. * Debug Control allowing disabling the bump map on this material.
  118105. */
  118106. disableBumpMap: boolean;
  118107. /**
  118108. * AKA Diffuse Texture in standard nomenclature.
  118109. */
  118110. albedoTexture: BaseTexture;
  118111. /**
  118112. * AKA Occlusion Texture in other nomenclature.
  118113. */
  118114. ambientTexture: BaseTexture;
  118115. /**
  118116. * AKA Occlusion Texture Intensity in other nomenclature.
  118117. */
  118118. ambientTextureStrength: number;
  118119. /**
  118120. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118121. * 1 means it completely occludes it
  118122. * 0 mean it has no impact
  118123. */
  118124. ambientTextureImpactOnAnalyticalLights: number;
  118125. /**
  118126. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118127. */
  118128. opacityTexture: BaseTexture;
  118129. /**
  118130. * Stores the reflection values in a texture.
  118131. */
  118132. reflectionTexture: Nullable<BaseTexture>;
  118133. /**
  118134. * Stores the emissive values in a texture.
  118135. */
  118136. emissiveTexture: BaseTexture;
  118137. /**
  118138. * AKA Specular texture in other nomenclature.
  118139. */
  118140. reflectivityTexture: BaseTexture;
  118141. /**
  118142. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118143. */
  118144. metallicTexture: BaseTexture;
  118145. /**
  118146. * Specifies the metallic scalar of the metallic/roughness workflow.
  118147. * Can also be used to scale the metalness values of the metallic texture.
  118148. */
  118149. metallic: Nullable<number>;
  118150. /**
  118151. * Specifies the roughness scalar of the metallic/roughness workflow.
  118152. * Can also be used to scale the roughness values of the metallic texture.
  118153. */
  118154. roughness: Nullable<number>;
  118155. /**
  118156. * Specifies the an F0 factor to help configuring the material F0.
  118157. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118158. * to 0.5 the previously hard coded value stays the same.
  118159. * Can also be used to scale the F0 values of the metallic texture.
  118160. */
  118161. metallicF0Factor: number;
  118162. /**
  118163. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118164. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118165. * your expectation as it multiplies with the texture data.
  118166. */
  118167. useMetallicF0FactorFromMetallicTexture: boolean;
  118168. /**
  118169. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118170. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118171. */
  118172. microSurfaceTexture: BaseTexture;
  118173. /**
  118174. * Stores surface normal data used to displace a mesh in a texture.
  118175. */
  118176. bumpTexture: BaseTexture;
  118177. /**
  118178. * Stores the pre-calculated light information of a mesh in a texture.
  118179. */
  118180. lightmapTexture: BaseTexture;
  118181. /**
  118182. * Stores the refracted light information in a texture.
  118183. */
  118184. refractionTexture: Nullable<BaseTexture>;
  118185. /**
  118186. * The color of a material in ambient lighting.
  118187. */
  118188. ambientColor: Color3;
  118189. /**
  118190. * AKA Diffuse Color in other nomenclature.
  118191. */
  118192. albedoColor: Color3;
  118193. /**
  118194. * AKA Specular Color in other nomenclature.
  118195. */
  118196. reflectivityColor: Color3;
  118197. /**
  118198. * The color reflected from the material.
  118199. */
  118200. reflectionColor: Color3;
  118201. /**
  118202. * The color emitted from the material.
  118203. */
  118204. emissiveColor: Color3;
  118205. /**
  118206. * AKA Glossiness in other nomenclature.
  118207. */
  118208. microSurface: number;
  118209. /**
  118210. * source material index of refraction (IOR)' / 'destination material IOR.
  118211. */
  118212. indexOfRefraction: number;
  118213. /**
  118214. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118215. */
  118216. invertRefractionY: boolean;
  118217. /**
  118218. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118219. * Materials half opaque for instance using refraction could benefit from this control.
  118220. */
  118221. linkRefractionWithTransparency: boolean;
  118222. /**
  118223. * If true, the light map contains occlusion information instead of lighting info.
  118224. */
  118225. useLightmapAsShadowmap: boolean;
  118226. /**
  118227. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118228. */
  118229. useAlphaFromAlbedoTexture: boolean;
  118230. /**
  118231. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118232. */
  118233. forceAlphaTest: boolean;
  118234. /**
  118235. * Defines the alpha limits in alpha test mode.
  118236. */
  118237. alphaCutOff: number;
  118238. /**
  118239. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118240. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118241. */
  118242. useSpecularOverAlpha: boolean;
  118243. /**
  118244. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118245. */
  118246. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118247. /**
  118248. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118249. */
  118250. useRoughnessFromMetallicTextureAlpha: boolean;
  118251. /**
  118252. * Specifies if the metallic texture contains the roughness information in its green channel.
  118253. */
  118254. useRoughnessFromMetallicTextureGreen: boolean;
  118255. /**
  118256. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118257. */
  118258. useMetallnessFromMetallicTextureBlue: boolean;
  118259. /**
  118260. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118261. */
  118262. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118263. /**
  118264. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118265. */
  118266. useAmbientInGrayScale: boolean;
  118267. /**
  118268. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118269. * The material will try to infer what glossiness each pixel should be.
  118270. */
  118271. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118272. /**
  118273. * BJS is using an harcoded light falloff based on a manually sets up range.
  118274. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118275. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118276. */
  118277. /**
  118278. * BJS is using an harcoded light falloff based on a manually sets up range.
  118279. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118280. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118281. */
  118282. usePhysicalLightFalloff: boolean;
  118283. /**
  118284. * In order to support the falloff compatibility with gltf, a special mode has been added
  118285. * to reproduce the gltf light falloff.
  118286. */
  118287. /**
  118288. * In order to support the falloff compatibility with gltf, a special mode has been added
  118289. * to reproduce the gltf light falloff.
  118290. */
  118291. useGLTFLightFalloff: boolean;
  118292. /**
  118293. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118294. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118295. */
  118296. useRadianceOverAlpha: boolean;
  118297. /**
  118298. * Allows using an object space normal map (instead of tangent space).
  118299. */
  118300. useObjectSpaceNormalMap: boolean;
  118301. /**
  118302. * Allows using the bump map in parallax mode.
  118303. */
  118304. useParallax: boolean;
  118305. /**
  118306. * Allows using the bump map in parallax occlusion mode.
  118307. */
  118308. useParallaxOcclusion: boolean;
  118309. /**
  118310. * Controls the scale bias of the parallax mode.
  118311. */
  118312. parallaxScaleBias: number;
  118313. /**
  118314. * If sets to true, disables all the lights affecting the material.
  118315. */
  118316. disableLighting: boolean;
  118317. /**
  118318. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118319. */
  118320. forceIrradianceInFragment: boolean;
  118321. /**
  118322. * Number of Simultaneous lights allowed on the material.
  118323. */
  118324. maxSimultaneousLights: number;
  118325. /**
  118326. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118327. */
  118328. invertNormalMapX: boolean;
  118329. /**
  118330. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118331. */
  118332. invertNormalMapY: boolean;
  118333. /**
  118334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118335. */
  118336. twoSidedLighting: boolean;
  118337. /**
  118338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118339. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118340. */
  118341. useAlphaFresnel: boolean;
  118342. /**
  118343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118344. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118345. */
  118346. useLinearAlphaFresnel: boolean;
  118347. /**
  118348. * Let user defines the brdf lookup texture used for IBL.
  118349. * A default 8bit version is embedded but you could point at :
  118350. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  118351. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118352. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  118353. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118354. */
  118355. environmentBRDFTexture: Nullable<BaseTexture>;
  118356. /**
  118357. * Force normal to face away from face.
  118358. */
  118359. forceNormalForward: boolean;
  118360. /**
  118361. * Enables specular anti aliasing in the PBR shader.
  118362. * It will both interacts on the Geometry for analytical and IBL lighting.
  118363. * It also prefilter the roughness map based on the bump values.
  118364. */
  118365. enableSpecularAntiAliasing: boolean;
  118366. /**
  118367. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118368. * makes the reflect vector face the model (under horizon).
  118369. */
  118370. useHorizonOcclusion: boolean;
  118371. /**
  118372. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118373. * too much the area relying on ambient texture to define their ambient occlusion.
  118374. */
  118375. useRadianceOcclusion: boolean;
  118376. /**
  118377. * If set to true, no lighting calculations will be applied.
  118378. */
  118379. unlit: boolean;
  118380. /**
  118381. * Gets the image processing configuration used either in this material.
  118382. */
  118383. /**
  118384. * Sets the Default image processing configuration used either in the this material.
  118385. *
  118386. * If sets to null, the scene one is in use.
  118387. */
  118388. imageProcessingConfiguration: ImageProcessingConfiguration;
  118389. /**
  118390. * Gets wether the color curves effect is enabled.
  118391. */
  118392. /**
  118393. * Sets wether the color curves effect is enabled.
  118394. */
  118395. cameraColorCurvesEnabled: boolean;
  118396. /**
  118397. * Gets wether the color grading effect is enabled.
  118398. */
  118399. /**
  118400. * Gets wether the color grading effect is enabled.
  118401. */
  118402. cameraColorGradingEnabled: boolean;
  118403. /**
  118404. * Gets wether tonemapping is enabled or not.
  118405. */
  118406. /**
  118407. * Sets wether tonemapping is enabled or not
  118408. */
  118409. cameraToneMappingEnabled: boolean;
  118410. /**
  118411. * The camera exposure used on this material.
  118412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118413. * This corresponds to a photographic exposure.
  118414. */
  118415. /**
  118416. * The camera exposure used on this material.
  118417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118418. * This corresponds to a photographic exposure.
  118419. */
  118420. cameraExposure: number;
  118421. /**
  118422. * Gets The camera contrast used on this material.
  118423. */
  118424. /**
  118425. * Sets The camera contrast used on this material.
  118426. */
  118427. cameraContrast: number;
  118428. /**
  118429. * Gets the Color Grading 2D Lookup Texture.
  118430. */
  118431. /**
  118432. * Sets the Color Grading 2D Lookup Texture.
  118433. */
  118434. cameraColorGradingTexture: Nullable<BaseTexture>;
  118435. /**
  118436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118438. * 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;
  118439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118440. */
  118441. /**
  118442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118444. * 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;
  118445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118446. */
  118447. cameraColorCurves: Nullable<ColorCurves>;
  118448. /**
  118449. * Instantiates a new PBRMaterial instance.
  118450. *
  118451. * @param name The material name
  118452. * @param scene The scene the material will be use in.
  118453. */
  118454. constructor(name: string, scene: Scene);
  118455. /**
  118456. * Returns the name of this material class.
  118457. */
  118458. getClassName(): string;
  118459. /**
  118460. * Makes a duplicate of the current material.
  118461. * @param name - name to use for the new material.
  118462. */
  118463. clone(name: string): PBRMaterial;
  118464. /**
  118465. * Serializes this PBR Material.
  118466. * @returns - An object with the serialized material.
  118467. */
  118468. serialize(): any;
  118469. /**
  118470. * Parses a PBR Material from a serialized object.
  118471. * @param source - Serialized object.
  118472. * @param scene - BJS scene instance.
  118473. * @param rootUrl - url for the scene object
  118474. * @returns - PBRMaterial
  118475. */
  118476. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  118477. }
  118478. }
  118479. declare module BABYLON {
  118480. /**
  118481. * Direct draw surface info
  118482. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  118483. */
  118484. export interface DDSInfo {
  118485. /**
  118486. * Width of the texture
  118487. */
  118488. width: number;
  118489. /**
  118490. * Width of the texture
  118491. */
  118492. height: number;
  118493. /**
  118494. * Number of Mipmaps for the texture
  118495. * @see https://en.wikipedia.org/wiki/Mipmap
  118496. */
  118497. mipmapCount: number;
  118498. /**
  118499. * If the textures format is a known fourCC format
  118500. * @see https://www.fourcc.org/
  118501. */
  118502. isFourCC: boolean;
  118503. /**
  118504. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  118505. */
  118506. isRGB: boolean;
  118507. /**
  118508. * If the texture is a lumincance format
  118509. */
  118510. isLuminance: boolean;
  118511. /**
  118512. * If this is a cube texture
  118513. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  118514. */
  118515. isCube: boolean;
  118516. /**
  118517. * If the texture is a compressed format eg. FOURCC_DXT1
  118518. */
  118519. isCompressed: boolean;
  118520. /**
  118521. * The dxgiFormat of the texture
  118522. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  118523. */
  118524. dxgiFormat: number;
  118525. /**
  118526. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  118527. */
  118528. textureType: number;
  118529. /**
  118530. * Sphericle polynomial created for the dds texture
  118531. */
  118532. sphericalPolynomial?: SphericalPolynomial;
  118533. }
  118534. /**
  118535. * Class used to provide DDS decompression tools
  118536. */
  118537. export class DDSTools {
  118538. /**
  118539. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  118540. */
  118541. static StoreLODInAlphaChannel: boolean;
  118542. /**
  118543. * Gets DDS information from an array buffer
  118544. * @param arrayBuffer defines the array buffer to read data from
  118545. * @returns the DDS information
  118546. */
  118547. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  118548. private static _FloatView;
  118549. private static _Int32View;
  118550. private static _ToHalfFloat;
  118551. private static _FromHalfFloat;
  118552. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  118553. private static _GetHalfFloatRGBAArrayBuffer;
  118554. private static _GetFloatRGBAArrayBuffer;
  118555. private static _GetFloatAsUIntRGBAArrayBuffer;
  118556. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  118557. private static _GetRGBAArrayBuffer;
  118558. private static _ExtractLongWordOrder;
  118559. private static _GetRGBArrayBuffer;
  118560. private static _GetLuminanceArrayBuffer;
  118561. /**
  118562. * Uploads DDS Levels to a Babylon Texture
  118563. * @hidden
  118564. */
  118565. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  118566. }
  118567. interface ThinEngine {
  118568. /**
  118569. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  118570. * @param rootUrl defines the url where the file to load is located
  118571. * @param scene defines the current scene
  118572. * @param lodScale defines scale to apply to the mip map selection
  118573. * @param lodOffset defines offset to apply to the mip map selection
  118574. * @param onLoad defines an optional callback raised when the texture is loaded
  118575. * @param onError defines an optional callback raised if there is an issue to load the texture
  118576. * @param format defines the format of the data
  118577. * @param forcedExtension defines the extension to use to pick the right loader
  118578. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  118579. * @returns the cube texture as an InternalTexture
  118580. */
  118581. 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;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * Implementation of the DDS Texture Loader.
  118587. * @hidden
  118588. */
  118589. export class _DDSTextureLoader implements IInternalTextureLoader {
  118590. /**
  118591. * Defines wether the loader supports cascade loading the different faces.
  118592. */
  118593. readonly supportCascades: boolean;
  118594. /**
  118595. * This returns if the loader support the current file information.
  118596. * @param extension defines the file extension of the file being loaded
  118597. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118598. * @param fallback defines the fallback internal texture if any
  118599. * @param isBase64 defines whether the texture is encoded as a base64
  118600. * @param isBuffer defines whether the texture data are stored as a buffer
  118601. * @returns true if the loader can load the specified file
  118602. */
  118603. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118604. /**
  118605. * Transform the url before loading if required.
  118606. * @param rootUrl the url of the texture
  118607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118608. * @returns the transformed texture
  118609. */
  118610. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118611. /**
  118612. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118613. * @param rootUrl the url of the texture
  118614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118615. * @returns the fallback texture
  118616. */
  118617. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118618. /**
  118619. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118620. * @param data contains the texture data
  118621. * @param texture defines the BabylonJS internal texture
  118622. * @param createPolynomials will be true if polynomials have been requested
  118623. * @param onLoad defines the callback to trigger once the texture is ready
  118624. * @param onError defines the callback to trigger in case of error
  118625. */
  118626. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118627. /**
  118628. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118629. * @param data contains the texture data
  118630. * @param texture defines the BabylonJS internal texture
  118631. * @param callback defines the method to call once ready to upload
  118632. */
  118633. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118634. }
  118635. }
  118636. declare module BABYLON {
  118637. /**
  118638. * Implementation of the ENV Texture Loader.
  118639. * @hidden
  118640. */
  118641. export class _ENVTextureLoader implements IInternalTextureLoader {
  118642. /**
  118643. * Defines wether the loader supports cascade loading the different faces.
  118644. */
  118645. readonly supportCascades: boolean;
  118646. /**
  118647. * This returns if the loader support the current file information.
  118648. * @param extension defines the file extension of the file being loaded
  118649. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118650. * @param fallback defines the fallback internal texture if any
  118651. * @param isBase64 defines whether the texture is encoded as a base64
  118652. * @param isBuffer defines whether the texture data are stored as a buffer
  118653. * @returns true if the loader can load the specified file
  118654. */
  118655. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118656. /**
  118657. * Transform the url before loading if required.
  118658. * @param rootUrl the url of the texture
  118659. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118660. * @returns the transformed texture
  118661. */
  118662. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118663. /**
  118664. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118665. * @param rootUrl the url of the texture
  118666. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118667. * @returns the fallback texture
  118668. */
  118669. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118670. /**
  118671. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118672. * @param data contains the texture data
  118673. * @param texture defines the BabylonJS internal texture
  118674. * @param createPolynomials will be true if polynomials have been requested
  118675. * @param onLoad defines the callback to trigger once the texture is ready
  118676. * @param onError defines the callback to trigger in case of error
  118677. */
  118678. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118679. /**
  118680. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118681. * @param data contains the texture data
  118682. * @param texture defines the BabylonJS internal texture
  118683. * @param callback defines the method to call once ready to upload
  118684. */
  118685. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118686. }
  118687. }
  118688. declare module BABYLON {
  118689. /**
  118690. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  118691. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  118692. */
  118693. export class KhronosTextureContainer {
  118694. /** contents of the KTX container file */
  118695. arrayBuffer: any;
  118696. private static HEADER_LEN;
  118697. private static COMPRESSED_2D;
  118698. private static COMPRESSED_3D;
  118699. private static TEX_2D;
  118700. private static TEX_3D;
  118701. /**
  118702. * Gets the openGL type
  118703. */
  118704. glType: number;
  118705. /**
  118706. * Gets the openGL type size
  118707. */
  118708. glTypeSize: number;
  118709. /**
  118710. * Gets the openGL format
  118711. */
  118712. glFormat: number;
  118713. /**
  118714. * Gets the openGL internal format
  118715. */
  118716. glInternalFormat: number;
  118717. /**
  118718. * Gets the base internal format
  118719. */
  118720. glBaseInternalFormat: number;
  118721. /**
  118722. * Gets image width in pixel
  118723. */
  118724. pixelWidth: number;
  118725. /**
  118726. * Gets image height in pixel
  118727. */
  118728. pixelHeight: number;
  118729. /**
  118730. * Gets image depth in pixels
  118731. */
  118732. pixelDepth: number;
  118733. /**
  118734. * Gets the number of array elements
  118735. */
  118736. numberOfArrayElements: number;
  118737. /**
  118738. * Gets the number of faces
  118739. */
  118740. numberOfFaces: number;
  118741. /**
  118742. * Gets the number of mipmap levels
  118743. */
  118744. numberOfMipmapLevels: number;
  118745. /**
  118746. * Gets the bytes of key value data
  118747. */
  118748. bytesOfKeyValueData: number;
  118749. /**
  118750. * Gets the load type
  118751. */
  118752. loadType: number;
  118753. /**
  118754. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  118755. */
  118756. isInvalid: boolean;
  118757. /**
  118758. * Creates a new KhronosTextureContainer
  118759. * @param arrayBuffer contents of the KTX container file
  118760. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  118761. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  118762. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  118763. */
  118764. constructor(
  118765. /** contents of the KTX container file */
  118766. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  118767. /**
  118768. * Uploads KTX content to a Babylon Texture.
  118769. * It is assumed that the texture has already been created & is currently bound
  118770. * @hidden
  118771. */
  118772. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  118773. private _upload2DCompressedLevels;
  118774. }
  118775. }
  118776. declare module BABYLON {
  118777. /**
  118778. * Implementation of the KTX Texture Loader.
  118779. * @hidden
  118780. */
  118781. export class _KTXTextureLoader implements IInternalTextureLoader {
  118782. /**
  118783. * Defines wether the loader supports cascade loading the different faces.
  118784. */
  118785. readonly supportCascades: boolean;
  118786. /**
  118787. * This returns if the loader support the current file information.
  118788. * @param extension defines the file extension of the file being loaded
  118789. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118790. * @param fallback defines the fallback internal texture if any
  118791. * @param isBase64 defines whether the texture is encoded as a base64
  118792. * @param isBuffer defines whether the texture data are stored as a buffer
  118793. * @returns true if the loader can load the specified file
  118794. */
  118795. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118796. /**
  118797. * Transform the url before loading if required.
  118798. * @param rootUrl the url of the texture
  118799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118800. * @returns the transformed texture
  118801. */
  118802. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118803. /**
  118804. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118805. * @param rootUrl the url of the texture
  118806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118807. * @returns the fallback texture
  118808. */
  118809. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118810. /**
  118811. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118812. * @param data contains the texture data
  118813. * @param texture defines the BabylonJS internal texture
  118814. * @param createPolynomials will be true if polynomials have been requested
  118815. * @param onLoad defines the callback to trigger once the texture is ready
  118816. * @param onError defines the callback to trigger in case of error
  118817. */
  118818. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118819. /**
  118820. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118821. * @param data contains the texture data
  118822. * @param texture defines the BabylonJS internal texture
  118823. * @param callback defines the method to call once ready to upload
  118824. */
  118825. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118826. }
  118827. }
  118828. declare module BABYLON {
  118829. /** @hidden */
  118830. export var _forceSceneHelpersToBundle: boolean;
  118831. interface Scene {
  118832. /**
  118833. * Creates a default light for the scene.
  118834. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118835. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118836. */
  118837. createDefaultLight(replace?: boolean): void;
  118838. /**
  118839. * Creates a default camera for the scene.
  118840. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118841. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118842. * @param replace has default false, when true replaces the active camera in the scene
  118843. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118844. */
  118845. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118846. /**
  118847. * Creates a default camera and a default light.
  118848. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118849. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118850. * @param replace has the default false, when true replaces the active camera/light in the scene
  118851. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118852. */
  118853. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118854. /**
  118855. * Creates a new sky box
  118856. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118857. * @param environmentTexture defines the texture to use as environment texture
  118858. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118859. * @param scale defines the overall scale of the skybox
  118860. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118861. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118862. * @returns a new mesh holding the sky box
  118863. */
  118864. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118865. /**
  118866. * Creates a new environment
  118867. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118868. * @param options defines the options you can use to configure the environment
  118869. * @returns the new EnvironmentHelper
  118870. */
  118871. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118872. /**
  118873. * Creates a new VREXperienceHelper
  118874. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118875. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118876. * @returns a new VREXperienceHelper
  118877. */
  118878. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118879. /**
  118880. * Creates a new WebXRDefaultExperience
  118881. * @see http://doc.babylonjs.com/how_to/webxr
  118882. * @param options experience options
  118883. * @returns a promise for a new WebXRDefaultExperience
  118884. */
  118885. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118886. }
  118887. }
  118888. declare module BABYLON {
  118889. /**
  118890. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118891. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118892. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118893. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118894. */
  118895. export class VideoDome extends TransformNode {
  118896. /**
  118897. * Define the video source as a Monoscopic panoramic 360 video.
  118898. */
  118899. static readonly MODE_MONOSCOPIC: number;
  118900. /**
  118901. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118902. */
  118903. static readonly MODE_TOPBOTTOM: number;
  118904. /**
  118905. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118906. */
  118907. static readonly MODE_SIDEBYSIDE: number;
  118908. private _halfDome;
  118909. private _useDirectMapping;
  118910. /**
  118911. * The video texture being displayed on the sphere
  118912. */
  118913. protected _videoTexture: VideoTexture;
  118914. /**
  118915. * Gets the video texture being displayed on the sphere
  118916. */
  118917. readonly videoTexture: VideoTexture;
  118918. /**
  118919. * The skybox material
  118920. */
  118921. protected _material: BackgroundMaterial;
  118922. /**
  118923. * The surface used for the skybox
  118924. */
  118925. protected _mesh: Mesh;
  118926. /**
  118927. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118928. */
  118929. private _halfDomeMask;
  118930. /**
  118931. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118932. * Also see the options.resolution property.
  118933. */
  118934. fovMultiplier: number;
  118935. private _videoMode;
  118936. /**
  118937. * Gets or set the current video mode for the video. It can be:
  118938. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118939. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118940. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118941. */
  118942. videoMode: number;
  118943. /**
  118944. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118945. *
  118946. */
  118947. /**
  118948. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118949. */
  118950. halfDome: boolean;
  118951. /**
  118952. * Oberserver used in Stereoscopic VR Mode.
  118953. */
  118954. private _onBeforeCameraRenderObserver;
  118955. /**
  118956. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118957. * @param name Element's name, child elements will append suffixes for their own names.
  118958. * @param urlsOrVideo defines the url(s) or the video element to use
  118959. * @param options An object containing optional or exposed sub element properties
  118960. */
  118961. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118962. resolution?: number;
  118963. clickToPlay?: boolean;
  118964. autoPlay?: boolean;
  118965. loop?: boolean;
  118966. size?: number;
  118967. poster?: string;
  118968. faceForward?: boolean;
  118969. useDirectMapping?: boolean;
  118970. halfDomeMode?: boolean;
  118971. }, scene: Scene);
  118972. private _changeVideoMode;
  118973. /**
  118974. * Releases resources associated with this node.
  118975. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118976. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118977. */
  118978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118979. }
  118980. }
  118981. declare module BABYLON {
  118982. /**
  118983. * This class can be used to get instrumentation data from a Babylon engine
  118984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118985. */
  118986. export class EngineInstrumentation implements IDisposable {
  118987. /**
  118988. * Define the instrumented engine.
  118989. */
  118990. engine: Engine;
  118991. private _captureGPUFrameTime;
  118992. private _gpuFrameTimeToken;
  118993. private _gpuFrameTime;
  118994. private _captureShaderCompilationTime;
  118995. private _shaderCompilationTime;
  118996. private _onBeginFrameObserver;
  118997. private _onEndFrameObserver;
  118998. private _onBeforeShaderCompilationObserver;
  118999. private _onAfterShaderCompilationObserver;
  119000. /**
  119001. * Gets the perf counter used for GPU frame time
  119002. */
  119003. readonly gpuFrameTimeCounter: PerfCounter;
  119004. /**
  119005. * Gets the GPU frame time capture status
  119006. */
  119007. /**
  119008. * Enable or disable the GPU frame time capture
  119009. */
  119010. captureGPUFrameTime: boolean;
  119011. /**
  119012. * Gets the perf counter used for shader compilation time
  119013. */
  119014. readonly shaderCompilationTimeCounter: PerfCounter;
  119015. /**
  119016. * Gets the shader compilation time capture status
  119017. */
  119018. /**
  119019. * Enable or disable the shader compilation time capture
  119020. */
  119021. captureShaderCompilationTime: boolean;
  119022. /**
  119023. * Instantiates a new engine instrumentation.
  119024. * This class can be used to get instrumentation data from a Babylon engine
  119025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119026. * @param engine Defines the engine to instrument
  119027. */
  119028. constructor(
  119029. /**
  119030. * Define the instrumented engine.
  119031. */
  119032. engine: Engine);
  119033. /**
  119034. * Dispose and release associated resources.
  119035. */
  119036. dispose(): void;
  119037. }
  119038. }
  119039. declare module BABYLON {
  119040. /**
  119041. * This class can be used to get instrumentation data from a Babylon engine
  119042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119043. */
  119044. export class SceneInstrumentation implements IDisposable {
  119045. /**
  119046. * Defines the scene to instrument
  119047. */
  119048. scene: Scene;
  119049. private _captureActiveMeshesEvaluationTime;
  119050. private _activeMeshesEvaluationTime;
  119051. private _captureRenderTargetsRenderTime;
  119052. private _renderTargetsRenderTime;
  119053. private _captureFrameTime;
  119054. private _frameTime;
  119055. private _captureRenderTime;
  119056. private _renderTime;
  119057. private _captureInterFrameTime;
  119058. private _interFrameTime;
  119059. private _captureParticlesRenderTime;
  119060. private _particlesRenderTime;
  119061. private _captureSpritesRenderTime;
  119062. private _spritesRenderTime;
  119063. private _capturePhysicsTime;
  119064. private _physicsTime;
  119065. private _captureAnimationsTime;
  119066. private _animationsTime;
  119067. private _captureCameraRenderTime;
  119068. private _cameraRenderTime;
  119069. private _onBeforeActiveMeshesEvaluationObserver;
  119070. private _onAfterActiveMeshesEvaluationObserver;
  119071. private _onBeforeRenderTargetsRenderObserver;
  119072. private _onAfterRenderTargetsRenderObserver;
  119073. private _onAfterRenderObserver;
  119074. private _onBeforeDrawPhaseObserver;
  119075. private _onAfterDrawPhaseObserver;
  119076. private _onBeforeAnimationsObserver;
  119077. private _onBeforeParticlesRenderingObserver;
  119078. private _onAfterParticlesRenderingObserver;
  119079. private _onBeforeSpritesRenderingObserver;
  119080. private _onAfterSpritesRenderingObserver;
  119081. private _onBeforePhysicsObserver;
  119082. private _onAfterPhysicsObserver;
  119083. private _onAfterAnimationsObserver;
  119084. private _onBeforeCameraRenderObserver;
  119085. private _onAfterCameraRenderObserver;
  119086. /**
  119087. * Gets the perf counter used for active meshes evaluation time
  119088. */
  119089. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119090. /**
  119091. * Gets the active meshes evaluation time capture status
  119092. */
  119093. /**
  119094. * Enable or disable the active meshes evaluation time capture
  119095. */
  119096. captureActiveMeshesEvaluationTime: boolean;
  119097. /**
  119098. * Gets the perf counter used for render targets render time
  119099. */
  119100. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119101. /**
  119102. * Gets the render targets render time capture status
  119103. */
  119104. /**
  119105. * Enable or disable the render targets render time capture
  119106. */
  119107. captureRenderTargetsRenderTime: boolean;
  119108. /**
  119109. * Gets the perf counter used for particles render time
  119110. */
  119111. readonly particlesRenderTimeCounter: PerfCounter;
  119112. /**
  119113. * Gets the particles render time capture status
  119114. */
  119115. /**
  119116. * Enable or disable the particles render time capture
  119117. */
  119118. captureParticlesRenderTime: boolean;
  119119. /**
  119120. * Gets the perf counter used for sprites render time
  119121. */
  119122. readonly spritesRenderTimeCounter: PerfCounter;
  119123. /**
  119124. * Gets the sprites render time capture status
  119125. */
  119126. /**
  119127. * Enable or disable the sprites render time capture
  119128. */
  119129. captureSpritesRenderTime: boolean;
  119130. /**
  119131. * Gets the perf counter used for physics time
  119132. */
  119133. readonly physicsTimeCounter: PerfCounter;
  119134. /**
  119135. * Gets the physics time capture status
  119136. */
  119137. /**
  119138. * Enable or disable the physics time capture
  119139. */
  119140. capturePhysicsTime: boolean;
  119141. /**
  119142. * Gets the perf counter used for animations time
  119143. */
  119144. readonly animationsTimeCounter: PerfCounter;
  119145. /**
  119146. * Gets the animations time capture status
  119147. */
  119148. /**
  119149. * Enable or disable the animations time capture
  119150. */
  119151. captureAnimationsTime: boolean;
  119152. /**
  119153. * Gets the perf counter used for frame time capture
  119154. */
  119155. readonly frameTimeCounter: PerfCounter;
  119156. /**
  119157. * Gets the frame time capture status
  119158. */
  119159. /**
  119160. * Enable or disable the frame time capture
  119161. */
  119162. captureFrameTime: boolean;
  119163. /**
  119164. * Gets the perf counter used for inter-frames time capture
  119165. */
  119166. readonly interFrameTimeCounter: PerfCounter;
  119167. /**
  119168. * Gets the inter-frames time capture status
  119169. */
  119170. /**
  119171. * Enable or disable the inter-frames time capture
  119172. */
  119173. captureInterFrameTime: boolean;
  119174. /**
  119175. * Gets the perf counter used for render time capture
  119176. */
  119177. readonly renderTimeCounter: PerfCounter;
  119178. /**
  119179. * Gets the render time capture status
  119180. */
  119181. /**
  119182. * Enable or disable the render time capture
  119183. */
  119184. captureRenderTime: boolean;
  119185. /**
  119186. * Gets the perf counter used for camera render time capture
  119187. */
  119188. readonly cameraRenderTimeCounter: PerfCounter;
  119189. /**
  119190. * Gets the camera render time capture status
  119191. */
  119192. /**
  119193. * Enable or disable the camera render time capture
  119194. */
  119195. captureCameraRenderTime: boolean;
  119196. /**
  119197. * Gets the perf counter used for draw calls
  119198. */
  119199. readonly drawCallsCounter: PerfCounter;
  119200. /**
  119201. * Instantiates a new scene instrumentation.
  119202. * This class can be used to get instrumentation data from a Babylon engine
  119203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119204. * @param scene Defines the scene to instrument
  119205. */
  119206. constructor(
  119207. /**
  119208. * Defines the scene to instrument
  119209. */
  119210. scene: Scene);
  119211. /**
  119212. * Dispose and release associated resources.
  119213. */
  119214. dispose(): void;
  119215. }
  119216. }
  119217. declare module BABYLON {
  119218. /** @hidden */
  119219. export var glowMapGenerationPixelShader: {
  119220. name: string;
  119221. shader: string;
  119222. };
  119223. }
  119224. declare module BABYLON {
  119225. /** @hidden */
  119226. export var glowMapGenerationVertexShader: {
  119227. name: string;
  119228. shader: string;
  119229. };
  119230. }
  119231. declare module BABYLON {
  119232. /**
  119233. * Effect layer options. This helps customizing the behaviour
  119234. * of the effect layer.
  119235. */
  119236. export interface IEffectLayerOptions {
  119237. /**
  119238. * Multiplication factor apply to the canvas size to compute the render target size
  119239. * used to generated the objects (the smaller the faster).
  119240. */
  119241. mainTextureRatio: number;
  119242. /**
  119243. * Enforces a fixed size texture to ensure effect stability across devices.
  119244. */
  119245. mainTextureFixedSize?: number;
  119246. /**
  119247. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119248. */
  119249. alphaBlendingMode: number;
  119250. /**
  119251. * The camera attached to the layer.
  119252. */
  119253. camera: Nullable<Camera>;
  119254. /**
  119255. * The rendering group to draw the layer in.
  119256. */
  119257. renderingGroupId: number;
  119258. }
  119259. /**
  119260. * The effect layer Helps adding post process effect blended with the main pass.
  119261. *
  119262. * This can be for instance use to generate glow or higlight effects on the scene.
  119263. *
  119264. * The effect layer class can not be used directly and is intented to inherited from to be
  119265. * customized per effects.
  119266. */
  119267. export abstract class EffectLayer {
  119268. private _vertexBuffers;
  119269. private _indexBuffer;
  119270. private _cachedDefines;
  119271. private _effectLayerMapGenerationEffect;
  119272. private _effectLayerOptions;
  119273. private _mergeEffect;
  119274. protected _scene: Scene;
  119275. protected _engine: Engine;
  119276. protected _maxSize: number;
  119277. protected _mainTextureDesiredSize: ISize;
  119278. protected _mainTexture: RenderTargetTexture;
  119279. protected _shouldRender: boolean;
  119280. protected _postProcesses: PostProcess[];
  119281. protected _textures: BaseTexture[];
  119282. protected _emissiveTextureAndColor: {
  119283. texture: Nullable<BaseTexture>;
  119284. color: Color4;
  119285. };
  119286. /**
  119287. * The name of the layer
  119288. */
  119289. name: string;
  119290. /**
  119291. * The clear color of the texture used to generate the glow map.
  119292. */
  119293. neutralColor: Color4;
  119294. /**
  119295. * Specifies wether the highlight layer is enabled or not.
  119296. */
  119297. isEnabled: boolean;
  119298. /**
  119299. * Gets the camera attached to the layer.
  119300. */
  119301. readonly camera: Nullable<Camera>;
  119302. /**
  119303. * Gets the rendering group id the layer should render in.
  119304. */
  119305. renderingGroupId: number;
  119306. /**
  119307. * An event triggered when the effect layer has been disposed.
  119308. */
  119309. onDisposeObservable: Observable<EffectLayer>;
  119310. /**
  119311. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119312. */
  119313. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119314. /**
  119315. * An event triggered when the generated texture is being merged in the scene.
  119316. */
  119317. onBeforeComposeObservable: Observable<EffectLayer>;
  119318. /**
  119319. * An event triggered when the mesh is rendered into the effect render target.
  119320. */
  119321. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119322. /**
  119323. * An event triggered after the mesh has been rendered into the effect render target.
  119324. */
  119325. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119326. /**
  119327. * An event triggered when the generated texture has been merged in the scene.
  119328. */
  119329. onAfterComposeObservable: Observable<EffectLayer>;
  119330. /**
  119331. * An event triggered when the efffect layer changes its size.
  119332. */
  119333. onSizeChangedObservable: Observable<EffectLayer>;
  119334. /** @hidden */
  119335. static _SceneComponentInitialization: (scene: Scene) => void;
  119336. /**
  119337. * Instantiates a new effect Layer and references it in the scene.
  119338. * @param name The name of the layer
  119339. * @param scene The scene to use the layer in
  119340. */
  119341. constructor(
  119342. /** The Friendly of the effect in the scene */
  119343. name: string, scene: Scene);
  119344. /**
  119345. * Get the effect name of the layer.
  119346. * @return The effect name
  119347. */
  119348. abstract getEffectName(): string;
  119349. /**
  119350. * Checks for the readiness of the element composing the layer.
  119351. * @param subMesh the mesh to check for
  119352. * @param useInstances specify wether or not to use instances to render the mesh
  119353. * @return true if ready otherwise, false
  119354. */
  119355. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119356. /**
  119357. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119358. * @returns true if the effect requires stencil during the main canvas render pass.
  119359. */
  119360. abstract needStencil(): boolean;
  119361. /**
  119362. * Create the merge effect. This is the shader use to blit the information back
  119363. * to the main canvas at the end of the scene rendering.
  119364. * @returns The effect containing the shader used to merge the effect on the main canvas
  119365. */
  119366. protected abstract _createMergeEffect(): Effect;
  119367. /**
  119368. * Creates the render target textures and post processes used in the effect layer.
  119369. */
  119370. protected abstract _createTextureAndPostProcesses(): void;
  119371. /**
  119372. * Implementation specific of rendering the generating effect on the main canvas.
  119373. * @param effect The effect used to render through
  119374. */
  119375. protected abstract _internalRender(effect: Effect): void;
  119376. /**
  119377. * Sets the required values for both the emissive texture and and the main color.
  119378. */
  119379. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119380. /**
  119381. * Free any resources and references associated to a mesh.
  119382. * Internal use
  119383. * @param mesh The mesh to free.
  119384. */
  119385. abstract _disposeMesh(mesh: Mesh): void;
  119386. /**
  119387. * Serializes this layer (Glow or Highlight for example)
  119388. * @returns a serialized layer object
  119389. */
  119390. abstract serialize?(): any;
  119391. /**
  119392. * Initializes the effect layer with the required options.
  119393. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  119394. */
  119395. protected _init(options: Partial<IEffectLayerOptions>): void;
  119396. /**
  119397. * Generates the index buffer of the full screen quad blending to the main canvas.
  119398. */
  119399. private _generateIndexBuffer;
  119400. /**
  119401. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  119402. */
  119403. private _generateVertexBuffer;
  119404. /**
  119405. * Sets the main texture desired size which is the closest power of two
  119406. * of the engine canvas size.
  119407. */
  119408. private _setMainTextureSize;
  119409. /**
  119410. * Creates the main texture for the effect layer.
  119411. */
  119412. protected _createMainTexture(): void;
  119413. /**
  119414. * Adds specific effects defines.
  119415. * @param defines The defines to add specifics to.
  119416. */
  119417. protected _addCustomEffectDefines(defines: string[]): void;
  119418. /**
  119419. * Checks for the readiness of the element composing the layer.
  119420. * @param subMesh the mesh to check for
  119421. * @param useInstances specify wether or not to use instances to render the mesh
  119422. * @param emissiveTexture the associated emissive texture used to generate the glow
  119423. * @return true if ready otherwise, false
  119424. */
  119425. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  119426. /**
  119427. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  119428. */
  119429. render(): void;
  119430. /**
  119431. * Determine if a given mesh will be used in the current effect.
  119432. * @param mesh mesh to test
  119433. * @returns true if the mesh will be used
  119434. */
  119435. hasMesh(mesh: AbstractMesh): boolean;
  119436. /**
  119437. * Returns true if the layer contains information to display, otherwise false.
  119438. * @returns true if the glow layer should be rendered
  119439. */
  119440. shouldRender(): boolean;
  119441. /**
  119442. * Returns true if the mesh should render, otherwise false.
  119443. * @param mesh The mesh to render
  119444. * @returns true if it should render otherwise false
  119445. */
  119446. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  119447. /**
  119448. * Returns true if the mesh can be rendered, otherwise false.
  119449. * @param mesh The mesh to render
  119450. * @param material The material used on the mesh
  119451. * @returns true if it can be rendered otherwise false
  119452. */
  119453. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119454. /**
  119455. * Returns true if the mesh should render, otherwise false.
  119456. * @param mesh The mesh to render
  119457. * @returns true if it should render otherwise false
  119458. */
  119459. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  119460. /**
  119461. * Renders the submesh passed in parameter to the generation map.
  119462. */
  119463. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  119464. /**
  119465. * Defines wether the current material of the mesh should be use to render the effect.
  119466. * @param mesh defines the current mesh to render
  119467. */
  119468. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119469. /**
  119470. * Rebuild the required buffers.
  119471. * @hidden Internal use only.
  119472. */
  119473. _rebuild(): void;
  119474. /**
  119475. * Dispose only the render target textures and post process.
  119476. */
  119477. private _disposeTextureAndPostProcesses;
  119478. /**
  119479. * Dispose the highlight layer and free resources.
  119480. */
  119481. dispose(): void;
  119482. /**
  119483. * Gets the class name of the effect layer
  119484. * @returns the string with the class name of the effect layer
  119485. */
  119486. getClassName(): string;
  119487. /**
  119488. * Creates an effect layer from parsed effect layer data
  119489. * @param parsedEffectLayer defines effect layer data
  119490. * @param scene defines the current scene
  119491. * @param rootUrl defines the root URL containing the effect layer information
  119492. * @returns a parsed effect Layer
  119493. */
  119494. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  119495. }
  119496. }
  119497. declare module BABYLON {
  119498. interface AbstractScene {
  119499. /**
  119500. * The list of effect layers (highlights/glow) added to the scene
  119501. * @see http://doc.babylonjs.com/how_to/highlight_layer
  119502. * @see http://doc.babylonjs.com/how_to/glow_layer
  119503. */
  119504. effectLayers: Array<EffectLayer>;
  119505. /**
  119506. * Removes the given effect layer from this scene.
  119507. * @param toRemove defines the effect layer to remove
  119508. * @returns the index of the removed effect layer
  119509. */
  119510. removeEffectLayer(toRemove: EffectLayer): number;
  119511. /**
  119512. * Adds the given effect layer to this scene
  119513. * @param newEffectLayer defines the effect layer to add
  119514. */
  119515. addEffectLayer(newEffectLayer: EffectLayer): void;
  119516. }
  119517. /**
  119518. * Defines the layer scene component responsible to manage any effect layers
  119519. * in a given scene.
  119520. */
  119521. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  119522. /**
  119523. * The component name helpfull to identify the component in the list of scene components.
  119524. */
  119525. readonly name: string;
  119526. /**
  119527. * The scene the component belongs to.
  119528. */
  119529. scene: Scene;
  119530. private _engine;
  119531. private _renderEffects;
  119532. private _needStencil;
  119533. private _previousStencilState;
  119534. /**
  119535. * Creates a new instance of the component for the given scene
  119536. * @param scene Defines the scene to register the component in
  119537. */
  119538. constructor(scene: Scene);
  119539. /**
  119540. * Registers the component in a given scene
  119541. */
  119542. register(): void;
  119543. /**
  119544. * Rebuilds the elements related to this component in case of
  119545. * context lost for instance.
  119546. */
  119547. rebuild(): void;
  119548. /**
  119549. * Serializes the component data to the specified json object
  119550. * @param serializationObject The object to serialize to
  119551. */
  119552. serialize(serializationObject: any): void;
  119553. /**
  119554. * Adds all the elements from the container to the scene
  119555. * @param container the container holding the elements
  119556. */
  119557. addFromContainer(container: AbstractScene): void;
  119558. /**
  119559. * Removes all the elements in the container from the scene
  119560. * @param container contains the elements to remove
  119561. * @param dispose if the removed element should be disposed (default: false)
  119562. */
  119563. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119564. /**
  119565. * Disposes the component and the associated ressources.
  119566. */
  119567. dispose(): void;
  119568. private _isReadyForMesh;
  119569. private _renderMainTexture;
  119570. private _setStencil;
  119571. private _setStencilBack;
  119572. private _draw;
  119573. private _drawCamera;
  119574. private _drawRenderingGroup;
  119575. }
  119576. }
  119577. declare module BABYLON {
  119578. /** @hidden */
  119579. export var glowMapMergePixelShader: {
  119580. name: string;
  119581. shader: string;
  119582. };
  119583. }
  119584. declare module BABYLON {
  119585. /** @hidden */
  119586. export var glowMapMergeVertexShader: {
  119587. name: string;
  119588. shader: string;
  119589. };
  119590. }
  119591. declare module BABYLON {
  119592. interface AbstractScene {
  119593. /**
  119594. * Return a the first highlight layer of the scene with a given name.
  119595. * @param name The name of the highlight layer to look for.
  119596. * @return The highlight layer if found otherwise null.
  119597. */
  119598. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  119599. }
  119600. /**
  119601. * Glow layer options. This helps customizing the behaviour
  119602. * of the glow layer.
  119603. */
  119604. export interface IGlowLayerOptions {
  119605. /**
  119606. * Multiplication factor apply to the canvas size to compute the render target size
  119607. * used to generated the glowing objects (the smaller the faster).
  119608. */
  119609. mainTextureRatio: number;
  119610. /**
  119611. * Enforces a fixed size texture to ensure resize independant blur.
  119612. */
  119613. mainTextureFixedSize?: number;
  119614. /**
  119615. * How big is the kernel of the blur texture.
  119616. */
  119617. blurKernelSize: number;
  119618. /**
  119619. * The camera attached to the layer.
  119620. */
  119621. camera: Nullable<Camera>;
  119622. /**
  119623. * Enable MSAA by chosing the number of samples.
  119624. */
  119625. mainTextureSamples?: number;
  119626. /**
  119627. * The rendering group to draw the layer in.
  119628. */
  119629. renderingGroupId: number;
  119630. }
  119631. /**
  119632. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  119633. *
  119634. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  119635. *
  119636. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  119637. */
  119638. export class GlowLayer extends EffectLayer {
  119639. /**
  119640. * Effect Name of the layer.
  119641. */
  119642. static readonly EffectName: string;
  119643. /**
  119644. * The default blur kernel size used for the glow.
  119645. */
  119646. static DefaultBlurKernelSize: number;
  119647. /**
  119648. * The default texture size ratio used for the glow.
  119649. */
  119650. static DefaultTextureRatio: number;
  119651. /**
  119652. * Sets the kernel size of the blur.
  119653. */
  119654. /**
  119655. * Gets the kernel size of the blur.
  119656. */
  119657. blurKernelSize: number;
  119658. /**
  119659. * Sets the glow intensity.
  119660. */
  119661. /**
  119662. * Gets the glow intensity.
  119663. */
  119664. intensity: number;
  119665. private _options;
  119666. private _intensity;
  119667. private _horizontalBlurPostprocess1;
  119668. private _verticalBlurPostprocess1;
  119669. private _horizontalBlurPostprocess2;
  119670. private _verticalBlurPostprocess2;
  119671. private _blurTexture1;
  119672. private _blurTexture2;
  119673. private _postProcesses1;
  119674. private _postProcesses2;
  119675. private _includedOnlyMeshes;
  119676. private _excludedMeshes;
  119677. private _meshesUsingTheirOwnMaterials;
  119678. /**
  119679. * Callback used to let the user override the color selection on a per mesh basis
  119680. */
  119681. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  119682. /**
  119683. * Callback used to let the user override the texture selection on a per mesh basis
  119684. */
  119685. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  119686. /**
  119687. * Instantiates a new glow Layer and references it to the scene.
  119688. * @param name The name of the layer
  119689. * @param scene The scene to use the layer in
  119690. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  119691. */
  119692. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  119693. /**
  119694. * Get the effect name of the layer.
  119695. * @return The effect name
  119696. */
  119697. getEffectName(): string;
  119698. /**
  119699. * Create the merge effect. This is the shader use to blit the information back
  119700. * to the main canvas at the end of the scene rendering.
  119701. */
  119702. protected _createMergeEffect(): Effect;
  119703. /**
  119704. * Creates the render target textures and post processes used in the glow layer.
  119705. */
  119706. protected _createTextureAndPostProcesses(): void;
  119707. /**
  119708. * Checks for the readiness of the element composing the layer.
  119709. * @param subMesh the mesh to check for
  119710. * @param useInstances specify wether or not to use instances to render the mesh
  119711. * @param emissiveTexture the associated emissive texture used to generate the glow
  119712. * @return true if ready otherwise, false
  119713. */
  119714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119715. /**
  119716. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119717. */
  119718. needStencil(): boolean;
  119719. /**
  119720. * Returns true if the mesh can be rendered, otherwise false.
  119721. * @param mesh The mesh to render
  119722. * @param material The material used on the mesh
  119723. * @returns true if it can be rendered otherwise false
  119724. */
  119725. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  119726. /**
  119727. * Implementation specific of rendering the generating effect on the main canvas.
  119728. * @param effect The effect used to render through
  119729. */
  119730. protected _internalRender(effect: Effect): void;
  119731. /**
  119732. * Sets the required values for both the emissive texture and and the main color.
  119733. */
  119734. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119735. /**
  119736. * Returns true if the mesh should render, otherwise false.
  119737. * @param mesh The mesh to render
  119738. * @returns true if it should render otherwise false
  119739. */
  119740. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119741. /**
  119742. * Adds specific effects defines.
  119743. * @param defines The defines to add specifics to.
  119744. */
  119745. protected _addCustomEffectDefines(defines: string[]): void;
  119746. /**
  119747. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  119748. * @param mesh The mesh to exclude from the glow layer
  119749. */
  119750. addExcludedMesh(mesh: Mesh): void;
  119751. /**
  119752. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  119753. * @param mesh The mesh to remove
  119754. */
  119755. removeExcludedMesh(mesh: Mesh): void;
  119756. /**
  119757. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  119758. * @param mesh The mesh to include in the glow layer
  119759. */
  119760. addIncludedOnlyMesh(mesh: Mesh): void;
  119761. /**
  119762. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  119763. * @param mesh The mesh to remove
  119764. */
  119765. removeIncludedOnlyMesh(mesh: Mesh): void;
  119766. /**
  119767. * Determine if a given mesh will be used in the glow layer
  119768. * @param mesh The mesh to test
  119769. * @returns true if the mesh will be highlighted by the current glow layer
  119770. */
  119771. hasMesh(mesh: AbstractMesh): boolean;
  119772. /**
  119773. * Defines wether the current material of the mesh should be use to render the effect.
  119774. * @param mesh defines the current mesh to render
  119775. */
  119776. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  119777. /**
  119778. * Add a mesh to be rendered through its own material and not with emissive only.
  119779. * @param mesh The mesh for which we need to use its material
  119780. */
  119781. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  119782. /**
  119783. * Remove a mesh from being rendered through its own material and not with emissive only.
  119784. * @param mesh The mesh for which we need to not use its material
  119785. */
  119786. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  119787. /**
  119788. * Free any resources and references associated to a mesh.
  119789. * Internal use
  119790. * @param mesh The mesh to free.
  119791. * @hidden
  119792. */
  119793. _disposeMesh(mesh: Mesh): void;
  119794. /**
  119795. * Gets the class name of the effect layer
  119796. * @returns the string with the class name of the effect layer
  119797. */
  119798. getClassName(): string;
  119799. /**
  119800. * Serializes this glow layer
  119801. * @returns a serialized glow layer object
  119802. */
  119803. serialize(): any;
  119804. /**
  119805. * Creates a Glow Layer from parsed glow layer data
  119806. * @param parsedGlowLayer defines glow layer data
  119807. * @param scene defines the current scene
  119808. * @param rootUrl defines the root URL containing the glow layer information
  119809. * @returns a parsed Glow Layer
  119810. */
  119811. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119812. }
  119813. }
  119814. declare module BABYLON {
  119815. /** @hidden */
  119816. export var glowBlurPostProcessPixelShader: {
  119817. name: string;
  119818. shader: string;
  119819. };
  119820. }
  119821. declare module BABYLON {
  119822. interface AbstractScene {
  119823. /**
  119824. * Return a the first highlight layer of the scene with a given name.
  119825. * @param name The name of the highlight layer to look for.
  119826. * @return The highlight layer if found otherwise null.
  119827. */
  119828. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119829. }
  119830. /**
  119831. * Highlight layer options. This helps customizing the behaviour
  119832. * of the highlight layer.
  119833. */
  119834. export interface IHighlightLayerOptions {
  119835. /**
  119836. * Multiplication factor apply to the canvas size to compute the render target size
  119837. * used to generated the glowing objects (the smaller the faster).
  119838. */
  119839. mainTextureRatio: number;
  119840. /**
  119841. * Enforces a fixed size texture to ensure resize independant blur.
  119842. */
  119843. mainTextureFixedSize?: number;
  119844. /**
  119845. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119846. * of the picture to blur (the smaller the faster).
  119847. */
  119848. blurTextureSizeRatio: number;
  119849. /**
  119850. * How big in texel of the blur texture is the vertical blur.
  119851. */
  119852. blurVerticalSize: number;
  119853. /**
  119854. * How big in texel of the blur texture is the horizontal blur.
  119855. */
  119856. blurHorizontalSize: number;
  119857. /**
  119858. * Alpha blending mode used to apply the blur. Default is combine.
  119859. */
  119860. alphaBlendingMode: number;
  119861. /**
  119862. * The camera attached to the layer.
  119863. */
  119864. camera: Nullable<Camera>;
  119865. /**
  119866. * Should we display highlight as a solid stroke?
  119867. */
  119868. isStroke?: boolean;
  119869. /**
  119870. * The rendering group to draw the layer in.
  119871. */
  119872. renderingGroupId: number;
  119873. }
  119874. /**
  119875. * The highlight layer Helps adding a glow effect around a mesh.
  119876. *
  119877. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119878. * glowy meshes to your scene.
  119879. *
  119880. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119881. */
  119882. export class HighlightLayer extends EffectLayer {
  119883. name: string;
  119884. /**
  119885. * Effect Name of the highlight layer.
  119886. */
  119887. static readonly EffectName: string;
  119888. /**
  119889. * The neutral color used during the preparation of the glow effect.
  119890. * This is black by default as the blend operation is a blend operation.
  119891. */
  119892. static NeutralColor: Color4;
  119893. /**
  119894. * Stencil value used for glowing meshes.
  119895. */
  119896. static GlowingMeshStencilReference: number;
  119897. /**
  119898. * Stencil value used for the other meshes in the scene.
  119899. */
  119900. static NormalMeshStencilReference: number;
  119901. /**
  119902. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119903. */
  119904. innerGlow: boolean;
  119905. /**
  119906. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119907. */
  119908. outerGlow: boolean;
  119909. /**
  119910. * Specifies the horizontal size of the blur.
  119911. */
  119912. /**
  119913. * Gets the horizontal size of the blur.
  119914. */
  119915. blurHorizontalSize: number;
  119916. /**
  119917. * Specifies the vertical size of the blur.
  119918. */
  119919. /**
  119920. * Gets the vertical size of the blur.
  119921. */
  119922. blurVerticalSize: number;
  119923. /**
  119924. * An event triggered when the highlight layer is being blurred.
  119925. */
  119926. onBeforeBlurObservable: Observable<HighlightLayer>;
  119927. /**
  119928. * An event triggered when the highlight layer has been blurred.
  119929. */
  119930. onAfterBlurObservable: Observable<HighlightLayer>;
  119931. private _instanceGlowingMeshStencilReference;
  119932. private _options;
  119933. private _downSamplePostprocess;
  119934. private _horizontalBlurPostprocess;
  119935. private _verticalBlurPostprocess;
  119936. private _blurTexture;
  119937. private _meshes;
  119938. private _excludedMeshes;
  119939. /**
  119940. * Instantiates a new highlight Layer and references it to the scene..
  119941. * @param name The name of the layer
  119942. * @param scene The scene to use the layer in
  119943. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119944. */
  119945. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119946. /**
  119947. * Get the effect name of the layer.
  119948. * @return The effect name
  119949. */
  119950. getEffectName(): string;
  119951. /**
  119952. * Create the merge effect. This is the shader use to blit the information back
  119953. * to the main canvas at the end of the scene rendering.
  119954. */
  119955. protected _createMergeEffect(): Effect;
  119956. /**
  119957. * Creates the render target textures and post processes used in the highlight layer.
  119958. */
  119959. protected _createTextureAndPostProcesses(): void;
  119960. /**
  119961. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119962. */
  119963. needStencil(): boolean;
  119964. /**
  119965. * Checks for the readiness of the element composing the layer.
  119966. * @param subMesh the mesh to check for
  119967. * @param useInstances specify wether or not to use instances to render the mesh
  119968. * @param emissiveTexture the associated emissive texture used to generate the glow
  119969. * @return true if ready otherwise, false
  119970. */
  119971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119972. /**
  119973. * Implementation specific of rendering the generating effect on the main canvas.
  119974. * @param effect The effect used to render through
  119975. */
  119976. protected _internalRender(effect: Effect): void;
  119977. /**
  119978. * Returns true if the layer contains information to display, otherwise false.
  119979. */
  119980. shouldRender(): boolean;
  119981. /**
  119982. * Returns true if the mesh should render, otherwise false.
  119983. * @param mesh The mesh to render
  119984. * @returns true if it should render otherwise false
  119985. */
  119986. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119987. /**
  119988. * Sets the required values for both the emissive texture and and the main color.
  119989. */
  119990. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119991. /**
  119992. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119993. * @param mesh The mesh to exclude from the highlight layer
  119994. */
  119995. addExcludedMesh(mesh: Mesh): void;
  119996. /**
  119997. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119998. * @param mesh The mesh to highlight
  119999. */
  120000. removeExcludedMesh(mesh: Mesh): void;
  120001. /**
  120002. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120003. * @param mesh mesh to test
  120004. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120005. */
  120006. hasMesh(mesh: AbstractMesh): boolean;
  120007. /**
  120008. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120009. * @param mesh The mesh to highlight
  120010. * @param color The color of the highlight
  120011. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120012. */
  120013. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120014. /**
  120015. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120016. * @param mesh The mesh to highlight
  120017. */
  120018. removeMesh(mesh: Mesh): void;
  120019. /**
  120020. * Force the stencil to the normal expected value for none glowing parts
  120021. */
  120022. private _defaultStencilReference;
  120023. /**
  120024. * Free any resources and references associated to a mesh.
  120025. * Internal use
  120026. * @param mesh The mesh to free.
  120027. * @hidden
  120028. */
  120029. _disposeMesh(mesh: Mesh): void;
  120030. /**
  120031. * Dispose the highlight layer and free resources.
  120032. */
  120033. dispose(): void;
  120034. /**
  120035. * Gets the class name of the effect layer
  120036. * @returns the string with the class name of the effect layer
  120037. */
  120038. getClassName(): string;
  120039. /**
  120040. * Serializes this Highlight layer
  120041. * @returns a serialized Highlight layer object
  120042. */
  120043. serialize(): any;
  120044. /**
  120045. * Creates a Highlight layer from parsed Highlight layer data
  120046. * @param parsedHightlightLayer defines the Highlight layer data
  120047. * @param scene defines the current scene
  120048. * @param rootUrl defines the root URL containing the Highlight layer information
  120049. * @returns a parsed Highlight layer
  120050. */
  120051. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120052. }
  120053. }
  120054. declare module BABYLON {
  120055. interface AbstractScene {
  120056. /**
  120057. * The list of layers (background and foreground) of the scene
  120058. */
  120059. layers: Array<Layer>;
  120060. }
  120061. /**
  120062. * Defines the layer scene component responsible to manage any layers
  120063. * in a given scene.
  120064. */
  120065. export class LayerSceneComponent implements ISceneComponent {
  120066. /**
  120067. * The component name helpfull to identify the component in the list of scene components.
  120068. */
  120069. readonly name: string;
  120070. /**
  120071. * The scene the component belongs to.
  120072. */
  120073. scene: Scene;
  120074. private _engine;
  120075. /**
  120076. * Creates a new instance of the component for the given scene
  120077. * @param scene Defines the scene to register the component in
  120078. */
  120079. constructor(scene: Scene);
  120080. /**
  120081. * Registers the component in a given scene
  120082. */
  120083. register(): void;
  120084. /**
  120085. * Rebuilds the elements related to this component in case of
  120086. * context lost for instance.
  120087. */
  120088. rebuild(): void;
  120089. /**
  120090. * Disposes the component and the associated ressources.
  120091. */
  120092. dispose(): void;
  120093. private _draw;
  120094. private _drawCameraPredicate;
  120095. private _drawCameraBackground;
  120096. private _drawCameraForeground;
  120097. private _drawRenderTargetPredicate;
  120098. private _drawRenderTargetBackground;
  120099. private _drawRenderTargetForeground;
  120100. /**
  120101. * Adds all the elements from the container to the scene
  120102. * @param container the container holding the elements
  120103. */
  120104. addFromContainer(container: AbstractScene): void;
  120105. /**
  120106. * Removes all the elements in the container from the scene
  120107. * @param container contains the elements to remove
  120108. * @param dispose if the removed element should be disposed (default: false)
  120109. */
  120110. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120111. }
  120112. }
  120113. declare module BABYLON {
  120114. /** @hidden */
  120115. export var layerPixelShader: {
  120116. name: string;
  120117. shader: string;
  120118. };
  120119. }
  120120. declare module BABYLON {
  120121. /** @hidden */
  120122. export var layerVertexShader: {
  120123. name: string;
  120124. shader: string;
  120125. };
  120126. }
  120127. declare module BABYLON {
  120128. /**
  120129. * This represents a full screen 2d layer.
  120130. * This can be useful to display a picture in the background of your scene for instance.
  120131. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120132. */
  120133. export class Layer {
  120134. /**
  120135. * Define the name of the layer.
  120136. */
  120137. name: string;
  120138. /**
  120139. * Define the texture the layer should display.
  120140. */
  120141. texture: Nullable<Texture>;
  120142. /**
  120143. * Is the layer in background or foreground.
  120144. */
  120145. isBackground: boolean;
  120146. /**
  120147. * Define the color of the layer (instead of texture).
  120148. */
  120149. color: Color4;
  120150. /**
  120151. * Define the scale of the layer in order to zoom in out of the texture.
  120152. */
  120153. scale: Vector2;
  120154. /**
  120155. * Define an offset for the layer in order to shift the texture.
  120156. */
  120157. offset: Vector2;
  120158. /**
  120159. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120160. */
  120161. alphaBlendingMode: number;
  120162. /**
  120163. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120164. * Alpha test will not mix with the background color in case of transparency.
  120165. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120166. */
  120167. alphaTest: boolean;
  120168. /**
  120169. * Define a mask to restrict the layer to only some of the scene cameras.
  120170. */
  120171. layerMask: number;
  120172. /**
  120173. * Define the list of render target the layer is visible into.
  120174. */
  120175. renderTargetTextures: RenderTargetTexture[];
  120176. /**
  120177. * Define if the layer is only used in renderTarget or if it also
  120178. * renders in the main frame buffer of the canvas.
  120179. */
  120180. renderOnlyInRenderTargetTextures: boolean;
  120181. private _scene;
  120182. private _vertexBuffers;
  120183. private _indexBuffer;
  120184. private _effect;
  120185. private _alphaTestEffect;
  120186. /**
  120187. * An event triggered when the layer is disposed.
  120188. */
  120189. onDisposeObservable: Observable<Layer>;
  120190. private _onDisposeObserver;
  120191. /**
  120192. * Back compatibility with callback before the onDisposeObservable existed.
  120193. * The set callback will be triggered when the layer has been disposed.
  120194. */
  120195. onDispose: () => void;
  120196. /**
  120197. * An event triggered before rendering the scene
  120198. */
  120199. onBeforeRenderObservable: Observable<Layer>;
  120200. private _onBeforeRenderObserver;
  120201. /**
  120202. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120203. * The set callback will be triggered just before rendering the layer.
  120204. */
  120205. onBeforeRender: () => void;
  120206. /**
  120207. * An event triggered after rendering the scene
  120208. */
  120209. onAfterRenderObservable: Observable<Layer>;
  120210. private _onAfterRenderObserver;
  120211. /**
  120212. * Back compatibility with callback before the onAfterRenderObservable existed.
  120213. * The set callback will be triggered just after rendering the layer.
  120214. */
  120215. onAfterRender: () => void;
  120216. /**
  120217. * Instantiates a new layer.
  120218. * This represents a full screen 2d layer.
  120219. * This can be useful to display a picture in the background of your scene for instance.
  120220. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120221. * @param name Define the name of the layer in the scene
  120222. * @param imgUrl Define the url of the texture to display in the layer
  120223. * @param scene Define the scene the layer belongs to
  120224. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120225. * @param color Defines a color for the layer
  120226. */
  120227. constructor(
  120228. /**
  120229. * Define the name of the layer.
  120230. */
  120231. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120232. private _createIndexBuffer;
  120233. /** @hidden */
  120234. _rebuild(): void;
  120235. /**
  120236. * Renders the layer in the scene.
  120237. */
  120238. render(): void;
  120239. /**
  120240. * Disposes and releases the associated ressources.
  120241. */
  120242. dispose(): void;
  120243. }
  120244. }
  120245. declare module BABYLON {
  120246. /** @hidden */
  120247. export var lensFlarePixelShader: {
  120248. name: string;
  120249. shader: string;
  120250. };
  120251. }
  120252. declare module BABYLON {
  120253. /** @hidden */
  120254. export var lensFlareVertexShader: {
  120255. name: string;
  120256. shader: string;
  120257. };
  120258. }
  120259. declare module BABYLON {
  120260. /**
  120261. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120262. * It is usually composed of several `lensFlare`.
  120263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120264. */
  120265. export class LensFlareSystem {
  120266. /**
  120267. * Define the name of the lens flare system
  120268. */
  120269. name: string;
  120270. /**
  120271. * List of lens flares used in this system.
  120272. */
  120273. lensFlares: LensFlare[];
  120274. /**
  120275. * Define a limit from the border the lens flare can be visible.
  120276. */
  120277. borderLimit: number;
  120278. /**
  120279. * Define a viewport border we do not want to see the lens flare in.
  120280. */
  120281. viewportBorder: number;
  120282. /**
  120283. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120284. */
  120285. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120286. /**
  120287. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120288. */
  120289. layerMask: number;
  120290. /**
  120291. * Define the id of the lens flare system in the scene.
  120292. * (equal to name by default)
  120293. */
  120294. id: string;
  120295. private _scene;
  120296. private _emitter;
  120297. private _vertexBuffers;
  120298. private _indexBuffer;
  120299. private _effect;
  120300. private _positionX;
  120301. private _positionY;
  120302. private _isEnabled;
  120303. /** @hidden */
  120304. static _SceneComponentInitialization: (scene: Scene) => void;
  120305. /**
  120306. * Instantiates a lens flare system.
  120307. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120308. * It is usually composed of several `lensFlare`.
  120309. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120310. * @param name Define the name of the lens flare system in the scene
  120311. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120312. * @param scene Define the scene the lens flare system belongs to
  120313. */
  120314. constructor(
  120315. /**
  120316. * Define the name of the lens flare system
  120317. */
  120318. name: string, emitter: any, scene: Scene);
  120319. /**
  120320. * Define if the lens flare system is enabled.
  120321. */
  120322. isEnabled: boolean;
  120323. /**
  120324. * Get the scene the effects belongs to.
  120325. * @returns the scene holding the lens flare system
  120326. */
  120327. getScene(): Scene;
  120328. /**
  120329. * Get the emitter of the lens flare system.
  120330. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120331. * @returns the emitter of the lens flare system
  120332. */
  120333. getEmitter(): any;
  120334. /**
  120335. * Set the emitter of the lens flare system.
  120336. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120337. * @param newEmitter Define the new emitter of the system
  120338. */
  120339. setEmitter(newEmitter: any): void;
  120340. /**
  120341. * Get the lens flare system emitter position.
  120342. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120343. * @returns the position
  120344. */
  120345. getEmitterPosition(): Vector3;
  120346. /**
  120347. * @hidden
  120348. */
  120349. computeEffectivePosition(globalViewport: Viewport): boolean;
  120350. /** @hidden */
  120351. _isVisible(): boolean;
  120352. /**
  120353. * @hidden
  120354. */
  120355. render(): boolean;
  120356. /**
  120357. * Dispose and release the lens flare with its associated resources.
  120358. */
  120359. dispose(): void;
  120360. /**
  120361. * Parse a lens flare system from a JSON repressentation
  120362. * @param parsedLensFlareSystem Define the JSON to parse
  120363. * @param scene Define the scene the parsed system should be instantiated in
  120364. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  120365. * @returns the parsed system
  120366. */
  120367. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  120368. /**
  120369. * Serialize the current Lens Flare System into a JSON representation.
  120370. * @returns the serialized JSON
  120371. */
  120372. serialize(): any;
  120373. }
  120374. }
  120375. declare module BABYLON {
  120376. /**
  120377. * This represents one of the lens effect in a `lensFlareSystem`.
  120378. * It controls one of the indiviual texture used in the effect.
  120379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120380. */
  120381. export class LensFlare {
  120382. /**
  120383. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120384. */
  120385. size: number;
  120386. /**
  120387. * 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.
  120388. */
  120389. position: number;
  120390. /**
  120391. * Define the lens color.
  120392. */
  120393. color: Color3;
  120394. /**
  120395. * Define the lens texture.
  120396. */
  120397. texture: Nullable<Texture>;
  120398. /**
  120399. * Define the alpha mode to render this particular lens.
  120400. */
  120401. alphaMode: number;
  120402. private _system;
  120403. /**
  120404. * Creates a new Lens Flare.
  120405. * This represents one of the lens effect in a `lensFlareSystem`.
  120406. * It controls one of the indiviual texture used in the effect.
  120407. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120408. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  120409. * @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.
  120410. * @param color Define the lens color
  120411. * @param imgUrl Define the lens texture url
  120412. * @param system Define the `lensFlareSystem` this flare is part of
  120413. * @returns The newly created Lens Flare
  120414. */
  120415. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  120416. /**
  120417. * Instantiates a new Lens Flare.
  120418. * This represents one of the lens effect in a `lensFlareSystem`.
  120419. * It controls one of the indiviual texture used in the effect.
  120420. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120421. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  120422. * @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.
  120423. * @param color Define the lens color
  120424. * @param imgUrl Define the lens texture url
  120425. * @param system Define the `lensFlareSystem` this flare is part of
  120426. */
  120427. constructor(
  120428. /**
  120429. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  120430. */
  120431. size: number,
  120432. /**
  120433. * 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.
  120434. */
  120435. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  120436. /**
  120437. * Dispose and release the lens flare with its associated resources.
  120438. */
  120439. dispose(): void;
  120440. }
  120441. }
  120442. declare module BABYLON {
  120443. interface AbstractScene {
  120444. /**
  120445. * The list of lens flare system added to the scene
  120446. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120447. */
  120448. lensFlareSystems: Array<LensFlareSystem>;
  120449. /**
  120450. * Removes the given lens flare system from this scene.
  120451. * @param toRemove The lens flare system to remove
  120452. * @returns The index of the removed lens flare system
  120453. */
  120454. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  120455. /**
  120456. * Adds the given lens flare system to this scene
  120457. * @param newLensFlareSystem The lens flare system to add
  120458. */
  120459. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  120460. /**
  120461. * Gets a lens flare system using its name
  120462. * @param name defines the name to look for
  120463. * @returns the lens flare system or null if not found
  120464. */
  120465. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  120466. /**
  120467. * Gets a lens flare system using its id
  120468. * @param id defines the id to look for
  120469. * @returns the lens flare system or null if not found
  120470. */
  120471. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  120472. }
  120473. /**
  120474. * Defines the lens flare scene component responsible to manage any lens flares
  120475. * in a given scene.
  120476. */
  120477. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  120478. /**
  120479. * The component name helpfull to identify the component in the list of scene components.
  120480. */
  120481. readonly name: string;
  120482. /**
  120483. * The scene the component belongs to.
  120484. */
  120485. scene: Scene;
  120486. /**
  120487. * Creates a new instance of the component for the given scene
  120488. * @param scene Defines the scene to register the component in
  120489. */
  120490. constructor(scene: Scene);
  120491. /**
  120492. * Registers the component in a given scene
  120493. */
  120494. register(): void;
  120495. /**
  120496. * Rebuilds the elements related to this component in case of
  120497. * context lost for instance.
  120498. */
  120499. rebuild(): void;
  120500. /**
  120501. * Adds all the elements from the container to the scene
  120502. * @param container the container holding the elements
  120503. */
  120504. addFromContainer(container: AbstractScene): void;
  120505. /**
  120506. * Removes all the elements in the container from the scene
  120507. * @param container contains the elements to remove
  120508. * @param dispose if the removed element should be disposed (default: false)
  120509. */
  120510. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120511. /**
  120512. * Serializes the component data to the specified json object
  120513. * @param serializationObject The object to serialize to
  120514. */
  120515. serialize(serializationObject: any): void;
  120516. /**
  120517. * Disposes the component and the associated ressources.
  120518. */
  120519. dispose(): void;
  120520. private _draw;
  120521. }
  120522. }
  120523. declare module BABYLON {
  120524. /**
  120525. * Defines the shadow generator component responsible to manage any shadow generators
  120526. * in a given scene.
  120527. */
  120528. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  120529. /**
  120530. * The component name helpfull to identify the component in the list of scene components.
  120531. */
  120532. readonly name: string;
  120533. /**
  120534. * The scene the component belongs to.
  120535. */
  120536. scene: Scene;
  120537. /**
  120538. * Creates a new instance of the component for the given scene
  120539. * @param scene Defines the scene to register the component in
  120540. */
  120541. constructor(scene: Scene);
  120542. /**
  120543. * Registers the component in a given scene
  120544. */
  120545. register(): void;
  120546. /**
  120547. * Rebuilds the elements related to this component in case of
  120548. * context lost for instance.
  120549. */
  120550. rebuild(): void;
  120551. /**
  120552. * Serializes the component data to the specified json object
  120553. * @param serializationObject The object to serialize to
  120554. */
  120555. serialize(serializationObject: any): void;
  120556. /**
  120557. * Adds all the elements from the container to the scene
  120558. * @param container the container holding the elements
  120559. */
  120560. addFromContainer(container: AbstractScene): void;
  120561. /**
  120562. * Removes all the elements in the container from the scene
  120563. * @param container contains the elements to remove
  120564. * @param dispose if the removed element should be disposed (default: false)
  120565. */
  120566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120567. /**
  120568. * Rebuilds the elements related to this component in case of
  120569. * context lost for instance.
  120570. */
  120571. dispose(): void;
  120572. private _gatherRenderTargets;
  120573. }
  120574. }
  120575. declare module BABYLON {
  120576. /**
  120577. * A point light is a light defined by an unique point in world space.
  120578. * The light is emitted in every direction from this point.
  120579. * A good example of a point light is a standard light bulb.
  120580. * Documentation: https://doc.babylonjs.com/babylon101/lights
  120581. */
  120582. export class PointLight extends ShadowLight {
  120583. private _shadowAngle;
  120584. /**
  120585. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120586. * This specifies what angle the shadow will use to be created.
  120587. *
  120588. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120589. */
  120590. /**
  120591. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120592. * This specifies what angle the shadow will use to be created.
  120593. *
  120594. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  120595. */
  120596. shadowAngle: number;
  120597. /**
  120598. * Gets the direction if it has been set.
  120599. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120600. */
  120601. /**
  120602. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  120603. */
  120604. direction: Vector3;
  120605. /**
  120606. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  120607. * A PointLight emits the light in every direction.
  120608. * It can cast shadows.
  120609. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  120610. * ```javascript
  120611. * var pointLight = new PointLight("pl", camera.position, scene);
  120612. * ```
  120613. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120614. * @param name The light friendly name
  120615. * @param position The position of the point light in the scene
  120616. * @param scene The scene the lights belongs to
  120617. */
  120618. constructor(name: string, position: Vector3, scene: Scene);
  120619. /**
  120620. * Returns the string "PointLight"
  120621. * @returns the class name
  120622. */
  120623. getClassName(): string;
  120624. /**
  120625. * Returns the integer 0.
  120626. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120627. */
  120628. getTypeID(): number;
  120629. /**
  120630. * Specifies wether or not the shadowmap should be a cube texture.
  120631. * @returns true if the shadowmap needs to be a cube texture.
  120632. */
  120633. needCube(): boolean;
  120634. /**
  120635. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  120636. * @param faceIndex The index of the face we are computed the direction to generate shadow
  120637. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  120638. */
  120639. getShadowDirection(faceIndex?: number): Vector3;
  120640. /**
  120641. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  120642. * - fov = PI / 2
  120643. * - aspect ratio : 1.0
  120644. * - z-near and far equal to the active camera minZ and maxZ.
  120645. * Returns the PointLight.
  120646. */
  120647. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120648. protected _buildUniformLayout(): void;
  120649. /**
  120650. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  120651. * @param effect The effect to update
  120652. * @param lightIndex The index of the light in the effect to update
  120653. * @returns The point light
  120654. */
  120655. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  120656. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120657. /**
  120658. * Prepares the list of defines specific to the light type.
  120659. * @param defines the list of defines
  120660. * @param lightIndex defines the index of the light for the effect
  120661. */
  120662. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120663. }
  120664. }
  120665. declare module BABYLON {
  120666. /**
  120667. * Header information of HDR texture files.
  120668. */
  120669. export interface HDRInfo {
  120670. /**
  120671. * The height of the texture in pixels.
  120672. */
  120673. height: number;
  120674. /**
  120675. * The width of the texture in pixels.
  120676. */
  120677. width: number;
  120678. /**
  120679. * The index of the beginning of the data in the binary file.
  120680. */
  120681. dataPosition: number;
  120682. }
  120683. /**
  120684. * This groups tools to convert HDR texture to native colors array.
  120685. */
  120686. export class HDRTools {
  120687. private static Ldexp;
  120688. private static Rgbe2float;
  120689. private static readStringLine;
  120690. /**
  120691. * Reads header information from an RGBE texture stored in a native array.
  120692. * More information on this format are available here:
  120693. * https://en.wikipedia.org/wiki/RGBE_image_format
  120694. *
  120695. * @param uint8array The binary file stored in native array.
  120696. * @return The header information.
  120697. */
  120698. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  120699. /**
  120700. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  120701. * This RGBE texture needs to store the information as a panorama.
  120702. *
  120703. * More information on this format are available here:
  120704. * https://en.wikipedia.org/wiki/RGBE_image_format
  120705. *
  120706. * @param buffer The binary file stored in an array buffer.
  120707. * @param size The expected size of the extracted cubemap.
  120708. * @return The Cube Map information.
  120709. */
  120710. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  120711. /**
  120712. * Returns the pixels data extracted from an RGBE texture.
  120713. * This pixels will be stored left to right up to down in the R G B order in one array.
  120714. *
  120715. * More information on this format are available here:
  120716. * https://en.wikipedia.org/wiki/RGBE_image_format
  120717. *
  120718. * @param uint8array The binary file stored in an array buffer.
  120719. * @param hdrInfo The header information of the file.
  120720. * @return The pixels data in RGB right to left up to down order.
  120721. */
  120722. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  120723. private static RGBE_ReadPixels_RLE;
  120724. }
  120725. }
  120726. declare module BABYLON {
  120727. /**
  120728. * This represents a texture coming from an HDR input.
  120729. *
  120730. * The only supported format is currently panorama picture stored in RGBE format.
  120731. * Example of such files can be found on HDRLib: http://hdrlib.com/
  120732. */
  120733. export class HDRCubeTexture extends BaseTexture {
  120734. private static _facesMapping;
  120735. private _generateHarmonics;
  120736. private _noMipmap;
  120737. private _textureMatrix;
  120738. private _size;
  120739. private _onLoad;
  120740. private _onError;
  120741. /**
  120742. * The texture URL.
  120743. */
  120744. url: string;
  120745. /**
  120746. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  120747. */
  120748. coordinatesMode: number;
  120749. protected _isBlocking: boolean;
  120750. /**
  120751. * Sets wether or not the texture is blocking during loading.
  120752. */
  120753. /**
  120754. * Gets wether or not the texture is blocking during loading.
  120755. */
  120756. isBlocking: boolean;
  120757. protected _rotationY: number;
  120758. /**
  120759. * Sets texture matrix rotation angle around Y axis in radians.
  120760. */
  120761. /**
  120762. * Gets texture matrix rotation angle around Y axis radians.
  120763. */
  120764. rotationY: number;
  120765. /**
  120766. * Gets or sets the center of the bounding box associated with the cube texture
  120767. * It must define where the camera used to render the texture was set
  120768. */
  120769. boundingBoxPosition: Vector3;
  120770. private _boundingBoxSize;
  120771. /**
  120772. * Gets or sets the size of the bounding box associated with the cube texture
  120773. * When defined, the cubemap will switch to local mode
  120774. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  120775. * @example https://www.babylonjs-playground.com/#RNASML
  120776. */
  120777. boundingBoxSize: Vector3;
  120778. /**
  120779. * Instantiates an HDRTexture from the following parameters.
  120780. *
  120781. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  120782. * @param scene The scene the texture will be used in
  120783. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  120784. * @param noMipmap Forces to not generate the mipmap if true
  120785. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  120786. * @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)
  120787. * @param reserved Reserved flag for internal use.
  120788. */
  120789. 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>);
  120790. /**
  120791. * Get the current class name of the texture useful for serialization or dynamic coding.
  120792. * @returns "HDRCubeTexture"
  120793. */
  120794. getClassName(): string;
  120795. /**
  120796. * Occurs when the file is raw .hdr file.
  120797. */
  120798. private loadTexture;
  120799. clone(): HDRCubeTexture;
  120800. delayLoad(): void;
  120801. /**
  120802. * Get the texture reflection matrix used to rotate/transform the reflection.
  120803. * @returns the reflection matrix
  120804. */
  120805. getReflectionTextureMatrix(): Matrix;
  120806. /**
  120807. * Set the texture reflection matrix used to rotate/transform the reflection.
  120808. * @param value Define the reflection matrix to set
  120809. */
  120810. setReflectionTextureMatrix(value: Matrix): void;
  120811. /**
  120812. * Parses a JSON representation of an HDR Texture in order to create the texture
  120813. * @param parsedTexture Define the JSON representation
  120814. * @param scene Define the scene the texture should be created in
  120815. * @param rootUrl Define the root url in case we need to load relative dependencies
  120816. * @returns the newly created texture after parsing
  120817. */
  120818. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120819. serialize(): any;
  120820. }
  120821. }
  120822. declare module BABYLON {
  120823. /**
  120824. * Class used to control physics engine
  120825. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120826. */
  120827. export class PhysicsEngine implements IPhysicsEngine {
  120828. private _physicsPlugin;
  120829. /**
  120830. * Global value used to control the smallest number supported by the simulation
  120831. */
  120832. static Epsilon: number;
  120833. private _impostors;
  120834. private _joints;
  120835. private _subTimeStep;
  120836. /**
  120837. * Gets the gravity vector used by the simulation
  120838. */
  120839. gravity: Vector3;
  120840. /**
  120841. * Factory used to create the default physics plugin.
  120842. * @returns The default physics plugin
  120843. */
  120844. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120845. /**
  120846. * Creates a new Physics Engine
  120847. * @param gravity defines the gravity vector used by the simulation
  120848. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120849. */
  120850. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120851. /**
  120852. * Sets the gravity vector used by the simulation
  120853. * @param gravity defines the gravity vector to use
  120854. */
  120855. setGravity(gravity: Vector3): void;
  120856. /**
  120857. * Set the time step of the physics engine.
  120858. * Default is 1/60.
  120859. * To slow it down, enter 1/600 for example.
  120860. * To speed it up, 1/30
  120861. * @param newTimeStep defines the new timestep to apply to this world.
  120862. */
  120863. setTimeStep(newTimeStep?: number): void;
  120864. /**
  120865. * Get the time step of the physics engine.
  120866. * @returns the current time step
  120867. */
  120868. getTimeStep(): number;
  120869. /**
  120870. * Set the sub time step of the physics engine.
  120871. * Default is 0 meaning there is no sub steps
  120872. * To increase physics resolution precision, set a small value (like 1 ms)
  120873. * @param subTimeStep defines the new sub timestep used for physics resolution.
  120874. */
  120875. setSubTimeStep(subTimeStep?: number): void;
  120876. /**
  120877. * Get the sub time step of the physics engine.
  120878. * @returns the current sub time step
  120879. */
  120880. getSubTimeStep(): number;
  120881. /**
  120882. * Release all resources
  120883. */
  120884. dispose(): void;
  120885. /**
  120886. * Gets the name of the current physics plugin
  120887. * @returns the name of the plugin
  120888. */
  120889. getPhysicsPluginName(): string;
  120890. /**
  120891. * Adding a new impostor for the impostor tracking.
  120892. * This will be done by the impostor itself.
  120893. * @param impostor the impostor to add
  120894. */
  120895. addImpostor(impostor: PhysicsImpostor): void;
  120896. /**
  120897. * Remove an impostor from the engine.
  120898. * This impostor and its mesh will not longer be updated by the physics engine.
  120899. * @param impostor the impostor to remove
  120900. */
  120901. removeImpostor(impostor: PhysicsImpostor): void;
  120902. /**
  120903. * Add a joint to the physics engine
  120904. * @param mainImpostor defines the main impostor to which the joint is added.
  120905. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120906. * @param joint defines the joint that will connect both impostors.
  120907. */
  120908. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120909. /**
  120910. * Removes a joint from the simulation
  120911. * @param mainImpostor defines the impostor used with the joint
  120912. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120913. * @param joint defines the joint to remove
  120914. */
  120915. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120916. /**
  120917. * Called by the scene. No need to call it.
  120918. * @param delta defines the timespam between frames
  120919. */
  120920. _step(delta: number): void;
  120921. /**
  120922. * Gets the current plugin used to run the simulation
  120923. * @returns current plugin
  120924. */
  120925. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120926. /**
  120927. * Gets the list of physic impostors
  120928. * @returns an array of PhysicsImpostor
  120929. */
  120930. getImpostors(): Array<PhysicsImpostor>;
  120931. /**
  120932. * Gets the impostor for a physics enabled object
  120933. * @param object defines the object impersonated by the impostor
  120934. * @returns the PhysicsImpostor or null if not found
  120935. */
  120936. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120937. /**
  120938. * Gets the impostor for a physics body object
  120939. * @param body defines physics body used by the impostor
  120940. * @returns the PhysicsImpostor or null if not found
  120941. */
  120942. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120943. /**
  120944. * Does a raycast in the physics world
  120945. * @param from when should the ray start?
  120946. * @param to when should the ray end?
  120947. * @returns PhysicsRaycastResult
  120948. */
  120949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120950. }
  120951. }
  120952. declare module BABYLON {
  120953. /** @hidden */
  120954. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120955. private _useDeltaForWorldStep;
  120956. world: any;
  120957. name: string;
  120958. private _physicsMaterials;
  120959. private _fixedTimeStep;
  120960. private _cannonRaycastResult;
  120961. private _raycastResult;
  120962. private _physicsBodysToRemoveAfterStep;
  120963. BJSCANNON: any;
  120964. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120965. setGravity(gravity: Vector3): void;
  120966. setTimeStep(timeStep: number): void;
  120967. getTimeStep(): number;
  120968. executeStep(delta: number): void;
  120969. private _removeMarkedPhysicsBodiesFromWorld;
  120970. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120971. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120972. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120973. private _processChildMeshes;
  120974. removePhysicsBody(impostor: PhysicsImpostor): void;
  120975. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120976. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120977. private _addMaterial;
  120978. private _checkWithEpsilon;
  120979. private _createShape;
  120980. private _createHeightmap;
  120981. private _minus90X;
  120982. private _plus90X;
  120983. private _tmpPosition;
  120984. private _tmpDeltaPosition;
  120985. private _tmpUnityRotation;
  120986. private _updatePhysicsBodyTransformation;
  120987. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120988. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120989. isSupported(): boolean;
  120990. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120991. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120993. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120995. getBodyMass(impostor: PhysicsImpostor): number;
  120996. getBodyFriction(impostor: PhysicsImpostor): number;
  120997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120998. getBodyRestitution(impostor: PhysicsImpostor): number;
  120999. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121000. sleepBody(impostor: PhysicsImpostor): void;
  121001. wakeUpBody(impostor: PhysicsImpostor): void;
  121002. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121003. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121004. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121005. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121006. getRadius(impostor: PhysicsImpostor): number;
  121007. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121008. dispose(): void;
  121009. private _extendNamespace;
  121010. /**
  121011. * Does a raycast in the physics world
  121012. * @param from when should the ray start?
  121013. * @param to when should the ray end?
  121014. * @returns PhysicsRaycastResult
  121015. */
  121016. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121017. }
  121018. }
  121019. declare module BABYLON {
  121020. /** @hidden */
  121021. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121022. world: any;
  121023. name: string;
  121024. BJSOIMO: any;
  121025. private _raycastResult;
  121026. constructor(iterations?: number, oimoInjection?: any);
  121027. setGravity(gravity: Vector3): void;
  121028. setTimeStep(timeStep: number): void;
  121029. getTimeStep(): number;
  121030. private _tmpImpostorsArray;
  121031. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121032. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121033. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121034. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121035. private _tmpPositionVector;
  121036. removePhysicsBody(impostor: PhysicsImpostor): void;
  121037. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121038. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121039. isSupported(): boolean;
  121040. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121041. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121042. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121043. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121044. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121045. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121046. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121047. getBodyMass(impostor: PhysicsImpostor): number;
  121048. getBodyFriction(impostor: PhysicsImpostor): number;
  121049. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121050. getBodyRestitution(impostor: PhysicsImpostor): number;
  121051. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121052. sleepBody(impostor: PhysicsImpostor): void;
  121053. wakeUpBody(impostor: PhysicsImpostor): void;
  121054. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121055. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121056. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121057. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121058. getRadius(impostor: PhysicsImpostor): number;
  121059. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121060. dispose(): void;
  121061. /**
  121062. * Does a raycast in the physics world
  121063. * @param from when should the ray start?
  121064. * @param to when should the ray end?
  121065. * @returns PhysicsRaycastResult
  121066. */
  121067. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121068. }
  121069. }
  121070. declare module BABYLON {
  121071. /**
  121072. * Class containing static functions to help procedurally build meshes
  121073. */
  121074. export class RibbonBuilder {
  121075. /**
  121076. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121077. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121078. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121079. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121080. * * 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
  121081. * * 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
  121082. * * 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
  121083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121086. * * 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
  121087. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121088. * * 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
  121089. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121091. * @param name defines the name of the mesh
  121092. * @param options defines the options used to create the mesh
  121093. * @param scene defines the hosting scene
  121094. * @returns the ribbon mesh
  121095. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121097. */
  121098. static CreateRibbon(name: string, options: {
  121099. pathArray: Vector3[][];
  121100. closeArray?: boolean;
  121101. closePath?: boolean;
  121102. offset?: number;
  121103. updatable?: boolean;
  121104. sideOrientation?: number;
  121105. frontUVs?: Vector4;
  121106. backUVs?: Vector4;
  121107. instance?: Mesh;
  121108. invertUV?: boolean;
  121109. uvs?: Vector2[];
  121110. colors?: Color4[];
  121111. }, scene?: Nullable<Scene>): Mesh;
  121112. }
  121113. }
  121114. declare module BABYLON {
  121115. /**
  121116. * Class containing static functions to help procedurally build meshes
  121117. */
  121118. export class ShapeBuilder {
  121119. /**
  121120. * 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.
  121121. * * 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.
  121122. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121123. * * 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.
  121124. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121125. * * 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
  121126. * * 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
  121127. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121132. * @param name defines the name of the mesh
  121133. * @param options defines the options used to create the mesh
  121134. * @param scene defines the hosting scene
  121135. * @returns the extruded shape mesh
  121136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121138. */
  121139. static ExtrudeShape(name: string, options: {
  121140. shape: Vector3[];
  121141. path: Vector3[];
  121142. scale?: number;
  121143. rotation?: number;
  121144. cap?: number;
  121145. updatable?: boolean;
  121146. sideOrientation?: number;
  121147. frontUVs?: Vector4;
  121148. backUVs?: Vector4;
  121149. instance?: Mesh;
  121150. invertUV?: boolean;
  121151. }, scene?: Nullable<Scene>): Mesh;
  121152. /**
  121153. * Creates an custom extruded shape mesh.
  121154. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121155. * * 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.
  121156. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121157. * * 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
  121158. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121159. * * 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
  121160. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121161. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121162. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121163. * * 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
  121164. * * 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
  121165. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121167. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121168. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121170. * @param name defines the name of the mesh
  121171. * @param options defines the options used to create the mesh
  121172. * @param scene defines the hosting scene
  121173. * @returns the custom extruded shape mesh
  121174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121177. */
  121178. static ExtrudeShapeCustom(name: string, options: {
  121179. shape: Vector3[];
  121180. path: Vector3[];
  121181. scaleFunction?: any;
  121182. rotationFunction?: any;
  121183. ribbonCloseArray?: boolean;
  121184. ribbonClosePath?: boolean;
  121185. cap?: number;
  121186. updatable?: boolean;
  121187. sideOrientation?: number;
  121188. frontUVs?: Vector4;
  121189. backUVs?: Vector4;
  121190. instance?: Mesh;
  121191. invertUV?: boolean;
  121192. }, scene?: Nullable<Scene>): Mesh;
  121193. private static _ExtrudeShapeGeneric;
  121194. }
  121195. }
  121196. declare module BABYLON {
  121197. /**
  121198. * AmmoJS Physics plugin
  121199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121200. * @see https://github.com/kripken/ammo.js/
  121201. */
  121202. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121203. private _useDeltaForWorldStep;
  121204. /**
  121205. * Reference to the Ammo library
  121206. */
  121207. bjsAMMO: any;
  121208. /**
  121209. * Created ammoJS world which physics bodies are added to
  121210. */
  121211. world: any;
  121212. /**
  121213. * Name of the plugin
  121214. */
  121215. name: string;
  121216. private _timeStep;
  121217. private _fixedTimeStep;
  121218. private _maxSteps;
  121219. private _tmpQuaternion;
  121220. private _tmpAmmoTransform;
  121221. private _tmpAmmoQuaternion;
  121222. private _tmpAmmoConcreteContactResultCallback;
  121223. private _collisionConfiguration;
  121224. private _dispatcher;
  121225. private _overlappingPairCache;
  121226. private _solver;
  121227. private _softBodySolver;
  121228. private _tmpAmmoVectorA;
  121229. private _tmpAmmoVectorB;
  121230. private _tmpAmmoVectorC;
  121231. private _tmpAmmoVectorD;
  121232. private _tmpContactCallbackResult;
  121233. private _tmpAmmoVectorRCA;
  121234. private _tmpAmmoVectorRCB;
  121235. private _raycastResult;
  121236. private static readonly DISABLE_COLLISION_FLAG;
  121237. private static readonly KINEMATIC_FLAG;
  121238. private static readonly DISABLE_DEACTIVATION_FLAG;
  121239. /**
  121240. * Initializes the ammoJS plugin
  121241. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121242. * @param ammoInjection can be used to inject your own ammo reference
  121243. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121244. */
  121245. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121246. /**
  121247. * Sets the gravity of the physics world (m/(s^2))
  121248. * @param gravity Gravity to set
  121249. */
  121250. setGravity(gravity: Vector3): void;
  121251. /**
  121252. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121253. * @param timeStep timestep to use in seconds
  121254. */
  121255. setTimeStep(timeStep: number): void;
  121256. /**
  121257. * 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)
  121258. * @param fixedTimeStep fixedTimeStep to use in seconds
  121259. */
  121260. setFixedTimeStep(fixedTimeStep: number): void;
  121261. /**
  121262. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121263. * @param maxSteps the maximum number of steps by the physics engine per frame
  121264. */
  121265. setMaxSteps(maxSteps: number): void;
  121266. /**
  121267. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121268. * @returns the current timestep in seconds
  121269. */
  121270. getTimeStep(): number;
  121271. /**
  121272. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121273. */
  121274. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121275. private _isImpostorInContact;
  121276. private _isImpostorPairInContact;
  121277. private _stepSimulation;
  121278. /**
  121279. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121280. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121281. * After the step the babylon meshes are set to the position of the physics imposters
  121282. * @param delta amount of time to step forward
  121283. * @param impostors array of imposters to update before/after the step
  121284. */
  121285. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121286. /**
  121287. * Update babylon mesh to match physics world object
  121288. * @param impostor imposter to match
  121289. */
  121290. private _afterSoftStep;
  121291. /**
  121292. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121293. * @param impostor imposter to match
  121294. */
  121295. private _ropeStep;
  121296. /**
  121297. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121298. * @param impostor imposter to match
  121299. */
  121300. private _softbodyOrClothStep;
  121301. private _tmpVector;
  121302. private _tmpMatrix;
  121303. /**
  121304. * Applies an impulse on the imposter
  121305. * @param impostor imposter to apply impulse to
  121306. * @param force amount of force to be applied to the imposter
  121307. * @param contactPoint the location to apply the impulse on the imposter
  121308. */
  121309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121310. /**
  121311. * Applies a force on the imposter
  121312. * @param impostor imposter to apply force
  121313. * @param force amount of force to be applied to the imposter
  121314. * @param contactPoint the location to apply the force on the imposter
  121315. */
  121316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121317. /**
  121318. * Creates a physics body using the plugin
  121319. * @param impostor the imposter to create the physics body on
  121320. */
  121321. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121322. /**
  121323. * Removes the physics body from the imposter and disposes of the body's memory
  121324. * @param impostor imposter to remove the physics body from
  121325. */
  121326. removePhysicsBody(impostor: PhysicsImpostor): void;
  121327. /**
  121328. * Generates a joint
  121329. * @param impostorJoint the imposter joint to create the joint with
  121330. */
  121331. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121332. /**
  121333. * Removes a joint
  121334. * @param impostorJoint the imposter joint to remove the joint from
  121335. */
  121336. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121337. private _addMeshVerts;
  121338. /**
  121339. * Initialise the soft body vertices to match its object's (mesh) vertices
  121340. * Softbody vertices (nodes) are in world space and to match this
  121341. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121342. * @param impostor to create the softbody for
  121343. */
  121344. private _softVertexData;
  121345. /**
  121346. * Create an impostor's soft body
  121347. * @param impostor to create the softbody for
  121348. */
  121349. private _createSoftbody;
  121350. /**
  121351. * Create cloth for an impostor
  121352. * @param impostor to create the softbody for
  121353. */
  121354. private _createCloth;
  121355. /**
  121356. * Create rope for an impostor
  121357. * @param impostor to create the softbody for
  121358. */
  121359. private _createRope;
  121360. /**
  121361. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  121362. * @param impostor to create the custom physics shape for
  121363. */
  121364. private _createCustom;
  121365. private _addHullVerts;
  121366. private _createShape;
  121367. /**
  121368. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  121369. * @param impostor imposter containing the physics body and babylon object
  121370. */
  121371. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121372. /**
  121373. * Sets the babylon object's position/rotation from the physics body's position/rotation
  121374. * @param impostor imposter containing the physics body and babylon object
  121375. * @param newPosition new position
  121376. * @param newRotation new rotation
  121377. */
  121378. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121379. /**
  121380. * If this plugin is supported
  121381. * @returns true if its supported
  121382. */
  121383. isSupported(): boolean;
  121384. /**
  121385. * Sets the linear velocity of the physics body
  121386. * @param impostor imposter to set the velocity on
  121387. * @param velocity velocity to set
  121388. */
  121389. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121390. /**
  121391. * Sets the angular velocity of the physics body
  121392. * @param impostor imposter to set the velocity on
  121393. * @param velocity velocity to set
  121394. */
  121395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121396. /**
  121397. * gets the linear velocity
  121398. * @param impostor imposter to get linear velocity from
  121399. * @returns linear velocity
  121400. */
  121401. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121402. /**
  121403. * gets the angular velocity
  121404. * @param impostor imposter to get angular velocity from
  121405. * @returns angular velocity
  121406. */
  121407. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121408. /**
  121409. * Sets the mass of physics body
  121410. * @param impostor imposter to set the mass on
  121411. * @param mass mass to set
  121412. */
  121413. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121414. /**
  121415. * Gets the mass of the physics body
  121416. * @param impostor imposter to get the mass from
  121417. * @returns mass
  121418. */
  121419. getBodyMass(impostor: PhysicsImpostor): number;
  121420. /**
  121421. * Gets friction of the impostor
  121422. * @param impostor impostor to get friction from
  121423. * @returns friction value
  121424. */
  121425. getBodyFriction(impostor: PhysicsImpostor): number;
  121426. /**
  121427. * Sets friction of the impostor
  121428. * @param impostor impostor to set friction on
  121429. * @param friction friction value
  121430. */
  121431. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121432. /**
  121433. * Gets restitution of the impostor
  121434. * @param impostor impostor to get restitution from
  121435. * @returns restitution value
  121436. */
  121437. getBodyRestitution(impostor: PhysicsImpostor): number;
  121438. /**
  121439. * Sets resitution of the impostor
  121440. * @param impostor impostor to set resitution on
  121441. * @param restitution resitution value
  121442. */
  121443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121444. /**
  121445. * Gets pressure inside the impostor
  121446. * @param impostor impostor to get pressure from
  121447. * @returns pressure value
  121448. */
  121449. getBodyPressure(impostor: PhysicsImpostor): number;
  121450. /**
  121451. * Sets pressure inside a soft body impostor
  121452. * Cloth and rope must remain 0 pressure
  121453. * @param impostor impostor to set pressure on
  121454. * @param pressure pressure value
  121455. */
  121456. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  121457. /**
  121458. * Gets stiffness of the impostor
  121459. * @param impostor impostor to get stiffness from
  121460. * @returns pressure value
  121461. */
  121462. getBodyStiffness(impostor: PhysicsImpostor): number;
  121463. /**
  121464. * Sets stiffness of the impostor
  121465. * @param impostor impostor to set stiffness on
  121466. * @param stiffness stiffness value from 0 to 1
  121467. */
  121468. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  121469. /**
  121470. * Gets velocityIterations of the impostor
  121471. * @param impostor impostor to get velocity iterations from
  121472. * @returns velocityIterations value
  121473. */
  121474. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  121475. /**
  121476. * Sets velocityIterations of the impostor
  121477. * @param impostor impostor to set velocity iterations on
  121478. * @param velocityIterations velocityIterations value
  121479. */
  121480. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  121481. /**
  121482. * Gets positionIterations of the impostor
  121483. * @param impostor impostor to get position iterations from
  121484. * @returns positionIterations value
  121485. */
  121486. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  121487. /**
  121488. * Sets positionIterations of the impostor
  121489. * @param impostor impostor to set position on
  121490. * @param positionIterations positionIterations value
  121491. */
  121492. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  121493. /**
  121494. * Append an anchor to a cloth object
  121495. * @param impostor is the cloth impostor to add anchor to
  121496. * @param otherImpostor is the rigid impostor to anchor to
  121497. * @param width ratio across width from 0 to 1
  121498. * @param height ratio up height from 0 to 1
  121499. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  121500. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121501. */
  121502. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121503. /**
  121504. * Append an hook to a rope object
  121505. * @param impostor is the rope impostor to add hook to
  121506. * @param otherImpostor is the rigid impostor to hook to
  121507. * @param length ratio along the rope from 0 to 1
  121508. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  121509. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  121510. */
  121511. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  121512. /**
  121513. * Sleeps the physics body and stops it from being active
  121514. * @param impostor impostor to sleep
  121515. */
  121516. sleepBody(impostor: PhysicsImpostor): void;
  121517. /**
  121518. * Activates the physics body
  121519. * @param impostor impostor to activate
  121520. */
  121521. wakeUpBody(impostor: PhysicsImpostor): void;
  121522. /**
  121523. * Updates the distance parameters of the joint
  121524. * @param joint joint to update
  121525. * @param maxDistance maximum distance of the joint
  121526. * @param minDistance minimum distance of the joint
  121527. */
  121528. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121529. /**
  121530. * Sets a motor on the joint
  121531. * @param joint joint to set motor on
  121532. * @param speed speed of the motor
  121533. * @param maxForce maximum force of the motor
  121534. * @param motorIndex index of the motor
  121535. */
  121536. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121537. /**
  121538. * Sets the motors limit
  121539. * @param joint joint to set limit on
  121540. * @param upperLimit upper limit
  121541. * @param lowerLimit lower limit
  121542. */
  121543. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121544. /**
  121545. * Syncs the position and rotation of a mesh with the impostor
  121546. * @param mesh mesh to sync
  121547. * @param impostor impostor to update the mesh with
  121548. */
  121549. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121550. /**
  121551. * Gets the radius of the impostor
  121552. * @param impostor impostor to get radius from
  121553. * @returns the radius
  121554. */
  121555. getRadius(impostor: PhysicsImpostor): number;
  121556. /**
  121557. * Gets the box size of the impostor
  121558. * @param impostor impostor to get box size from
  121559. * @param result the resulting box size
  121560. */
  121561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121562. /**
  121563. * Disposes of the impostor
  121564. */
  121565. dispose(): void;
  121566. /**
  121567. * Does a raycast in the physics world
  121568. * @param from when should the ray start?
  121569. * @param to when should the ray end?
  121570. * @returns PhysicsRaycastResult
  121571. */
  121572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121573. }
  121574. }
  121575. declare module BABYLON {
  121576. interface AbstractScene {
  121577. /**
  121578. * The list of reflection probes added to the scene
  121579. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121580. */
  121581. reflectionProbes: Array<ReflectionProbe>;
  121582. /**
  121583. * Removes the given reflection probe from this scene.
  121584. * @param toRemove The reflection probe to remove
  121585. * @returns The index of the removed reflection probe
  121586. */
  121587. removeReflectionProbe(toRemove: ReflectionProbe): number;
  121588. /**
  121589. * Adds the given reflection probe to this scene.
  121590. * @param newReflectionProbe The reflection probe to add
  121591. */
  121592. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  121593. }
  121594. /**
  121595. * Class used to generate realtime reflection / refraction cube textures
  121596. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  121597. */
  121598. export class ReflectionProbe {
  121599. /** defines the name of the probe */
  121600. name: string;
  121601. private _scene;
  121602. private _renderTargetTexture;
  121603. private _projectionMatrix;
  121604. private _viewMatrix;
  121605. private _target;
  121606. private _add;
  121607. private _attachedMesh;
  121608. private _invertYAxis;
  121609. /** Gets or sets probe position (center of the cube map) */
  121610. position: Vector3;
  121611. /**
  121612. * Creates a new reflection probe
  121613. * @param name defines the name of the probe
  121614. * @param size defines the texture resolution (for each face)
  121615. * @param scene defines the hosting scene
  121616. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  121617. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  121618. */
  121619. constructor(
  121620. /** defines the name of the probe */
  121621. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  121622. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  121623. samples: number;
  121624. /** Gets or sets the refresh rate to use (on every frame by default) */
  121625. refreshRate: number;
  121626. /**
  121627. * Gets the hosting scene
  121628. * @returns a Scene
  121629. */
  121630. getScene(): Scene;
  121631. /** Gets the internal CubeTexture used to render to */
  121632. readonly cubeTexture: RenderTargetTexture;
  121633. /** Gets the list of meshes to render */
  121634. readonly renderList: Nullable<AbstractMesh[]>;
  121635. /**
  121636. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  121637. * @param mesh defines the mesh to attach to
  121638. */
  121639. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121640. /**
  121641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  121642. * @param renderingGroupId The rendering group id corresponding to its index
  121643. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121644. */
  121645. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  121646. /**
  121647. * Clean all associated resources
  121648. */
  121649. dispose(): void;
  121650. /**
  121651. * Converts the reflection probe information to a readable string for debug purpose.
  121652. * @param fullDetails Supports for multiple levels of logging within scene loading
  121653. * @returns the human readable reflection probe info
  121654. */
  121655. toString(fullDetails?: boolean): string;
  121656. /**
  121657. * Get the class name of the relfection probe.
  121658. * @returns "ReflectionProbe"
  121659. */
  121660. getClassName(): string;
  121661. /**
  121662. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  121663. * @returns The JSON representation of the texture
  121664. */
  121665. serialize(): any;
  121666. /**
  121667. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  121668. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  121669. * @param scene Define the scene the parsed reflection probe should be instantiated in
  121670. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  121671. * @returns The parsed reflection probe if successful
  121672. */
  121673. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. /** @hidden */
  121678. export var _BabylonLoaderRegistered: boolean;
  121679. /**
  121680. * Helps setting up some configuration for the babylon file loader.
  121681. */
  121682. export class BabylonFileLoaderConfiguration {
  121683. /**
  121684. * The loader does not allow injecting custom physix engine into the plugins.
  121685. * Unfortunately in ES6, we need to manually inject them into the plugin.
  121686. * So you could set this variable to your engine import to make it work.
  121687. */
  121688. static LoaderInjectedPhysicsEngine: any;
  121689. }
  121690. }
  121691. declare module BABYLON {
  121692. /**
  121693. * The Physically based simple base material of BJS.
  121694. *
  121695. * This enables better naming and convention enforcements on top of the pbrMaterial.
  121696. * It is used as the base class for both the specGloss and metalRough conventions.
  121697. */
  121698. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  121699. /**
  121700. * Number of Simultaneous lights allowed on the material.
  121701. */
  121702. maxSimultaneousLights: number;
  121703. /**
  121704. * If sets to true, disables all the lights affecting the material.
  121705. */
  121706. disableLighting: boolean;
  121707. /**
  121708. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  121709. */
  121710. environmentTexture: BaseTexture;
  121711. /**
  121712. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121713. */
  121714. invertNormalMapX: boolean;
  121715. /**
  121716. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121717. */
  121718. invertNormalMapY: boolean;
  121719. /**
  121720. * Normal map used in the model.
  121721. */
  121722. normalTexture: BaseTexture;
  121723. /**
  121724. * Emissivie color used to self-illuminate the model.
  121725. */
  121726. emissiveColor: Color3;
  121727. /**
  121728. * Emissivie texture used to self-illuminate the model.
  121729. */
  121730. emissiveTexture: BaseTexture;
  121731. /**
  121732. * Occlusion Channel Strenght.
  121733. */
  121734. occlusionStrength: number;
  121735. /**
  121736. * Occlusion Texture of the material (adding extra occlusion effects).
  121737. */
  121738. occlusionTexture: BaseTexture;
  121739. /**
  121740. * Defines the alpha limits in alpha test mode.
  121741. */
  121742. alphaCutOff: number;
  121743. /**
  121744. * Gets the current double sided mode.
  121745. */
  121746. /**
  121747. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121748. */
  121749. doubleSided: boolean;
  121750. /**
  121751. * Stores the pre-calculated light information of a mesh in a texture.
  121752. */
  121753. lightmapTexture: BaseTexture;
  121754. /**
  121755. * If true, the light map contains occlusion information instead of lighting info.
  121756. */
  121757. useLightmapAsShadowmap: boolean;
  121758. /**
  121759. * Instantiates a new PBRMaterial instance.
  121760. *
  121761. * @param name The material name
  121762. * @param scene The scene the material will be use in.
  121763. */
  121764. constructor(name: string, scene: Scene);
  121765. getClassName(): string;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * The PBR material of BJS following the metal roughness convention.
  121771. *
  121772. * This fits to the PBR convention in the GLTF definition:
  121773. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  121774. */
  121775. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  121776. /**
  121777. * The base color has two different interpretations depending on the value of metalness.
  121778. * When the material is a metal, the base color is the specific measured reflectance value
  121779. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  121780. * of the material.
  121781. */
  121782. baseColor: Color3;
  121783. /**
  121784. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  121785. * well as opacity information in the alpha channel.
  121786. */
  121787. baseTexture: BaseTexture;
  121788. /**
  121789. * Specifies the metallic scalar value of the material.
  121790. * Can also be used to scale the metalness values of the metallic texture.
  121791. */
  121792. metallic: number;
  121793. /**
  121794. * Specifies the roughness scalar value of the material.
  121795. * Can also be used to scale the roughness values of the metallic texture.
  121796. */
  121797. roughness: number;
  121798. /**
  121799. * Texture containing both the metallic value in the B channel and the
  121800. * roughness value in the G channel to keep better precision.
  121801. */
  121802. metallicRoughnessTexture: BaseTexture;
  121803. /**
  121804. * Instantiates a new PBRMetalRoughnessMaterial instance.
  121805. *
  121806. * @param name The material name
  121807. * @param scene The scene the material will be use in.
  121808. */
  121809. constructor(name: string, scene: Scene);
  121810. /**
  121811. * Return the currrent class name of the material.
  121812. */
  121813. getClassName(): string;
  121814. /**
  121815. * Makes a duplicate of the current material.
  121816. * @param name - name to use for the new material.
  121817. */
  121818. clone(name: string): PBRMetallicRoughnessMaterial;
  121819. /**
  121820. * Serialize the material to a parsable JSON object.
  121821. */
  121822. serialize(): any;
  121823. /**
  121824. * Parses a JSON object correponding to the serialize function.
  121825. */
  121826. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121827. }
  121828. }
  121829. declare module BABYLON {
  121830. /**
  121831. * The PBR material of BJS following the specular glossiness convention.
  121832. *
  121833. * This fits to the PBR convention in the GLTF definition:
  121834. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121835. */
  121836. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121837. /**
  121838. * Specifies the diffuse color of the material.
  121839. */
  121840. diffuseColor: Color3;
  121841. /**
  121842. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121843. * channel.
  121844. */
  121845. diffuseTexture: BaseTexture;
  121846. /**
  121847. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121848. */
  121849. specularColor: Color3;
  121850. /**
  121851. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121852. */
  121853. glossiness: number;
  121854. /**
  121855. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121856. */
  121857. specularGlossinessTexture: BaseTexture;
  121858. /**
  121859. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121860. *
  121861. * @param name The material name
  121862. * @param scene The scene the material will be use in.
  121863. */
  121864. constructor(name: string, scene: Scene);
  121865. /**
  121866. * Return the currrent class name of the material.
  121867. */
  121868. getClassName(): string;
  121869. /**
  121870. * Makes a duplicate of the current material.
  121871. * @param name - name to use for the new material.
  121872. */
  121873. clone(name: string): PBRSpecularGlossinessMaterial;
  121874. /**
  121875. * Serialize the material to a parsable JSON object.
  121876. */
  121877. serialize(): any;
  121878. /**
  121879. * Parses a JSON object correponding to the serialize function.
  121880. */
  121881. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121887. * It can help converting any input color in a desired output one. This can then be used to create effects
  121888. * from sepia, black and white to sixties or futuristic rendering...
  121889. *
  121890. * The only supported format is currently 3dl.
  121891. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121892. */
  121893. export class ColorGradingTexture extends BaseTexture {
  121894. /**
  121895. * The current texture matrix. (will always be identity in color grading texture)
  121896. */
  121897. private _textureMatrix;
  121898. /**
  121899. * The texture URL.
  121900. */
  121901. url: string;
  121902. /**
  121903. * Empty line regex stored for GC.
  121904. */
  121905. private static _noneEmptyLineRegex;
  121906. private _engine;
  121907. /**
  121908. * Instantiates a ColorGradingTexture from the following parameters.
  121909. *
  121910. * @param url The location of the color gradind data (currently only supporting 3dl)
  121911. * @param scene The scene the texture will be used in
  121912. */
  121913. constructor(url: string, scene: Scene);
  121914. /**
  121915. * Returns the texture matrix used in most of the material.
  121916. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121917. */
  121918. getTextureMatrix(): Matrix;
  121919. /**
  121920. * Occurs when the file being loaded is a .3dl LUT file.
  121921. */
  121922. private load3dlTexture;
  121923. /**
  121924. * Starts the loading process of the texture.
  121925. */
  121926. private loadTexture;
  121927. /**
  121928. * Clones the color gradind texture.
  121929. */
  121930. clone(): ColorGradingTexture;
  121931. /**
  121932. * Called during delayed load for textures.
  121933. */
  121934. delayLoad(): void;
  121935. /**
  121936. * Parses a color grading texture serialized by Babylon.
  121937. * @param parsedTexture The texture information being parsedTexture
  121938. * @param scene The scene to load the texture in
  121939. * @param rootUrl The root url of the data assets to load
  121940. * @return A color gradind texture
  121941. */
  121942. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121943. /**
  121944. * Serializes the LUT texture to json format.
  121945. */
  121946. serialize(): any;
  121947. }
  121948. }
  121949. declare module BABYLON {
  121950. /**
  121951. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121952. */
  121953. export class EquiRectangularCubeTexture extends BaseTexture {
  121954. /** The six faces of the cube. */
  121955. private static _FacesMapping;
  121956. private _noMipmap;
  121957. private _onLoad;
  121958. private _onError;
  121959. /** The size of the cubemap. */
  121960. private _size;
  121961. /** The buffer of the image. */
  121962. private _buffer;
  121963. /** The width of the input image. */
  121964. private _width;
  121965. /** The height of the input image. */
  121966. private _height;
  121967. /** The URL to the image. */
  121968. url: string;
  121969. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121970. coordinatesMode: number;
  121971. /**
  121972. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121973. * @param url The location of the image
  121974. * @param scene The scene the texture will be used in
  121975. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121976. * @param noMipmap Forces to not generate the mipmap if true
  121977. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121978. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121979. * @param onLoad — defines a callback called when texture is loaded
  121980. * @param onError — defines a callback called if there is an error
  121981. */
  121982. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121983. /**
  121984. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121985. */
  121986. private loadImage;
  121987. /**
  121988. * Convert the image buffer into a cubemap and create a CubeTexture.
  121989. */
  121990. private loadTexture;
  121991. /**
  121992. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121993. * @param buffer The ArrayBuffer that should be converted.
  121994. * @returns The buffer as Float32Array.
  121995. */
  121996. private getFloat32ArrayFromArrayBuffer;
  121997. /**
  121998. * Get the current class name of the texture useful for serialization or dynamic coding.
  121999. * @returns "EquiRectangularCubeTexture"
  122000. */
  122001. getClassName(): string;
  122002. /**
  122003. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122004. * @returns A clone of the current EquiRectangularCubeTexture.
  122005. */
  122006. clone(): EquiRectangularCubeTexture;
  122007. }
  122008. }
  122009. declare module BABYLON {
  122010. /**
  122011. * Based on jsTGALoader - Javascript loader for TGA file
  122012. * By Vincent Thibault
  122013. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122014. */
  122015. export class TGATools {
  122016. private static _TYPE_INDEXED;
  122017. private static _TYPE_RGB;
  122018. private static _TYPE_GREY;
  122019. private static _TYPE_RLE_INDEXED;
  122020. private static _TYPE_RLE_RGB;
  122021. private static _TYPE_RLE_GREY;
  122022. private static _ORIGIN_MASK;
  122023. private static _ORIGIN_SHIFT;
  122024. private static _ORIGIN_BL;
  122025. private static _ORIGIN_BR;
  122026. private static _ORIGIN_UL;
  122027. private static _ORIGIN_UR;
  122028. /**
  122029. * Gets the header of a TGA file
  122030. * @param data defines the TGA data
  122031. * @returns the header
  122032. */
  122033. static GetTGAHeader(data: Uint8Array): any;
  122034. /**
  122035. * Uploads TGA content to a Babylon Texture
  122036. * @hidden
  122037. */
  122038. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122039. /** @hidden */
  122040. 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;
  122041. /** @hidden */
  122042. 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;
  122043. /** @hidden */
  122044. 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;
  122045. /** @hidden */
  122046. 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;
  122047. /** @hidden */
  122048. 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;
  122049. /** @hidden */
  122050. 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;
  122051. }
  122052. }
  122053. declare module BABYLON {
  122054. /**
  122055. * Implementation of the TGA Texture Loader.
  122056. * @hidden
  122057. */
  122058. export class _TGATextureLoader implements IInternalTextureLoader {
  122059. /**
  122060. * Defines wether the loader supports cascade loading the different faces.
  122061. */
  122062. readonly supportCascades: boolean;
  122063. /**
  122064. * This returns if the loader support the current file information.
  122065. * @param extension defines the file extension of the file being loaded
  122066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122067. * @param fallback defines the fallback internal texture if any
  122068. * @param isBase64 defines whether the texture is encoded as a base64
  122069. * @param isBuffer defines whether the texture data are stored as a buffer
  122070. * @returns true if the loader can load the specified file
  122071. */
  122072. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122073. /**
  122074. * Transform the url before loading if required.
  122075. * @param rootUrl the url of the texture
  122076. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122077. * @returns the transformed texture
  122078. */
  122079. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122080. /**
  122081. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122082. * @param rootUrl the url of the texture
  122083. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122084. * @returns the fallback texture
  122085. */
  122086. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122087. /**
  122088. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122089. * @param data contains the texture data
  122090. * @param texture defines the BabylonJS internal texture
  122091. * @param createPolynomials will be true if polynomials have been requested
  122092. * @param onLoad defines the callback to trigger once the texture is ready
  122093. * @param onError defines the callback to trigger in case of error
  122094. */
  122095. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122096. /**
  122097. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122098. * @param data contains the texture data
  122099. * @param texture defines the BabylonJS internal texture
  122100. * @param callback defines the method to call once ready to upload
  122101. */
  122102. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122103. }
  122104. }
  122105. declare module BABYLON {
  122106. /**
  122107. * Info about the .basis files
  122108. */
  122109. class BasisFileInfo {
  122110. /**
  122111. * If the file has alpha
  122112. */
  122113. hasAlpha: boolean;
  122114. /**
  122115. * Info about each image of the basis file
  122116. */
  122117. images: Array<{
  122118. levels: Array<{
  122119. width: number;
  122120. height: number;
  122121. transcodedPixels: ArrayBufferView;
  122122. }>;
  122123. }>;
  122124. }
  122125. /**
  122126. * Result of transcoding a basis file
  122127. */
  122128. class TranscodeResult {
  122129. /**
  122130. * Info about the .basis file
  122131. */
  122132. fileInfo: BasisFileInfo;
  122133. /**
  122134. * Format to use when loading the file
  122135. */
  122136. format: number;
  122137. }
  122138. /**
  122139. * Configuration options for the Basis transcoder
  122140. */
  122141. export class BasisTranscodeConfiguration {
  122142. /**
  122143. * Supported compression formats used to determine the supported output format of the transcoder
  122144. */
  122145. supportedCompressionFormats?: {
  122146. /**
  122147. * etc1 compression format
  122148. */
  122149. etc1?: boolean;
  122150. /**
  122151. * s3tc compression format
  122152. */
  122153. s3tc?: boolean;
  122154. /**
  122155. * pvrtc compression format
  122156. */
  122157. pvrtc?: boolean;
  122158. /**
  122159. * etc2 compression format
  122160. */
  122161. etc2?: boolean;
  122162. };
  122163. /**
  122164. * If mipmap levels should be loaded for transcoded images (Default: true)
  122165. */
  122166. loadMipmapLevels?: boolean;
  122167. /**
  122168. * Index of a single image to load (Default: all images)
  122169. */
  122170. loadSingleImage?: number;
  122171. }
  122172. /**
  122173. * Used to load .Basis files
  122174. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122175. */
  122176. export class BasisTools {
  122177. private static _IgnoreSupportedFormats;
  122178. /**
  122179. * URL to use when loading the basis transcoder
  122180. */
  122181. static JSModuleURL: string;
  122182. /**
  122183. * URL to use when loading the wasm module for the transcoder
  122184. */
  122185. static WasmModuleURL: string;
  122186. /**
  122187. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122188. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122189. * @returns internal format corresponding to the Basis format
  122190. */
  122191. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122192. private static _WorkerPromise;
  122193. private static _Worker;
  122194. private static _actionId;
  122195. private static _CreateWorkerAsync;
  122196. /**
  122197. * Transcodes a loaded image file to compressed pixel data
  122198. * @param imageData image data to transcode
  122199. * @param config configuration options for the transcoding
  122200. * @returns a promise resulting in the transcoded image
  122201. */
  122202. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122203. /**
  122204. * Loads a texture from the transcode result
  122205. * @param texture texture load to
  122206. * @param transcodeResult the result of transcoding the basis file to load from
  122207. */
  122208. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122209. }
  122210. }
  122211. declare module BABYLON {
  122212. /**
  122213. * Loader for .basis file format
  122214. */
  122215. export class _BasisTextureLoader implements IInternalTextureLoader {
  122216. /**
  122217. * Defines whether the loader supports cascade loading the different faces.
  122218. */
  122219. readonly supportCascades: boolean;
  122220. /**
  122221. * This returns if the loader support the current file information.
  122222. * @param extension defines the file extension of the file being loaded
  122223. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122224. * @param fallback defines the fallback internal texture if any
  122225. * @param isBase64 defines whether the texture is encoded as a base64
  122226. * @param isBuffer defines whether the texture data are stored as a buffer
  122227. * @returns true if the loader can load the specified file
  122228. */
  122229. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122230. /**
  122231. * Transform the url before loading if required.
  122232. * @param rootUrl the url of the texture
  122233. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122234. * @returns the transformed texture
  122235. */
  122236. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122237. /**
  122238. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122239. * @param rootUrl the url of the texture
  122240. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122241. * @returns the fallback texture
  122242. */
  122243. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122244. /**
  122245. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122246. * @param data contains the texture data
  122247. * @param texture defines the BabylonJS internal texture
  122248. * @param createPolynomials will be true if polynomials have been requested
  122249. * @param onLoad defines the callback to trigger once the texture is ready
  122250. * @param onError defines the callback to trigger in case of error
  122251. */
  122252. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122253. /**
  122254. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122255. * @param data contains the texture data
  122256. * @param texture defines the BabylonJS internal texture
  122257. * @param callback defines the method to call once ready to upload
  122258. */
  122259. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122260. }
  122261. }
  122262. declare module BABYLON {
  122263. /**
  122264. * 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.
  122265. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122266. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122267. */
  122268. export class CustomProceduralTexture extends ProceduralTexture {
  122269. private _animate;
  122270. private _time;
  122271. private _config;
  122272. private _texturePath;
  122273. /**
  122274. * Instantiates a new Custom Procedural Texture.
  122275. * 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.
  122276. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122277. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122278. * @param name Define the name of the texture
  122279. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122280. * @param size Define the size of the texture to create
  122281. * @param scene Define the scene the texture belongs to
  122282. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122283. * @param generateMipMaps Define if the texture should creates mip maps or not
  122284. */
  122285. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122286. private _loadJson;
  122287. /**
  122288. * Is the texture ready to be used ? (rendered at least once)
  122289. * @returns true if ready, otherwise, false.
  122290. */
  122291. isReady(): boolean;
  122292. /**
  122293. * Render the texture to its associated render target.
  122294. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122295. */
  122296. render(useCameraPostProcess?: boolean): void;
  122297. /**
  122298. * Update the list of dependant textures samplers in the shader.
  122299. */
  122300. updateTextures(): void;
  122301. /**
  122302. * Update the uniform values of the procedural texture in the shader.
  122303. */
  122304. updateShaderUniforms(): void;
  122305. /**
  122306. * Define if the texture animates or not.
  122307. */
  122308. animate: boolean;
  122309. }
  122310. }
  122311. declare module BABYLON {
  122312. /** @hidden */
  122313. export var noisePixelShader: {
  122314. name: string;
  122315. shader: string;
  122316. };
  122317. }
  122318. declare module BABYLON {
  122319. /**
  122320. * Class used to generate noise procedural textures
  122321. */
  122322. export class NoiseProceduralTexture extends ProceduralTexture {
  122323. private _time;
  122324. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122325. brightness: number;
  122326. /** Defines the number of octaves to process */
  122327. octaves: number;
  122328. /** Defines the level of persistence (0.8 by default) */
  122329. persistence: number;
  122330. /** Gets or sets animation speed factor (default is 1) */
  122331. animationSpeedFactor: number;
  122332. /**
  122333. * Creates a new NoiseProceduralTexture
  122334. * @param name defines the name fo the texture
  122335. * @param size defines the size of the texture (default is 256)
  122336. * @param scene defines the hosting scene
  122337. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122338. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122339. */
  122340. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122341. private _updateShaderUniforms;
  122342. protected _getDefines(): string;
  122343. /** Generate the current state of the procedural texture */
  122344. render(useCameraPostProcess?: boolean): void;
  122345. /**
  122346. * Serializes this noise procedural texture
  122347. * @returns a serialized noise procedural texture object
  122348. */
  122349. serialize(): any;
  122350. /**
  122351. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  122352. * @param parsedTexture defines parsed texture data
  122353. * @param scene defines the current scene
  122354. * @param rootUrl defines the root URL containing noise procedural texture information
  122355. * @returns a parsed NoiseProceduralTexture
  122356. */
  122357. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  122358. }
  122359. }
  122360. declare module BABYLON {
  122361. /**
  122362. * Raw cube texture where the raw buffers are passed in
  122363. */
  122364. export class RawCubeTexture extends CubeTexture {
  122365. /**
  122366. * Creates a cube texture where the raw buffers are passed in.
  122367. * @param scene defines the scene the texture is attached to
  122368. * @param data defines the array of data to use to create each face
  122369. * @param size defines the size of the textures
  122370. * @param format defines the format of the data
  122371. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  122372. * @param generateMipMaps defines if the engine should generate the mip levels
  122373. * @param invertY defines if data must be stored with Y axis inverted
  122374. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  122375. * @param compression defines the compression used (null by default)
  122376. */
  122377. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  122378. /**
  122379. * Updates the raw cube texture.
  122380. * @param data defines the data to store
  122381. * @param format defines the data format
  122382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122383. * @param invertY defines if data must be stored with Y axis inverted
  122384. * @param compression defines the compression used (null by default)
  122385. * @param level defines which level of the texture to update
  122386. */
  122387. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  122388. /**
  122389. * Updates a raw cube texture with RGBD encoded data.
  122390. * @param data defines the array of data [mipmap][face] to use to create each face
  122391. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  122392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122394. * @returns a promsie that resolves when the operation is complete
  122395. */
  122396. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  122397. /**
  122398. * Clones the raw cube texture.
  122399. * @return a new cube texture
  122400. */
  122401. clone(): CubeTexture;
  122402. /** @hidden */
  122403. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122404. }
  122405. }
  122406. declare module BABYLON {
  122407. /**
  122408. * Class used to store 3D textures containing user data
  122409. */
  122410. export class RawTexture3D extends Texture {
  122411. /** Gets or sets the texture format to use */
  122412. format: number;
  122413. private _engine;
  122414. /**
  122415. * Create a new RawTexture3D
  122416. * @param data defines the data of the texture
  122417. * @param width defines the width of the texture
  122418. * @param height defines the height of the texture
  122419. * @param depth defines the depth of the texture
  122420. * @param format defines the texture format to use
  122421. * @param scene defines the hosting scene
  122422. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122423. * @param invertY defines if texture must be stored with Y axis inverted
  122424. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122425. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122426. */
  122427. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122428. /** Gets or sets the texture format to use */
  122429. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122430. /**
  122431. * Update the texture with new data
  122432. * @param data defines the data to store in the texture
  122433. */
  122434. update(data: ArrayBufferView): void;
  122435. }
  122436. }
  122437. declare module BABYLON {
  122438. /**
  122439. * Class used to store 2D array textures containing user data
  122440. */
  122441. export class RawTexture2DArray extends Texture {
  122442. /** Gets or sets the texture format to use */
  122443. format: number;
  122444. private _engine;
  122445. /**
  122446. * Create a new RawTexture2DArray
  122447. * @param data defines the data of the texture
  122448. * @param width defines the width of the texture
  122449. * @param height defines the height of the texture
  122450. * @param depth defines the number of layers of the texture
  122451. * @param format defines the texture format to use
  122452. * @param scene defines the hosting scene
  122453. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  122454. * @param invertY defines if texture must be stored with Y axis inverted
  122455. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  122456. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  122457. */
  122458. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  122459. /** Gets or sets the texture format to use */
  122460. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  122461. /**
  122462. * Update the texture with new data
  122463. * @param data defines the data to store in the texture
  122464. */
  122465. update(data: ArrayBufferView): void;
  122466. }
  122467. }
  122468. declare module BABYLON {
  122469. /**
  122470. * Creates a refraction texture used by refraction channel of the standard material.
  122471. * It is like a mirror but to see through a material.
  122472. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122473. */
  122474. export class RefractionTexture extends RenderTargetTexture {
  122475. /**
  122476. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  122477. * 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.
  122478. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122479. */
  122480. refractionPlane: Plane;
  122481. /**
  122482. * Define how deep under the surface we should see.
  122483. */
  122484. depth: number;
  122485. /**
  122486. * Creates a refraction texture used by refraction channel of the standard material.
  122487. * It is like a mirror but to see through a material.
  122488. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  122489. * @param name Define the texture name
  122490. * @param size Define the size of the underlying texture
  122491. * @param scene Define the scene the refraction belongs to
  122492. * @param generateMipMaps Define if we need to generate mips level for the refraction
  122493. */
  122494. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  122495. /**
  122496. * Clone the refraction texture.
  122497. * @returns the cloned texture
  122498. */
  122499. clone(): RefractionTexture;
  122500. /**
  122501. * Serialize the texture to a JSON representation you could use in Parse later on
  122502. * @returns the serialized JSON representation
  122503. */
  122504. serialize(): any;
  122505. }
  122506. }
  122507. declare module BABYLON {
  122508. /**
  122509. * Defines the options related to the creation of an HtmlElementTexture
  122510. */
  122511. export interface IHtmlElementTextureOptions {
  122512. /**
  122513. * Defines wether mip maps should be created or not.
  122514. */
  122515. generateMipMaps?: boolean;
  122516. /**
  122517. * Defines the sampling mode of the texture.
  122518. */
  122519. samplingMode?: number;
  122520. /**
  122521. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  122522. */
  122523. engine: Nullable<ThinEngine>;
  122524. /**
  122525. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  122526. */
  122527. scene: Nullable<Scene>;
  122528. }
  122529. /**
  122530. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  122531. * To be as efficient as possible depending on your constraints nothing aside the first upload
  122532. * is automatically managed.
  122533. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  122534. * in your application.
  122535. *
  122536. * As the update is not automatic, you need to call them manually.
  122537. */
  122538. export class HtmlElementTexture extends BaseTexture {
  122539. /**
  122540. * The texture URL.
  122541. */
  122542. element: HTMLVideoElement | HTMLCanvasElement;
  122543. private static readonly DefaultOptions;
  122544. private _textureMatrix;
  122545. private _engine;
  122546. private _isVideo;
  122547. private _generateMipMaps;
  122548. private _samplingMode;
  122549. /**
  122550. * Instantiates a HtmlElementTexture from the following parameters.
  122551. *
  122552. * @param name Defines the name of the texture
  122553. * @param element Defines the video or canvas the texture is filled with
  122554. * @param options Defines the other none mandatory texture creation options
  122555. */
  122556. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  122557. private _createInternalTexture;
  122558. /**
  122559. * Returns the texture matrix used in most of the material.
  122560. */
  122561. getTextureMatrix(): Matrix;
  122562. /**
  122563. * Updates the content of the texture.
  122564. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  122565. */
  122566. update(invertY?: Nullable<boolean>): void;
  122567. }
  122568. }
  122569. declare module BABYLON {
  122570. /**
  122571. * Enum used to define the target of a block
  122572. */
  122573. export enum NodeMaterialBlockTargets {
  122574. /** Vertex shader */
  122575. Vertex = 1,
  122576. /** Fragment shader */
  122577. Fragment = 2,
  122578. /** Neutral */
  122579. Neutral = 4,
  122580. /** Vertex and Fragment */
  122581. VertexAndFragment = 3
  122582. }
  122583. }
  122584. declare module BABYLON {
  122585. /**
  122586. * Defines the kind of connection point for node based material
  122587. */
  122588. export enum NodeMaterialBlockConnectionPointTypes {
  122589. /** Float */
  122590. Float = 1,
  122591. /** Int */
  122592. Int = 2,
  122593. /** Vector2 */
  122594. Vector2 = 4,
  122595. /** Vector3 */
  122596. Vector3 = 8,
  122597. /** Vector4 */
  122598. Vector4 = 16,
  122599. /** Color3 */
  122600. Color3 = 32,
  122601. /** Color4 */
  122602. Color4 = 64,
  122603. /** Matrix */
  122604. Matrix = 128,
  122605. /** Detect type based on connection */
  122606. AutoDetect = 1024,
  122607. /** Output type that will be defined by input type */
  122608. BasedOnInput = 2048
  122609. }
  122610. }
  122611. declare module BABYLON {
  122612. /**
  122613. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  122614. */
  122615. export enum NodeMaterialBlockConnectionPointMode {
  122616. /** Value is an uniform */
  122617. Uniform = 0,
  122618. /** Value is a mesh attribute */
  122619. Attribute = 1,
  122620. /** Value is a varying between vertex and fragment shaders */
  122621. Varying = 2,
  122622. /** Mode is undefined */
  122623. Undefined = 3
  122624. }
  122625. }
  122626. declare module BABYLON {
  122627. /**
  122628. * Enum used to define system values e.g. values automatically provided by the system
  122629. */
  122630. export enum NodeMaterialSystemValues {
  122631. /** World */
  122632. World = 1,
  122633. /** View */
  122634. View = 2,
  122635. /** Projection */
  122636. Projection = 3,
  122637. /** ViewProjection */
  122638. ViewProjection = 4,
  122639. /** WorldView */
  122640. WorldView = 5,
  122641. /** WorldViewProjection */
  122642. WorldViewProjection = 6,
  122643. /** CameraPosition */
  122644. CameraPosition = 7,
  122645. /** Fog Color */
  122646. FogColor = 8,
  122647. /** Delta time */
  122648. DeltaTime = 9
  122649. }
  122650. }
  122651. declare module BABYLON {
  122652. /**
  122653. * Root class for all node material optimizers
  122654. */
  122655. export class NodeMaterialOptimizer {
  122656. /**
  122657. * Function used to optimize a NodeMaterial graph
  122658. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  122659. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  122660. */
  122661. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /**
  122666. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  122667. */
  122668. export class TransformBlock extends NodeMaterialBlock {
  122669. /**
  122670. * Defines the value to use to complement W value to transform it to a Vector4
  122671. */
  122672. complementW: number;
  122673. /**
  122674. * Defines the value to use to complement z value to transform it to a Vector4
  122675. */
  122676. complementZ: number;
  122677. /**
  122678. * Creates a new TransformBlock
  122679. * @param name defines the block name
  122680. */
  122681. constructor(name: string);
  122682. /**
  122683. * Gets the current class name
  122684. * @returns the class name
  122685. */
  122686. getClassName(): string;
  122687. /**
  122688. * Gets the vector input
  122689. */
  122690. readonly vector: NodeMaterialConnectionPoint;
  122691. /**
  122692. * Gets the output component
  122693. */
  122694. readonly output: NodeMaterialConnectionPoint;
  122695. /**
  122696. * Gets the matrix transform input
  122697. */
  122698. readonly transform: NodeMaterialConnectionPoint;
  122699. protected _buildBlock(state: NodeMaterialBuildState): this;
  122700. serialize(): any;
  122701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122702. protected _dumpPropertiesCode(): string;
  122703. }
  122704. }
  122705. declare module BABYLON {
  122706. /**
  122707. * Block used to output the vertex position
  122708. */
  122709. export class VertexOutputBlock extends NodeMaterialBlock {
  122710. /**
  122711. * Creates a new VertexOutputBlock
  122712. * @param name defines the block name
  122713. */
  122714. constructor(name: string);
  122715. /**
  122716. * Gets the current class name
  122717. * @returns the class name
  122718. */
  122719. getClassName(): string;
  122720. /**
  122721. * Gets the vector input component
  122722. */
  122723. readonly vector: NodeMaterialConnectionPoint;
  122724. protected _buildBlock(state: NodeMaterialBuildState): this;
  122725. }
  122726. }
  122727. declare module BABYLON {
  122728. /**
  122729. * Block used to output the final color
  122730. */
  122731. export class FragmentOutputBlock extends NodeMaterialBlock {
  122732. /**
  122733. * Create a new FragmentOutputBlock
  122734. * @param name defines the block name
  122735. */
  122736. constructor(name: string);
  122737. /**
  122738. * Gets the current class name
  122739. * @returns the class name
  122740. */
  122741. getClassName(): string;
  122742. /**
  122743. * Gets the rgba input component
  122744. */
  122745. readonly rgba: NodeMaterialConnectionPoint;
  122746. /**
  122747. * Gets the rgb input component
  122748. */
  122749. readonly rgb: NodeMaterialConnectionPoint;
  122750. /**
  122751. * Gets the a input component
  122752. */
  122753. readonly a: NodeMaterialConnectionPoint;
  122754. protected _buildBlock(state: NodeMaterialBuildState): this;
  122755. }
  122756. }
  122757. declare module BABYLON {
  122758. /**
  122759. * Block used to read a reflection texture from a sampler
  122760. */
  122761. export class ReflectionTextureBlock extends NodeMaterialBlock {
  122762. private _define3DName;
  122763. private _defineCubicName;
  122764. private _defineExplicitName;
  122765. private _defineProjectionName;
  122766. private _defineLocalCubicName;
  122767. private _defineSphericalName;
  122768. private _definePlanarName;
  122769. private _defineEquirectangularName;
  122770. private _defineMirroredEquirectangularFixedName;
  122771. private _defineEquirectangularFixedName;
  122772. private _defineSkyboxName;
  122773. private _cubeSamplerName;
  122774. private _2DSamplerName;
  122775. private _positionUVWName;
  122776. private _directionWName;
  122777. private _reflectionCoordsName;
  122778. private _reflection2DCoordsName;
  122779. private _reflectionColorName;
  122780. private _reflectionMatrixName;
  122781. /**
  122782. * Gets or sets the texture associated with the node
  122783. */
  122784. texture: Nullable<BaseTexture>;
  122785. /**
  122786. * Create a new TextureBlock
  122787. * @param name defines the block name
  122788. */
  122789. constructor(name: string);
  122790. /**
  122791. * Gets the current class name
  122792. * @returns the class name
  122793. */
  122794. getClassName(): string;
  122795. /**
  122796. * Gets the world position input component
  122797. */
  122798. readonly position: NodeMaterialConnectionPoint;
  122799. /**
  122800. * Gets the world position input component
  122801. */
  122802. readonly worldPosition: NodeMaterialConnectionPoint;
  122803. /**
  122804. * Gets the world normal input component
  122805. */
  122806. readonly worldNormal: NodeMaterialConnectionPoint;
  122807. /**
  122808. * Gets the world input component
  122809. */
  122810. readonly world: NodeMaterialConnectionPoint;
  122811. /**
  122812. * Gets the camera (or eye) position component
  122813. */
  122814. readonly cameraPosition: NodeMaterialConnectionPoint;
  122815. /**
  122816. * Gets the view input component
  122817. */
  122818. readonly view: NodeMaterialConnectionPoint;
  122819. /**
  122820. * Gets the rgb output component
  122821. */
  122822. readonly rgb: NodeMaterialConnectionPoint;
  122823. /**
  122824. * Gets the r output component
  122825. */
  122826. readonly r: NodeMaterialConnectionPoint;
  122827. /**
  122828. * Gets the g output component
  122829. */
  122830. readonly g: NodeMaterialConnectionPoint;
  122831. /**
  122832. * Gets the b output component
  122833. */
  122834. readonly b: NodeMaterialConnectionPoint;
  122835. autoConfigure(material: NodeMaterial): void;
  122836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122837. isReady(): boolean;
  122838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122839. private _injectVertexCode;
  122840. private _writeOutput;
  122841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122842. protected _dumpPropertiesCode(): string;
  122843. serialize(): any;
  122844. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122845. }
  122846. }
  122847. declare module BABYLON {
  122848. /**
  122849. * Interface used to configure the node material editor
  122850. */
  122851. export interface INodeMaterialEditorOptions {
  122852. /** Define the URl to load node editor script */
  122853. editorURL?: string;
  122854. }
  122855. /** @hidden */
  122856. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122857. /** BONES */
  122858. NUM_BONE_INFLUENCERS: number;
  122859. BonesPerMesh: number;
  122860. BONETEXTURE: boolean;
  122861. /** MORPH TARGETS */
  122862. MORPHTARGETS: boolean;
  122863. MORPHTARGETS_NORMAL: boolean;
  122864. MORPHTARGETS_TANGENT: boolean;
  122865. MORPHTARGETS_UV: boolean;
  122866. NUM_MORPH_INFLUENCERS: number;
  122867. /** IMAGE PROCESSING */
  122868. IMAGEPROCESSING: boolean;
  122869. VIGNETTE: boolean;
  122870. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122871. VIGNETTEBLENDMODEOPAQUE: boolean;
  122872. TONEMAPPING: boolean;
  122873. TONEMAPPING_ACES: boolean;
  122874. CONTRAST: boolean;
  122875. EXPOSURE: boolean;
  122876. COLORCURVES: boolean;
  122877. COLORGRADING: boolean;
  122878. COLORGRADING3D: boolean;
  122879. SAMPLER3DGREENDEPTH: boolean;
  122880. SAMPLER3DBGRMAP: boolean;
  122881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122882. /** MISC. */
  122883. BUMPDIRECTUV: number;
  122884. constructor();
  122885. setValue(name: string, value: boolean): void;
  122886. }
  122887. /**
  122888. * Class used to configure NodeMaterial
  122889. */
  122890. export interface INodeMaterialOptions {
  122891. /**
  122892. * Defines if blocks should emit comments
  122893. */
  122894. emitComments: boolean;
  122895. }
  122896. /**
  122897. * Class used to create a node based material built by assembling shader blocks
  122898. */
  122899. export class NodeMaterial extends PushMaterial {
  122900. private static _BuildIdGenerator;
  122901. private _options;
  122902. private _vertexCompilationState;
  122903. private _fragmentCompilationState;
  122904. private _sharedData;
  122905. private _buildId;
  122906. private _buildWasSuccessful;
  122907. private _cachedWorldViewMatrix;
  122908. private _cachedWorldViewProjectionMatrix;
  122909. private _optimizers;
  122910. private _animationFrame;
  122911. /** Define the URl to load node editor script */
  122912. static EditorURL: string;
  122913. private BJSNODEMATERIALEDITOR;
  122914. /** Get the inspector from bundle or global */
  122915. private _getGlobalNodeMaterialEditor;
  122916. /**
  122917. * Gets or sets data used by visual editor
  122918. * @see https://nme.babylonjs.com
  122919. */
  122920. editorData: any;
  122921. /**
  122922. * 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)
  122923. */
  122924. ignoreAlpha: boolean;
  122925. /**
  122926. * Defines the maximum number of lights that can be used in the material
  122927. */
  122928. maxSimultaneousLights: number;
  122929. /**
  122930. * Observable raised when the material is built
  122931. */
  122932. onBuildObservable: Observable<NodeMaterial>;
  122933. /**
  122934. * Gets or sets the root nodes of the material vertex shader
  122935. */
  122936. _vertexOutputNodes: NodeMaterialBlock[];
  122937. /**
  122938. * Gets or sets the root nodes of the material fragment (pixel) shader
  122939. */
  122940. _fragmentOutputNodes: NodeMaterialBlock[];
  122941. /** Gets or sets options to control the node material overall behavior */
  122942. options: INodeMaterialOptions;
  122943. /**
  122944. * Default configuration related to image processing available in the standard Material.
  122945. */
  122946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122947. /**
  122948. * Gets the image processing configuration used either in this material.
  122949. */
  122950. /**
  122951. * Sets the Default image processing configuration used either in the this material.
  122952. *
  122953. * If sets to null, the scene one is in use.
  122954. */
  122955. imageProcessingConfiguration: ImageProcessingConfiguration;
  122956. /**
  122957. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122958. */
  122959. attachedBlocks: NodeMaterialBlock[];
  122960. /**
  122961. * Create a new node based material
  122962. * @param name defines the material name
  122963. * @param scene defines the hosting scene
  122964. * @param options defines creation option
  122965. */
  122966. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122967. /**
  122968. * Gets the current class name of the material e.g. "NodeMaterial"
  122969. * @returns the class name
  122970. */
  122971. getClassName(): string;
  122972. /**
  122973. * Keep track of the image processing observer to allow dispose and replace.
  122974. */
  122975. private _imageProcessingObserver;
  122976. /**
  122977. * Attaches a new image processing configuration to the Standard Material.
  122978. * @param configuration
  122979. */
  122980. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122981. /**
  122982. * Get a block by its name
  122983. * @param name defines the name of the block to retrieve
  122984. * @returns the required block or null if not found
  122985. */
  122986. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122987. /**
  122988. * Get a block by its name
  122989. * @param predicate defines the predicate used to find the good candidate
  122990. * @returns the required block or null if not found
  122991. */
  122992. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122993. /**
  122994. * Get an input block by its name
  122995. * @param predicate defines the predicate used to find the good candidate
  122996. * @returns the required input block or null if not found
  122997. */
  122998. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122999. /**
  123000. * Gets the list of input blocks attached to this material
  123001. * @returns an array of InputBlocks
  123002. */
  123003. getInputBlocks(): InputBlock[];
  123004. /**
  123005. * Adds a new optimizer to the list of optimizers
  123006. * @param optimizer defines the optimizers to add
  123007. * @returns the current material
  123008. */
  123009. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123010. /**
  123011. * Remove an optimizer from the list of optimizers
  123012. * @param optimizer defines the optimizers to remove
  123013. * @returns the current material
  123014. */
  123015. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123016. /**
  123017. * Add a new block to the list of output nodes
  123018. * @param node defines the node to add
  123019. * @returns the current material
  123020. */
  123021. addOutputNode(node: NodeMaterialBlock): this;
  123022. /**
  123023. * Remove a block from the list of root nodes
  123024. * @param node defines the node to remove
  123025. * @returns the current material
  123026. */
  123027. removeOutputNode(node: NodeMaterialBlock): this;
  123028. private _addVertexOutputNode;
  123029. private _removeVertexOutputNode;
  123030. private _addFragmentOutputNode;
  123031. private _removeFragmentOutputNode;
  123032. /**
  123033. * Specifies if the material will require alpha blending
  123034. * @returns a boolean specifying if alpha blending is needed
  123035. */
  123036. needAlphaBlending(): boolean;
  123037. /**
  123038. * Specifies if this material should be rendered in alpha test mode
  123039. * @returns a boolean specifying if an alpha test is needed.
  123040. */
  123041. needAlphaTesting(): boolean;
  123042. private _initializeBlock;
  123043. private _resetDualBlocks;
  123044. /**
  123045. * Remove a block from the current node material
  123046. * @param block defines the block to remove
  123047. */
  123048. removeBlock(block: NodeMaterialBlock): void;
  123049. /**
  123050. * Build the material and generates the inner effect
  123051. * @param verbose defines if the build should log activity
  123052. */
  123053. build(verbose?: boolean): void;
  123054. /**
  123055. * Runs an otpimization phase to try to improve the shader code
  123056. */
  123057. optimize(): void;
  123058. private _prepareDefinesForAttributes;
  123059. /**
  123060. * Get if the submesh is ready to be used and all its information available.
  123061. * Child classes can use it to update shaders
  123062. * @param mesh defines the mesh to check
  123063. * @param subMesh defines which submesh to check
  123064. * @param useInstances specifies that instances should be used
  123065. * @returns a boolean indicating that the submesh is ready or not
  123066. */
  123067. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123068. /**
  123069. * Get a string representing the shaders built by the current node graph
  123070. */
  123071. readonly compiledShaders: string;
  123072. /**
  123073. * Binds the world matrix to the material
  123074. * @param world defines the world transformation matrix
  123075. */
  123076. bindOnlyWorldMatrix(world: Matrix): void;
  123077. /**
  123078. * Binds the submesh to this material by preparing the effect and shader to draw
  123079. * @param world defines the world transformation matrix
  123080. * @param mesh defines the mesh containing the submesh
  123081. * @param subMesh defines the submesh to bind the material to
  123082. */
  123083. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123084. /**
  123085. * Gets the active textures from the material
  123086. * @returns an array of textures
  123087. */
  123088. getActiveTextures(): BaseTexture[];
  123089. /**
  123090. * Gets the list of texture blocks
  123091. * @returns an array of texture blocks
  123092. */
  123093. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123094. /**
  123095. * Specifies if the material uses a texture
  123096. * @param texture defines the texture to check against the material
  123097. * @returns a boolean specifying if the material uses the texture
  123098. */
  123099. hasTexture(texture: BaseTexture): boolean;
  123100. /**
  123101. * Disposes the material
  123102. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123103. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123104. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123105. */
  123106. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123107. /** Creates the node editor window. */
  123108. private _createNodeEditor;
  123109. /**
  123110. * Launch the node material editor
  123111. * @param config Define the configuration of the editor
  123112. * @return a promise fulfilled when the node editor is visible
  123113. */
  123114. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123115. /**
  123116. * Clear the current material
  123117. */
  123118. clear(): void;
  123119. /**
  123120. * Clear the current material and set it to a default state
  123121. */
  123122. setToDefault(): void;
  123123. /**
  123124. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123125. * @param url defines the url to load from
  123126. * @returns a promise that will fullfil when the material is fully loaded
  123127. */
  123128. loadAsync(url: string): Promise<void>;
  123129. private _gatherBlocks;
  123130. /**
  123131. * Generate a string containing the code declaration required to create an equivalent of this material
  123132. * @returns a string
  123133. */
  123134. generateCode(): string;
  123135. /**
  123136. * Serializes this material in a JSON representation
  123137. * @returns the serialized material object
  123138. */
  123139. serialize(): any;
  123140. private _restoreConnections;
  123141. /**
  123142. * Clear the current graph and load a new one from a serialization object
  123143. * @param source defines the JSON representation of the material
  123144. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123145. */
  123146. loadFromSerialization(source: any, rootUrl?: string): void;
  123147. /**
  123148. * Creates a node material from parsed material data
  123149. * @param source defines the JSON representation of the material
  123150. * @param scene defines the hosting scene
  123151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123152. * @returns a new node material
  123153. */
  123154. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123155. /**
  123156. * Creates a new node material set to default basic configuration
  123157. * @param name defines the name of the material
  123158. * @param scene defines the hosting scene
  123159. * @returns a new NodeMaterial
  123160. */
  123161. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123162. }
  123163. }
  123164. declare module BABYLON {
  123165. /**
  123166. * Block used to read a texture from a sampler
  123167. */
  123168. export class TextureBlock extends NodeMaterialBlock {
  123169. private _defineName;
  123170. private _linearDefineName;
  123171. private _tempTextureRead;
  123172. private _samplerName;
  123173. private _transformedUVName;
  123174. private _textureTransformName;
  123175. private _textureInfoName;
  123176. private _mainUVName;
  123177. private _mainUVDefineName;
  123178. /**
  123179. * Gets or sets the texture associated with the node
  123180. */
  123181. texture: Nullable<Texture>;
  123182. /**
  123183. * Create a new TextureBlock
  123184. * @param name defines the block name
  123185. */
  123186. constructor(name: string);
  123187. /**
  123188. * Gets the current class name
  123189. * @returns the class name
  123190. */
  123191. getClassName(): string;
  123192. /**
  123193. * Gets the uv input component
  123194. */
  123195. readonly uv: NodeMaterialConnectionPoint;
  123196. /**
  123197. * Gets the rgba output component
  123198. */
  123199. readonly rgba: NodeMaterialConnectionPoint;
  123200. /**
  123201. * Gets the rgb output component
  123202. */
  123203. readonly rgb: NodeMaterialConnectionPoint;
  123204. /**
  123205. * Gets the r output component
  123206. */
  123207. readonly r: NodeMaterialConnectionPoint;
  123208. /**
  123209. * Gets the g output component
  123210. */
  123211. readonly g: NodeMaterialConnectionPoint;
  123212. /**
  123213. * Gets the b output component
  123214. */
  123215. readonly b: NodeMaterialConnectionPoint;
  123216. /**
  123217. * Gets the a output component
  123218. */
  123219. readonly a: NodeMaterialConnectionPoint;
  123220. readonly target: NodeMaterialBlockTargets;
  123221. autoConfigure(material: NodeMaterial): void;
  123222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123224. private _getTextureBase;
  123225. isReady(): boolean;
  123226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123227. private readonly _isMixed;
  123228. private _injectVertexCode;
  123229. private _writeTextureRead;
  123230. private _writeOutput;
  123231. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123232. protected _dumpPropertiesCode(): string;
  123233. serialize(): any;
  123234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123235. }
  123236. }
  123237. declare module BABYLON {
  123238. /**
  123239. * Class used to store shared data between 2 NodeMaterialBuildState
  123240. */
  123241. export class NodeMaterialBuildStateSharedData {
  123242. /**
  123243. * Gets the list of emitted varyings
  123244. */
  123245. temps: string[];
  123246. /**
  123247. * Gets the list of emitted varyings
  123248. */
  123249. varyings: string[];
  123250. /**
  123251. * Gets the varying declaration string
  123252. */
  123253. varyingDeclaration: string;
  123254. /**
  123255. * Input blocks
  123256. */
  123257. inputBlocks: InputBlock[];
  123258. /**
  123259. * Input blocks
  123260. */
  123261. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123262. /**
  123263. * Bindable blocks (Blocks that need to set data to the effect)
  123264. */
  123265. bindableBlocks: NodeMaterialBlock[];
  123266. /**
  123267. * List of blocks that can provide a compilation fallback
  123268. */
  123269. blocksWithFallbacks: NodeMaterialBlock[];
  123270. /**
  123271. * List of blocks that can provide a define update
  123272. */
  123273. blocksWithDefines: NodeMaterialBlock[];
  123274. /**
  123275. * List of blocks that can provide a repeatable content
  123276. */
  123277. repeatableContentBlocks: NodeMaterialBlock[];
  123278. /**
  123279. * List of blocks that can provide a dynamic list of uniforms
  123280. */
  123281. dynamicUniformBlocks: NodeMaterialBlock[];
  123282. /**
  123283. * List of blocks that can block the isReady function for the material
  123284. */
  123285. blockingBlocks: NodeMaterialBlock[];
  123286. /**
  123287. * Gets the list of animated inputs
  123288. */
  123289. animatedInputs: InputBlock[];
  123290. /**
  123291. * Build Id used to avoid multiple recompilations
  123292. */
  123293. buildId: number;
  123294. /** List of emitted variables */
  123295. variableNames: {
  123296. [key: string]: number;
  123297. };
  123298. /** List of emitted defines */
  123299. defineNames: {
  123300. [key: string]: number;
  123301. };
  123302. /** Should emit comments? */
  123303. emitComments: boolean;
  123304. /** Emit build activity */
  123305. verbose: boolean;
  123306. /** Gets or sets the hosting scene */
  123307. scene: Scene;
  123308. /**
  123309. * Gets the compilation hints emitted at compilation time
  123310. */
  123311. hints: {
  123312. needWorldViewMatrix: boolean;
  123313. needWorldViewProjectionMatrix: boolean;
  123314. needAlphaBlending: boolean;
  123315. needAlphaTesting: boolean;
  123316. };
  123317. /**
  123318. * List of compilation checks
  123319. */
  123320. checks: {
  123321. emitVertex: boolean;
  123322. emitFragment: boolean;
  123323. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123324. };
  123325. /** Creates a new shared data */
  123326. constructor();
  123327. /**
  123328. * Emits console errors and exceptions if there is a failing check
  123329. */
  123330. emitErrors(): void;
  123331. }
  123332. }
  123333. declare module BABYLON {
  123334. /**
  123335. * Class used to store node based material build state
  123336. */
  123337. export class NodeMaterialBuildState {
  123338. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123339. supportUniformBuffers: boolean;
  123340. /**
  123341. * Gets the list of emitted attributes
  123342. */
  123343. attributes: string[];
  123344. /**
  123345. * Gets the list of emitted uniforms
  123346. */
  123347. uniforms: string[];
  123348. /**
  123349. * Gets the list of emitted constants
  123350. */
  123351. constants: string[];
  123352. /**
  123353. * Gets the list of emitted samplers
  123354. */
  123355. samplers: string[];
  123356. /**
  123357. * Gets the list of emitted functions
  123358. */
  123359. functions: {
  123360. [key: string]: string;
  123361. };
  123362. /**
  123363. * Gets the list of emitted extensions
  123364. */
  123365. extensions: {
  123366. [key: string]: string;
  123367. };
  123368. /**
  123369. * Gets the target of the compilation state
  123370. */
  123371. target: NodeMaterialBlockTargets;
  123372. /**
  123373. * Gets the list of emitted counters
  123374. */
  123375. counters: {
  123376. [key: string]: number;
  123377. };
  123378. /**
  123379. * Shared data between multiple NodeMaterialBuildState instances
  123380. */
  123381. sharedData: NodeMaterialBuildStateSharedData;
  123382. /** @hidden */
  123383. _vertexState: NodeMaterialBuildState;
  123384. /** @hidden */
  123385. _attributeDeclaration: string;
  123386. /** @hidden */
  123387. _uniformDeclaration: string;
  123388. /** @hidden */
  123389. _constantDeclaration: string;
  123390. /** @hidden */
  123391. _samplerDeclaration: string;
  123392. /** @hidden */
  123393. _varyingTransfer: string;
  123394. private _repeatableContentAnchorIndex;
  123395. /** @hidden */
  123396. _builtCompilationString: string;
  123397. /**
  123398. * Gets the emitted compilation strings
  123399. */
  123400. compilationString: string;
  123401. /**
  123402. * Finalize the compilation strings
  123403. * @param state defines the current compilation state
  123404. */
  123405. finalize(state: NodeMaterialBuildState): void;
  123406. /** @hidden */
  123407. readonly _repeatableContentAnchor: string;
  123408. /** @hidden */
  123409. _getFreeVariableName(prefix: string): string;
  123410. /** @hidden */
  123411. _getFreeDefineName(prefix: string): string;
  123412. /** @hidden */
  123413. _excludeVariableName(name: string): void;
  123414. /** @hidden */
  123415. _emit2DSampler(name: string): void;
  123416. /** @hidden */
  123417. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  123418. /** @hidden */
  123419. _emitExtension(name: string, extension: string): void;
  123420. /** @hidden */
  123421. _emitFunction(name: string, code: string, comments: string): void;
  123422. /** @hidden */
  123423. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  123424. replaceStrings?: {
  123425. search: RegExp;
  123426. replace: string;
  123427. }[];
  123428. repeatKey?: string;
  123429. }): string;
  123430. /** @hidden */
  123431. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  123432. repeatKey?: string;
  123433. removeAttributes?: boolean;
  123434. removeUniforms?: boolean;
  123435. removeVaryings?: boolean;
  123436. removeIfDef?: boolean;
  123437. replaceStrings?: {
  123438. search: RegExp;
  123439. replace: string;
  123440. }[];
  123441. }, storeKey?: string): void;
  123442. /** @hidden */
  123443. _registerTempVariable(name: string): boolean;
  123444. /** @hidden */
  123445. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  123446. /** @hidden */
  123447. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  123448. /** @hidden */
  123449. _emitFloat(value: number): string;
  123450. }
  123451. }
  123452. declare module BABYLON {
  123453. /**
  123454. * Defines a block that can be used inside a node based material
  123455. */
  123456. export class NodeMaterialBlock {
  123457. private _buildId;
  123458. private _buildTarget;
  123459. private _target;
  123460. private _isFinalMerger;
  123461. private _isInput;
  123462. protected _isUnique: boolean;
  123463. /** @hidden */
  123464. _codeVariableName: string;
  123465. /** @hidden */
  123466. _inputs: NodeMaterialConnectionPoint[];
  123467. /** @hidden */
  123468. _outputs: NodeMaterialConnectionPoint[];
  123469. /** @hidden */
  123470. _preparationId: number;
  123471. /**
  123472. * Gets or sets the name of the block
  123473. */
  123474. name: string;
  123475. /**
  123476. * Gets or sets the unique id of the node
  123477. */
  123478. uniqueId: number;
  123479. /**
  123480. * Gets or sets the comments associated with this block
  123481. */
  123482. comments: string;
  123483. /**
  123484. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  123485. */
  123486. readonly isUnique: boolean;
  123487. /**
  123488. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  123489. */
  123490. readonly isFinalMerger: boolean;
  123491. /**
  123492. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  123493. */
  123494. readonly isInput: boolean;
  123495. /**
  123496. * Gets or sets the build Id
  123497. */
  123498. buildId: number;
  123499. /**
  123500. * Gets or sets the target of the block
  123501. */
  123502. target: NodeMaterialBlockTargets;
  123503. /**
  123504. * Gets the list of input points
  123505. */
  123506. readonly inputs: NodeMaterialConnectionPoint[];
  123507. /** Gets the list of output points */
  123508. readonly outputs: NodeMaterialConnectionPoint[];
  123509. /**
  123510. * Find an input by its name
  123511. * @param name defines the name of the input to look for
  123512. * @returns the input or null if not found
  123513. */
  123514. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123515. /**
  123516. * Find an output by its name
  123517. * @param name defines the name of the outputto look for
  123518. * @returns the output or null if not found
  123519. */
  123520. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  123521. /**
  123522. * Creates a new NodeMaterialBlock
  123523. * @param name defines the block name
  123524. * @param target defines the target of that block (Vertex by default)
  123525. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  123526. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  123527. */
  123528. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  123529. /**
  123530. * Initialize the block and prepare the context for build
  123531. * @param state defines the state that will be used for the build
  123532. */
  123533. initialize(state: NodeMaterialBuildState): void;
  123534. /**
  123535. * Bind data to effect. Will only be called for blocks with isBindable === true
  123536. * @param effect defines the effect to bind data to
  123537. * @param nodeMaterial defines the hosting NodeMaterial
  123538. * @param mesh defines the mesh that will be rendered
  123539. */
  123540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123541. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  123542. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  123543. protected _writeFloat(value: number): string;
  123544. /**
  123545. * Gets the current class name e.g. "NodeMaterialBlock"
  123546. * @returns the class name
  123547. */
  123548. getClassName(): string;
  123549. /**
  123550. * Register a new input. Must be called inside a block constructor
  123551. * @param name defines the connection point name
  123552. * @param type defines the connection point type
  123553. * @param isOptional defines a boolean indicating that this input can be omitted
  123554. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123555. * @returns the current block
  123556. */
  123557. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  123558. /**
  123559. * Register a new output. Must be called inside a block constructor
  123560. * @param name defines the connection point name
  123561. * @param type defines the connection point type
  123562. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  123563. * @returns the current block
  123564. */
  123565. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  123566. /**
  123567. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  123568. * @param forOutput defines an optional connection point to check compatibility with
  123569. * @returns the first available input or null
  123570. */
  123571. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  123572. /**
  123573. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  123574. * @param forBlock defines an optional block to check compatibility with
  123575. * @returns the first available input or null
  123576. */
  123577. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  123578. /**
  123579. * Gets the sibling of the given output
  123580. * @param current defines the current output
  123581. * @returns the next output in the list or null
  123582. */
  123583. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  123584. /**
  123585. * Connect current block with another block
  123586. * @param other defines the block to connect with
  123587. * @param options define the various options to help pick the right connections
  123588. * @returns the current block
  123589. */
  123590. connectTo(other: NodeMaterialBlock, options?: {
  123591. input?: string;
  123592. output?: string;
  123593. outputSwizzle?: string;
  123594. }): this | undefined;
  123595. protected _buildBlock(state: NodeMaterialBuildState): void;
  123596. /**
  123597. * Add uniforms, samplers and uniform buffers at compilation time
  123598. * @param state defines the state to update
  123599. * @param nodeMaterial defines the node material requesting the update
  123600. * @param defines defines the material defines to update
  123601. * @param uniformBuffers defines the list of uniform buffer names
  123602. */
  123603. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123604. /**
  123605. * Add potential fallbacks if shader compilation fails
  123606. * @param mesh defines the mesh to be rendered
  123607. * @param fallbacks defines the current prioritized list of fallbacks
  123608. */
  123609. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123610. /**
  123611. * Initialize defines for shader compilation
  123612. * @param mesh defines the mesh to be rendered
  123613. * @param nodeMaterial defines the node material requesting the update
  123614. * @param defines defines the material defines to update
  123615. * @param useInstances specifies that instances should be used
  123616. */
  123617. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123618. /**
  123619. * Update defines for shader compilation
  123620. * @param mesh defines the mesh to be rendered
  123621. * @param nodeMaterial defines the node material requesting the update
  123622. * @param defines defines the material defines to update
  123623. * @param useInstances specifies that instances should be used
  123624. */
  123625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123626. /**
  123627. * Lets the block try to connect some inputs automatically
  123628. * @param material defines the hosting NodeMaterial
  123629. */
  123630. autoConfigure(material: NodeMaterial): void;
  123631. /**
  123632. * Function called when a block is declared as repeatable content generator
  123633. * @param vertexShaderState defines the current compilation state for the vertex shader
  123634. * @param fragmentShaderState defines the current compilation state for the fragment shader
  123635. * @param mesh defines the mesh to be rendered
  123636. * @param defines defines the material defines to update
  123637. */
  123638. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123639. /**
  123640. * Checks if the block is ready
  123641. * @param mesh defines the mesh to be rendered
  123642. * @param nodeMaterial defines the node material requesting the update
  123643. * @param defines defines the material defines to update
  123644. * @param useInstances specifies that instances should be used
  123645. * @returns true if the block is ready
  123646. */
  123647. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  123648. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  123649. private _processBuild;
  123650. /**
  123651. * Compile the current node and generate the shader code
  123652. * @param state defines the current compilation state (uniforms, samplers, current string)
  123653. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  123654. * @returns true if already built
  123655. */
  123656. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  123657. protected _inputRename(name: string): string;
  123658. protected _outputRename(name: string): string;
  123659. protected _dumpPropertiesCode(): string;
  123660. /** @hidden */
  123661. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  123662. /** @hidden */
  123663. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  123664. /**
  123665. * Clone the current block to a new identical block
  123666. * @param scene defines the hosting scene
  123667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123668. * @returns a copy of the current block
  123669. */
  123670. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  123671. /**
  123672. * Serializes this block in a JSON representation
  123673. * @returns the serialized block object
  123674. */
  123675. serialize(): any;
  123676. /** @hidden */
  123677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123678. /**
  123679. * Release resources
  123680. */
  123681. dispose(): void;
  123682. }
  123683. }
  123684. declare module BABYLON {
  123685. /**
  123686. * Enum defining the type of animations supported by InputBlock
  123687. */
  123688. export enum AnimatedInputBlockTypes {
  123689. /** No animation */
  123690. None = 0,
  123691. /** Time based animation. Will only work for floats */
  123692. Time = 1
  123693. }
  123694. }
  123695. declare module BABYLON {
  123696. /**
  123697. * Block used to expose an input value
  123698. */
  123699. export class InputBlock extends NodeMaterialBlock {
  123700. private _mode;
  123701. private _associatedVariableName;
  123702. private _storedValue;
  123703. private _valueCallback;
  123704. private _type;
  123705. private _animationType;
  123706. /** Gets or set a value used to limit the range of float values */
  123707. min: number;
  123708. /** Gets or set a value used to limit the range of float values */
  123709. max: number;
  123710. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  123711. matrixMode: number;
  123712. /** @hidden */
  123713. _systemValue: Nullable<NodeMaterialSystemValues>;
  123714. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  123715. visibleInInspector: boolean;
  123716. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  123717. isConstant: boolean;
  123718. /**
  123719. * Gets or sets the connection point type (default is float)
  123720. */
  123721. readonly type: NodeMaterialBlockConnectionPointTypes;
  123722. /**
  123723. * Creates a new InputBlock
  123724. * @param name defines the block name
  123725. * @param target defines the target of that block (Vertex by default)
  123726. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  123727. */
  123728. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  123729. /**
  123730. * Gets the output component
  123731. */
  123732. readonly output: NodeMaterialConnectionPoint;
  123733. /**
  123734. * Set the source of this connection point to a vertex attribute
  123735. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  123736. * @returns the current connection point
  123737. */
  123738. setAsAttribute(attributeName?: string): InputBlock;
  123739. /**
  123740. * Set the source of this connection point to a system value
  123741. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  123742. * @returns the current connection point
  123743. */
  123744. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  123745. /**
  123746. * Gets or sets the value of that point.
  123747. * Please note that this value will be ignored if valueCallback is defined
  123748. */
  123749. value: any;
  123750. /**
  123751. * Gets or sets a callback used to get the value of that point.
  123752. * Please note that setting this value will force the connection point to ignore the value property
  123753. */
  123754. valueCallback: () => any;
  123755. /**
  123756. * Gets or sets the associated variable name in the shader
  123757. */
  123758. associatedVariableName: string;
  123759. /** Gets or sets the type of animation applied to the input */
  123760. animationType: AnimatedInputBlockTypes;
  123761. /**
  123762. * Gets a boolean indicating that this connection point not defined yet
  123763. */
  123764. readonly isUndefined: boolean;
  123765. /**
  123766. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  123767. * In this case the connection point name must be the name of the uniform to use.
  123768. * Can only be set on inputs
  123769. */
  123770. isUniform: boolean;
  123771. /**
  123772. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  123773. * In this case the connection point name must be the name of the attribute to use
  123774. * Can only be set on inputs
  123775. */
  123776. isAttribute: boolean;
  123777. /**
  123778. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  123779. * Can only be set on exit points
  123780. */
  123781. isVarying: boolean;
  123782. /**
  123783. * Gets a boolean indicating that the current connection point is a system value
  123784. */
  123785. readonly isSystemValue: boolean;
  123786. /**
  123787. * Gets or sets the current well known value or null if not defined as a system value
  123788. */
  123789. systemValue: Nullable<NodeMaterialSystemValues>;
  123790. /**
  123791. * Gets the current class name
  123792. * @returns the class name
  123793. */
  123794. getClassName(): string;
  123795. /**
  123796. * Animate the input if animationType !== None
  123797. * @param scene defines the rendering scene
  123798. */
  123799. animate(scene: Scene): void;
  123800. private _emitDefine;
  123801. initialize(state: NodeMaterialBuildState): void;
  123802. /**
  123803. * Set the input block to its default value (based on its type)
  123804. */
  123805. setDefaultValue(): void;
  123806. private _emitConstant;
  123807. private _emit;
  123808. /** @hidden */
  123809. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  123810. /** @hidden */
  123811. _transmit(effect: Effect, scene: Scene): void;
  123812. protected _buildBlock(state: NodeMaterialBuildState): void;
  123813. protected _dumpPropertiesCode(): string;
  123814. serialize(): any;
  123815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123816. }
  123817. }
  123818. declare module BABYLON {
  123819. /**
  123820. * Enum used to define the compatibility state between two connection points
  123821. */
  123822. export enum NodeMaterialConnectionPointCompatibilityStates {
  123823. /** Points are compatibles */
  123824. Compatible = 0,
  123825. /** Points are incompatible because of their types */
  123826. TypeIncompatible = 1,
  123827. /** Points are incompatible because of their targets (vertex vs fragment) */
  123828. TargetIncompatible = 2
  123829. }
  123830. /**
  123831. * Defines the direction of a connection point
  123832. */
  123833. export enum NodeMaterialConnectionPointDirection {
  123834. /** Input */
  123835. Input = 0,
  123836. /** Output */
  123837. Output = 1
  123838. }
  123839. /**
  123840. * Defines a connection point for a block
  123841. */
  123842. export class NodeMaterialConnectionPoint {
  123843. /** @hidden */
  123844. _ownerBlock: NodeMaterialBlock;
  123845. /** @hidden */
  123846. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123847. private _endpoints;
  123848. private _associatedVariableName;
  123849. private _direction;
  123850. /** @hidden */
  123851. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123852. /** @hidden */
  123853. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123854. private _type;
  123855. /** @hidden */
  123856. _enforceAssociatedVariableName: boolean;
  123857. /** Gets the direction of the point */
  123858. readonly direction: NodeMaterialConnectionPointDirection;
  123859. /**
  123860. * Gets or sets the additional types supported by this connection point
  123861. */
  123862. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123863. /**
  123864. * Gets or sets the additional types excluded by this connection point
  123865. */
  123866. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123867. /**
  123868. * Observable triggered when this point is connected
  123869. */
  123870. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123871. /**
  123872. * Gets or sets the associated variable name in the shader
  123873. */
  123874. associatedVariableName: string;
  123875. /**
  123876. * Gets or sets the connection point type (default is float)
  123877. */
  123878. type: NodeMaterialBlockConnectionPointTypes;
  123879. /**
  123880. * Gets or sets the connection point name
  123881. */
  123882. name: string;
  123883. /**
  123884. * Gets or sets a boolean indicating that this connection point can be omitted
  123885. */
  123886. isOptional: boolean;
  123887. /**
  123888. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123889. */
  123890. define: string;
  123891. /** @hidden */
  123892. _prioritizeVertex: boolean;
  123893. private _target;
  123894. /** Gets or sets the target of that connection point */
  123895. target: NodeMaterialBlockTargets;
  123896. /**
  123897. * Gets a boolean indicating that the current point is connected
  123898. */
  123899. readonly isConnected: boolean;
  123900. /**
  123901. * Gets a boolean indicating that the current point is connected to an input block
  123902. */
  123903. readonly isConnectedToInputBlock: boolean;
  123904. /**
  123905. * Gets a the connected input block (if any)
  123906. */
  123907. readonly connectInputBlock: Nullable<InputBlock>;
  123908. /** Get the other side of the connection (if any) */
  123909. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123910. /** Get the block that owns this connection point */
  123911. readonly ownerBlock: NodeMaterialBlock;
  123912. /** Get the block connected on the other side of this connection (if any) */
  123913. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123914. /** Get the block connected on the endpoints of this connection (if any) */
  123915. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123916. /** Gets the list of connected endpoints */
  123917. readonly endpoints: NodeMaterialConnectionPoint[];
  123918. /** Gets a boolean indicating if that output point is connected to at least one input */
  123919. readonly hasEndpoints: boolean;
  123920. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123921. readonly isConnectedInVertexShader: boolean;
  123922. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123923. readonly isConnectedInFragmentShader: boolean;
  123924. /**
  123925. * Creates a new connection point
  123926. * @param name defines the connection point name
  123927. * @param ownerBlock defines the block hosting this connection point
  123928. * @param direction defines the direction of the connection point
  123929. */
  123930. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  123931. /**
  123932. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123933. * @returns the class name
  123934. */
  123935. getClassName(): string;
  123936. /**
  123937. * Gets a boolean indicating if the current point can be connected to another point
  123938. * @param connectionPoint defines the other connection point
  123939. * @returns a boolean
  123940. */
  123941. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123942. /**
  123943. * Gets a number indicating if the current point can be connected to another point
  123944. * @param connectionPoint defines the other connection point
  123945. * @returns a number defining the compatibility state
  123946. */
  123947. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123948. /**
  123949. * Connect this point to another connection point
  123950. * @param connectionPoint defines the other connection point
  123951. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123952. * @returns the current connection point
  123953. */
  123954. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123955. /**
  123956. * Disconnect this point from one of his endpoint
  123957. * @param endpoint defines the other connection point
  123958. * @returns the current connection point
  123959. */
  123960. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  123961. /**
  123962. * Serializes this point in a JSON representation
  123963. * @returns the serialized point object
  123964. */
  123965. serialize(): any;
  123966. /**
  123967. * Release resources
  123968. */
  123969. dispose(): void;
  123970. }
  123971. }
  123972. declare module BABYLON {
  123973. /**
  123974. * Block used to add support for vertex skinning (bones)
  123975. */
  123976. export class BonesBlock extends NodeMaterialBlock {
  123977. /**
  123978. * Creates a new BonesBlock
  123979. * @param name defines the block name
  123980. */
  123981. constructor(name: string);
  123982. /**
  123983. * Initialize the block and prepare the context for build
  123984. * @param state defines the state that will be used for the build
  123985. */
  123986. initialize(state: NodeMaterialBuildState): void;
  123987. /**
  123988. * Gets the current class name
  123989. * @returns the class name
  123990. */
  123991. getClassName(): string;
  123992. /**
  123993. * Gets the matrix indices input component
  123994. */
  123995. readonly matricesIndices: NodeMaterialConnectionPoint;
  123996. /**
  123997. * Gets the matrix weights input component
  123998. */
  123999. readonly matricesWeights: NodeMaterialConnectionPoint;
  124000. /**
  124001. * Gets the extra matrix indices input component
  124002. */
  124003. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124004. /**
  124005. * Gets the extra matrix weights input component
  124006. */
  124007. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124008. /**
  124009. * Gets the world input component
  124010. */
  124011. readonly world: NodeMaterialConnectionPoint;
  124012. /**
  124013. * Gets the output component
  124014. */
  124015. readonly output: NodeMaterialConnectionPoint;
  124016. autoConfigure(material: NodeMaterial): void;
  124017. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124020. protected _buildBlock(state: NodeMaterialBuildState): this;
  124021. }
  124022. }
  124023. declare module BABYLON {
  124024. /**
  124025. * Block used to add support for instances
  124026. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124027. */
  124028. export class InstancesBlock extends NodeMaterialBlock {
  124029. /**
  124030. * Creates a new InstancesBlock
  124031. * @param name defines the block name
  124032. */
  124033. constructor(name: string);
  124034. /**
  124035. * Gets the current class name
  124036. * @returns the class name
  124037. */
  124038. getClassName(): string;
  124039. /**
  124040. * Gets the first world row input component
  124041. */
  124042. readonly world0: NodeMaterialConnectionPoint;
  124043. /**
  124044. * Gets the second world row input component
  124045. */
  124046. readonly world1: NodeMaterialConnectionPoint;
  124047. /**
  124048. * Gets the third world row input component
  124049. */
  124050. readonly world2: NodeMaterialConnectionPoint;
  124051. /**
  124052. * Gets the forth world row input component
  124053. */
  124054. readonly world3: NodeMaterialConnectionPoint;
  124055. /**
  124056. * Gets the world input component
  124057. */
  124058. readonly world: NodeMaterialConnectionPoint;
  124059. /**
  124060. * Gets the output component
  124061. */
  124062. readonly output: NodeMaterialConnectionPoint;
  124063. autoConfigure(material: NodeMaterial): void;
  124064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124065. protected _buildBlock(state: NodeMaterialBuildState): this;
  124066. }
  124067. }
  124068. declare module BABYLON {
  124069. /**
  124070. * Block used to add morph targets support to vertex shader
  124071. */
  124072. export class MorphTargetsBlock extends NodeMaterialBlock {
  124073. private _repeatableContentAnchor;
  124074. private _repeatebleContentGenerated;
  124075. /**
  124076. * Create a new MorphTargetsBlock
  124077. * @param name defines the block name
  124078. */
  124079. constructor(name: string);
  124080. /**
  124081. * Gets the current class name
  124082. * @returns the class name
  124083. */
  124084. getClassName(): string;
  124085. /**
  124086. * Gets the position input component
  124087. */
  124088. readonly position: NodeMaterialConnectionPoint;
  124089. /**
  124090. * Gets the normal input component
  124091. */
  124092. readonly normal: NodeMaterialConnectionPoint;
  124093. /**
  124094. * Gets the tangent input component
  124095. */
  124096. readonly tangent: NodeMaterialConnectionPoint;
  124097. /**
  124098. * Gets the tangent input component
  124099. */
  124100. readonly uv: NodeMaterialConnectionPoint;
  124101. /**
  124102. * Gets the position output component
  124103. */
  124104. readonly positionOutput: NodeMaterialConnectionPoint;
  124105. /**
  124106. * Gets the normal output component
  124107. */
  124108. readonly normalOutput: NodeMaterialConnectionPoint;
  124109. /**
  124110. * Gets the tangent output component
  124111. */
  124112. readonly tangentOutput: NodeMaterialConnectionPoint;
  124113. /**
  124114. * Gets the tangent output component
  124115. */
  124116. readonly uvOutput: NodeMaterialConnectionPoint;
  124117. initialize(state: NodeMaterialBuildState): void;
  124118. autoConfigure(material: NodeMaterial): void;
  124119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124121. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124122. protected _buildBlock(state: NodeMaterialBuildState): this;
  124123. }
  124124. }
  124125. declare module BABYLON {
  124126. /**
  124127. * Block used to get data information from a light
  124128. */
  124129. export class LightInformationBlock extends NodeMaterialBlock {
  124130. private _lightDataUniformName;
  124131. private _lightColorUniformName;
  124132. private _lightTypeDefineName;
  124133. /**
  124134. * Gets or sets the light associated with this block
  124135. */
  124136. light: Nullable<Light>;
  124137. /**
  124138. * Creates a new LightInformationBlock
  124139. * @param name defines the block name
  124140. */
  124141. constructor(name: string);
  124142. /**
  124143. * Gets the current class name
  124144. * @returns the class name
  124145. */
  124146. getClassName(): string;
  124147. /**
  124148. * Gets the world position input component
  124149. */
  124150. readonly worldPosition: NodeMaterialConnectionPoint;
  124151. /**
  124152. * Gets the direction output component
  124153. */
  124154. readonly direction: NodeMaterialConnectionPoint;
  124155. /**
  124156. * Gets the direction output component
  124157. */
  124158. readonly color: NodeMaterialConnectionPoint;
  124159. /**
  124160. * Gets the direction output component
  124161. */
  124162. readonly intensity: NodeMaterialConnectionPoint;
  124163. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124165. protected _buildBlock(state: NodeMaterialBuildState): this;
  124166. serialize(): any;
  124167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124168. }
  124169. }
  124170. declare module BABYLON {
  124171. /**
  124172. * Block used to add image processing support to fragment shader
  124173. */
  124174. export class ImageProcessingBlock extends NodeMaterialBlock {
  124175. /**
  124176. * Create a new ImageProcessingBlock
  124177. * @param name defines the block name
  124178. */
  124179. constructor(name: string);
  124180. /**
  124181. * Gets the current class name
  124182. * @returns the class name
  124183. */
  124184. getClassName(): string;
  124185. /**
  124186. * Gets the color input component
  124187. */
  124188. readonly color: NodeMaterialConnectionPoint;
  124189. /**
  124190. * Gets the output component
  124191. */
  124192. readonly output: NodeMaterialConnectionPoint;
  124193. /**
  124194. * Initialize the block and prepare the context for build
  124195. * @param state defines the state that will be used for the build
  124196. */
  124197. initialize(state: NodeMaterialBuildState): void;
  124198. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124200. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124201. protected _buildBlock(state: NodeMaterialBuildState): this;
  124202. }
  124203. }
  124204. declare module BABYLON {
  124205. /**
  124206. * Block used to pertub normals based on a normal map
  124207. */
  124208. export class PerturbNormalBlock extends NodeMaterialBlock {
  124209. private _tangentSpaceParameterName;
  124210. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124211. invertX: boolean;
  124212. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124213. invertY: boolean;
  124214. /**
  124215. * Create a new PerturbNormalBlock
  124216. * @param name defines the block name
  124217. */
  124218. constructor(name: string);
  124219. /**
  124220. * Gets the current class name
  124221. * @returns the class name
  124222. */
  124223. getClassName(): string;
  124224. /**
  124225. * Gets the world position input component
  124226. */
  124227. readonly worldPosition: NodeMaterialConnectionPoint;
  124228. /**
  124229. * Gets the world normal input component
  124230. */
  124231. readonly worldNormal: NodeMaterialConnectionPoint;
  124232. /**
  124233. * Gets the uv input component
  124234. */
  124235. readonly uv: NodeMaterialConnectionPoint;
  124236. /**
  124237. * Gets the normal map color input component
  124238. */
  124239. readonly normalMapColor: NodeMaterialConnectionPoint;
  124240. /**
  124241. * Gets the strength input component
  124242. */
  124243. readonly strength: NodeMaterialConnectionPoint;
  124244. /**
  124245. * Gets the output component
  124246. */
  124247. readonly output: NodeMaterialConnectionPoint;
  124248. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124250. autoConfigure(material: NodeMaterial): void;
  124251. protected _buildBlock(state: NodeMaterialBuildState): this;
  124252. protected _dumpPropertiesCode(): string;
  124253. serialize(): any;
  124254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124255. }
  124256. }
  124257. declare module BABYLON {
  124258. /**
  124259. * Block used to discard a pixel if a value is smaller than a cutoff
  124260. */
  124261. export class DiscardBlock extends NodeMaterialBlock {
  124262. /**
  124263. * Create a new DiscardBlock
  124264. * @param name defines the block name
  124265. */
  124266. constructor(name: string);
  124267. /**
  124268. * Gets the current class name
  124269. * @returns the class name
  124270. */
  124271. getClassName(): string;
  124272. /**
  124273. * Gets the color input component
  124274. */
  124275. readonly value: NodeMaterialConnectionPoint;
  124276. /**
  124277. * Gets the cutoff input component
  124278. */
  124279. readonly cutoff: NodeMaterialConnectionPoint;
  124280. protected _buildBlock(state: NodeMaterialBuildState): this;
  124281. }
  124282. }
  124283. declare module BABYLON {
  124284. /**
  124285. * Block used to test if the fragment shader is front facing
  124286. */
  124287. export class FrontFacingBlock extends NodeMaterialBlock {
  124288. /**
  124289. * Creates a new FrontFacingBlock
  124290. * @param name defines the block name
  124291. */
  124292. constructor(name: string);
  124293. /**
  124294. * Gets the current class name
  124295. * @returns the class name
  124296. */
  124297. getClassName(): string;
  124298. /**
  124299. * Gets the output component
  124300. */
  124301. readonly output: NodeMaterialConnectionPoint;
  124302. protected _buildBlock(state: NodeMaterialBuildState): this;
  124303. }
  124304. }
  124305. declare module BABYLON {
  124306. /**
  124307. * Block used to get the derivative value on x and y of a given input
  124308. */
  124309. export class DerivativeBlock extends NodeMaterialBlock {
  124310. /**
  124311. * Create a new DerivativeBlock
  124312. * @param name defines the block name
  124313. */
  124314. constructor(name: string);
  124315. /**
  124316. * Gets the current class name
  124317. * @returns the class name
  124318. */
  124319. getClassName(): string;
  124320. /**
  124321. * Gets the input component
  124322. */
  124323. readonly input: NodeMaterialConnectionPoint;
  124324. /**
  124325. * Gets the derivative output on x
  124326. */
  124327. readonly dx: NodeMaterialConnectionPoint;
  124328. /**
  124329. * Gets the derivative output on y
  124330. */
  124331. readonly dy: NodeMaterialConnectionPoint;
  124332. protected _buildBlock(state: NodeMaterialBuildState): this;
  124333. }
  124334. }
  124335. declare module BABYLON {
  124336. /**
  124337. * Block used to add support for scene fog
  124338. */
  124339. export class FogBlock extends NodeMaterialBlock {
  124340. private _fogDistanceName;
  124341. private _fogParameters;
  124342. /**
  124343. * Create a new FogBlock
  124344. * @param name defines the block name
  124345. */
  124346. constructor(name: string);
  124347. /**
  124348. * Gets the current class name
  124349. * @returns the class name
  124350. */
  124351. getClassName(): string;
  124352. /**
  124353. * Gets the world position input component
  124354. */
  124355. readonly worldPosition: NodeMaterialConnectionPoint;
  124356. /**
  124357. * Gets the view input component
  124358. */
  124359. readonly view: NodeMaterialConnectionPoint;
  124360. /**
  124361. * Gets the color input component
  124362. */
  124363. readonly input: NodeMaterialConnectionPoint;
  124364. /**
  124365. * Gets the fog color input component
  124366. */
  124367. readonly fogColor: NodeMaterialConnectionPoint;
  124368. /**
  124369. * Gets the output component
  124370. */
  124371. readonly output: NodeMaterialConnectionPoint;
  124372. autoConfigure(material: NodeMaterial): void;
  124373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124375. protected _buildBlock(state: NodeMaterialBuildState): this;
  124376. }
  124377. }
  124378. declare module BABYLON {
  124379. /**
  124380. * Block used to add light in the fragment shader
  124381. */
  124382. export class LightBlock extends NodeMaterialBlock {
  124383. private _lightId;
  124384. /**
  124385. * Gets or sets the light associated with this block
  124386. */
  124387. light: Nullable<Light>;
  124388. /**
  124389. * Create a new LightBlock
  124390. * @param name defines the block name
  124391. */
  124392. constructor(name: string);
  124393. /**
  124394. * Gets the current class name
  124395. * @returns the class name
  124396. */
  124397. getClassName(): string;
  124398. /**
  124399. * Gets the world position input component
  124400. */
  124401. readonly worldPosition: NodeMaterialConnectionPoint;
  124402. /**
  124403. * Gets the world normal input component
  124404. */
  124405. readonly worldNormal: NodeMaterialConnectionPoint;
  124406. /**
  124407. * Gets the camera (or eye) position component
  124408. */
  124409. readonly cameraPosition: NodeMaterialConnectionPoint;
  124410. /**
  124411. * Gets the glossiness component
  124412. */
  124413. readonly glossiness: NodeMaterialConnectionPoint;
  124414. /**
  124415. * Gets the glossinness power component
  124416. */
  124417. readonly glossPower: NodeMaterialConnectionPoint;
  124418. /**
  124419. * Gets the diffuse color component
  124420. */
  124421. readonly diffuseColor: NodeMaterialConnectionPoint;
  124422. /**
  124423. * Gets the specular color component
  124424. */
  124425. readonly specularColor: NodeMaterialConnectionPoint;
  124426. /**
  124427. * Gets the diffuse output component
  124428. */
  124429. readonly diffuseOutput: NodeMaterialConnectionPoint;
  124430. /**
  124431. * Gets the specular output component
  124432. */
  124433. readonly specularOutput: NodeMaterialConnectionPoint;
  124434. autoConfigure(material: NodeMaterial): void;
  124435. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124436. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124437. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124438. private _injectVertexCode;
  124439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124440. serialize(): any;
  124441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124442. }
  124443. }
  124444. declare module BABYLON {
  124445. /**
  124446. * Block used to multiply 2 values
  124447. */
  124448. export class MultiplyBlock extends NodeMaterialBlock {
  124449. /**
  124450. * Creates a new MultiplyBlock
  124451. * @param name defines the block name
  124452. */
  124453. constructor(name: string);
  124454. /**
  124455. * Gets the current class name
  124456. * @returns the class name
  124457. */
  124458. getClassName(): string;
  124459. /**
  124460. * Gets the left operand input component
  124461. */
  124462. readonly left: NodeMaterialConnectionPoint;
  124463. /**
  124464. * Gets the right operand input component
  124465. */
  124466. readonly right: NodeMaterialConnectionPoint;
  124467. /**
  124468. * Gets the output component
  124469. */
  124470. readonly output: NodeMaterialConnectionPoint;
  124471. protected _buildBlock(state: NodeMaterialBuildState): this;
  124472. }
  124473. }
  124474. declare module BABYLON {
  124475. /**
  124476. * Block used to add 2 vectors
  124477. */
  124478. export class AddBlock extends NodeMaterialBlock {
  124479. /**
  124480. * Creates a new AddBlock
  124481. * @param name defines the block name
  124482. */
  124483. constructor(name: string);
  124484. /**
  124485. * Gets the current class name
  124486. * @returns the class name
  124487. */
  124488. getClassName(): string;
  124489. /**
  124490. * Gets the left operand input component
  124491. */
  124492. readonly left: NodeMaterialConnectionPoint;
  124493. /**
  124494. * Gets the right operand input component
  124495. */
  124496. readonly right: NodeMaterialConnectionPoint;
  124497. /**
  124498. * Gets the output component
  124499. */
  124500. readonly output: NodeMaterialConnectionPoint;
  124501. protected _buildBlock(state: NodeMaterialBuildState): this;
  124502. }
  124503. }
  124504. declare module BABYLON {
  124505. /**
  124506. * Block used to scale a vector by a float
  124507. */
  124508. export class ScaleBlock extends NodeMaterialBlock {
  124509. /**
  124510. * Creates a new ScaleBlock
  124511. * @param name defines the block name
  124512. */
  124513. constructor(name: string);
  124514. /**
  124515. * Gets the current class name
  124516. * @returns the class name
  124517. */
  124518. getClassName(): string;
  124519. /**
  124520. * Gets the input component
  124521. */
  124522. readonly input: NodeMaterialConnectionPoint;
  124523. /**
  124524. * Gets the factor input component
  124525. */
  124526. readonly factor: NodeMaterialConnectionPoint;
  124527. /**
  124528. * Gets the output component
  124529. */
  124530. readonly output: NodeMaterialConnectionPoint;
  124531. protected _buildBlock(state: NodeMaterialBuildState): this;
  124532. }
  124533. }
  124534. declare module BABYLON {
  124535. /**
  124536. * Block used to clamp a float
  124537. */
  124538. export class ClampBlock extends NodeMaterialBlock {
  124539. /** Gets or sets the minimum range */
  124540. minimum: number;
  124541. /** Gets or sets the maximum range */
  124542. maximum: number;
  124543. /**
  124544. * Creates a new ClampBlock
  124545. * @param name defines the block name
  124546. */
  124547. constructor(name: string);
  124548. /**
  124549. * Gets the current class name
  124550. * @returns the class name
  124551. */
  124552. getClassName(): string;
  124553. /**
  124554. * Gets the value input component
  124555. */
  124556. readonly value: NodeMaterialConnectionPoint;
  124557. /**
  124558. * Gets the output component
  124559. */
  124560. readonly output: NodeMaterialConnectionPoint;
  124561. protected _buildBlock(state: NodeMaterialBuildState): this;
  124562. protected _dumpPropertiesCode(): string;
  124563. serialize(): any;
  124564. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124565. }
  124566. }
  124567. declare module BABYLON {
  124568. /**
  124569. * Block used to apply a cross product between 2 vectors
  124570. */
  124571. export class CrossBlock extends NodeMaterialBlock {
  124572. /**
  124573. * Creates a new CrossBlock
  124574. * @param name defines the block name
  124575. */
  124576. constructor(name: string);
  124577. /**
  124578. * Gets the current class name
  124579. * @returns the class name
  124580. */
  124581. getClassName(): string;
  124582. /**
  124583. * Gets the left operand input component
  124584. */
  124585. readonly left: NodeMaterialConnectionPoint;
  124586. /**
  124587. * Gets the right operand input component
  124588. */
  124589. readonly right: NodeMaterialConnectionPoint;
  124590. /**
  124591. * Gets the output component
  124592. */
  124593. readonly output: NodeMaterialConnectionPoint;
  124594. protected _buildBlock(state: NodeMaterialBuildState): this;
  124595. }
  124596. }
  124597. declare module BABYLON {
  124598. /**
  124599. * Block used to apply a dot product between 2 vectors
  124600. */
  124601. export class DotBlock extends NodeMaterialBlock {
  124602. /**
  124603. * Creates a new DotBlock
  124604. * @param name defines the block name
  124605. */
  124606. constructor(name: string);
  124607. /**
  124608. * Gets the current class name
  124609. * @returns the class name
  124610. */
  124611. getClassName(): string;
  124612. /**
  124613. * Gets the left operand input component
  124614. */
  124615. readonly left: NodeMaterialConnectionPoint;
  124616. /**
  124617. * Gets the right operand input component
  124618. */
  124619. readonly right: NodeMaterialConnectionPoint;
  124620. /**
  124621. * Gets the output component
  124622. */
  124623. readonly output: NodeMaterialConnectionPoint;
  124624. protected _buildBlock(state: NodeMaterialBuildState): this;
  124625. }
  124626. }
  124627. declare module BABYLON {
  124628. /**
  124629. * Block used to remap a float from a range to a new one
  124630. */
  124631. export class RemapBlock extends NodeMaterialBlock {
  124632. /**
  124633. * Gets or sets the source range
  124634. */
  124635. sourceRange: Vector2;
  124636. /**
  124637. * Gets or sets the target range
  124638. */
  124639. targetRange: Vector2;
  124640. /**
  124641. * Creates a new RemapBlock
  124642. * @param name defines the block name
  124643. */
  124644. constructor(name: string);
  124645. /**
  124646. * Gets the current class name
  124647. * @returns the class name
  124648. */
  124649. getClassName(): string;
  124650. /**
  124651. * Gets the input component
  124652. */
  124653. readonly input: NodeMaterialConnectionPoint;
  124654. /**
  124655. * Gets the source min input component
  124656. */
  124657. readonly sourceMin: NodeMaterialConnectionPoint;
  124658. /**
  124659. * Gets the source max input component
  124660. */
  124661. readonly sourceMax: NodeMaterialConnectionPoint;
  124662. /**
  124663. * Gets the target min input component
  124664. */
  124665. readonly targetMin: NodeMaterialConnectionPoint;
  124666. /**
  124667. * Gets the target max input component
  124668. */
  124669. readonly targetMax: NodeMaterialConnectionPoint;
  124670. /**
  124671. * Gets the output component
  124672. */
  124673. readonly output: NodeMaterialConnectionPoint;
  124674. protected _buildBlock(state: NodeMaterialBuildState): this;
  124675. protected _dumpPropertiesCode(): string;
  124676. serialize(): any;
  124677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124678. }
  124679. }
  124680. declare module BABYLON {
  124681. /**
  124682. * Block used to normalize a vector
  124683. */
  124684. export class NormalizeBlock extends NodeMaterialBlock {
  124685. /**
  124686. * Creates a new NormalizeBlock
  124687. * @param name defines the block name
  124688. */
  124689. constructor(name: string);
  124690. /**
  124691. * Gets the current class name
  124692. * @returns the class name
  124693. */
  124694. getClassName(): string;
  124695. /**
  124696. * Gets the input component
  124697. */
  124698. readonly input: NodeMaterialConnectionPoint;
  124699. /**
  124700. * Gets the output component
  124701. */
  124702. readonly output: NodeMaterialConnectionPoint;
  124703. protected _buildBlock(state: NodeMaterialBuildState): this;
  124704. }
  124705. }
  124706. declare module BABYLON {
  124707. /**
  124708. * Operations supported by the Trigonometry block
  124709. */
  124710. export enum TrigonometryBlockOperations {
  124711. /** Cos */
  124712. Cos = 0,
  124713. /** Sin */
  124714. Sin = 1,
  124715. /** Abs */
  124716. Abs = 2,
  124717. /** Exp */
  124718. Exp = 3,
  124719. /** Exp2 */
  124720. Exp2 = 4,
  124721. /** Round */
  124722. Round = 5,
  124723. /** Floor */
  124724. Floor = 6,
  124725. /** Ceiling */
  124726. Ceiling = 7,
  124727. /** Square root */
  124728. Sqrt = 8,
  124729. /** Log */
  124730. Log = 9,
  124731. /** Tangent */
  124732. Tan = 10,
  124733. /** Arc tangent */
  124734. ArcTan = 11,
  124735. /** Arc cosinus */
  124736. ArcCos = 12,
  124737. /** Arc sinus */
  124738. ArcSin = 13,
  124739. /** Fraction */
  124740. Fract = 14,
  124741. /** Sign */
  124742. Sign = 15,
  124743. /** To radians (from degrees) */
  124744. Radians = 16,
  124745. /** To degrees (from radians) */
  124746. Degrees = 17
  124747. }
  124748. /**
  124749. * Block used to apply trigonometry operation to floats
  124750. */
  124751. export class TrigonometryBlock extends NodeMaterialBlock {
  124752. /**
  124753. * Gets or sets the operation applied by the block
  124754. */
  124755. operation: TrigonometryBlockOperations;
  124756. /**
  124757. * Creates a new TrigonometryBlock
  124758. * @param name defines the block name
  124759. */
  124760. constructor(name: string);
  124761. /**
  124762. * Gets the current class name
  124763. * @returns the class name
  124764. */
  124765. getClassName(): string;
  124766. /**
  124767. * Gets the input component
  124768. */
  124769. readonly input: NodeMaterialConnectionPoint;
  124770. /**
  124771. * Gets the output component
  124772. */
  124773. readonly output: NodeMaterialConnectionPoint;
  124774. protected _buildBlock(state: NodeMaterialBuildState): this;
  124775. serialize(): any;
  124776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124777. protected _dumpPropertiesCode(): string;
  124778. }
  124779. }
  124780. declare module BABYLON {
  124781. /**
  124782. * Block used to create a Color3/4 out of individual inputs (one for each component)
  124783. */
  124784. export class ColorMergerBlock extends NodeMaterialBlock {
  124785. /**
  124786. * Create a new ColorMergerBlock
  124787. * @param name defines the block name
  124788. */
  124789. constructor(name: string);
  124790. /**
  124791. * Gets the current class name
  124792. * @returns the class name
  124793. */
  124794. getClassName(): string;
  124795. /**
  124796. * Gets the rgb component (input)
  124797. */
  124798. readonly rgbIn: NodeMaterialConnectionPoint;
  124799. /**
  124800. * Gets the r component (input)
  124801. */
  124802. readonly r: NodeMaterialConnectionPoint;
  124803. /**
  124804. * Gets the g component (input)
  124805. */
  124806. readonly g: NodeMaterialConnectionPoint;
  124807. /**
  124808. * Gets the b component (input)
  124809. */
  124810. readonly b: NodeMaterialConnectionPoint;
  124811. /**
  124812. * Gets the a component (input)
  124813. */
  124814. readonly a: NodeMaterialConnectionPoint;
  124815. /**
  124816. * Gets the rgba component (output)
  124817. */
  124818. readonly rgba: NodeMaterialConnectionPoint;
  124819. /**
  124820. * Gets the rgb component (output)
  124821. */
  124822. readonly rgbOut: NodeMaterialConnectionPoint;
  124823. /**
  124824. * Gets the rgb component (output)
  124825. * @deprecated Please use rgbOut instead.
  124826. */
  124827. readonly rgb: NodeMaterialConnectionPoint;
  124828. protected _buildBlock(state: NodeMaterialBuildState): this;
  124829. }
  124830. }
  124831. declare module BABYLON {
  124832. /**
  124833. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  124834. */
  124835. export class VectorMergerBlock extends NodeMaterialBlock {
  124836. /**
  124837. * Create a new VectorMergerBlock
  124838. * @param name defines the block name
  124839. */
  124840. constructor(name: string);
  124841. /**
  124842. * Gets the current class name
  124843. * @returns the class name
  124844. */
  124845. getClassName(): string;
  124846. /**
  124847. * Gets the xyz component (input)
  124848. */
  124849. readonly xyzIn: NodeMaterialConnectionPoint;
  124850. /**
  124851. * Gets the xy component (input)
  124852. */
  124853. readonly xyIn: NodeMaterialConnectionPoint;
  124854. /**
  124855. * Gets the x component (input)
  124856. */
  124857. readonly x: NodeMaterialConnectionPoint;
  124858. /**
  124859. * Gets the y component (input)
  124860. */
  124861. readonly y: NodeMaterialConnectionPoint;
  124862. /**
  124863. * Gets the z component (input)
  124864. */
  124865. readonly z: NodeMaterialConnectionPoint;
  124866. /**
  124867. * Gets the w component (input)
  124868. */
  124869. readonly w: NodeMaterialConnectionPoint;
  124870. /**
  124871. * Gets the xyzw component (output)
  124872. */
  124873. readonly xyzw: NodeMaterialConnectionPoint;
  124874. /**
  124875. * Gets the xyz component (output)
  124876. */
  124877. readonly xyzOut: NodeMaterialConnectionPoint;
  124878. /**
  124879. * Gets the xy component (output)
  124880. */
  124881. readonly xyOut: NodeMaterialConnectionPoint;
  124882. /**
  124883. * Gets the xy component (output)
  124884. * @deprecated Please use xyOut instead.
  124885. */
  124886. readonly xy: NodeMaterialConnectionPoint;
  124887. /**
  124888. * Gets the xyz component (output)
  124889. * @deprecated Please use xyzOut instead.
  124890. */
  124891. readonly xyz: NodeMaterialConnectionPoint;
  124892. protected _buildBlock(state: NodeMaterialBuildState): this;
  124893. }
  124894. }
  124895. declare module BABYLON {
  124896. /**
  124897. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  124898. */
  124899. export class ColorSplitterBlock extends NodeMaterialBlock {
  124900. /**
  124901. * Create a new ColorSplitterBlock
  124902. * @param name defines the block name
  124903. */
  124904. constructor(name: string);
  124905. /**
  124906. * Gets the current class name
  124907. * @returns the class name
  124908. */
  124909. getClassName(): string;
  124910. /**
  124911. * Gets the rgba component (input)
  124912. */
  124913. readonly rgba: NodeMaterialConnectionPoint;
  124914. /**
  124915. * Gets the rgb component (input)
  124916. */
  124917. readonly rgbIn: NodeMaterialConnectionPoint;
  124918. /**
  124919. * Gets the rgb component (output)
  124920. */
  124921. readonly rgbOut: NodeMaterialConnectionPoint;
  124922. /**
  124923. * Gets the r component (output)
  124924. */
  124925. readonly r: NodeMaterialConnectionPoint;
  124926. /**
  124927. * Gets the g component (output)
  124928. */
  124929. readonly g: NodeMaterialConnectionPoint;
  124930. /**
  124931. * Gets the b component (output)
  124932. */
  124933. readonly b: NodeMaterialConnectionPoint;
  124934. /**
  124935. * Gets the a component (output)
  124936. */
  124937. readonly a: NodeMaterialConnectionPoint;
  124938. protected _inputRename(name: string): string;
  124939. protected _outputRename(name: string): string;
  124940. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124941. }
  124942. }
  124943. declare module BABYLON {
  124944. /**
  124945. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124946. */
  124947. export class VectorSplitterBlock extends NodeMaterialBlock {
  124948. /**
  124949. * Create a new VectorSplitterBlock
  124950. * @param name defines the block name
  124951. */
  124952. constructor(name: string);
  124953. /**
  124954. * Gets the current class name
  124955. * @returns the class name
  124956. */
  124957. getClassName(): string;
  124958. /**
  124959. * Gets the xyzw component (input)
  124960. */
  124961. readonly xyzw: NodeMaterialConnectionPoint;
  124962. /**
  124963. * Gets the xyz component (input)
  124964. */
  124965. readonly xyzIn: NodeMaterialConnectionPoint;
  124966. /**
  124967. * Gets the xy component (input)
  124968. */
  124969. readonly xyIn: NodeMaterialConnectionPoint;
  124970. /**
  124971. * Gets the xyz component (output)
  124972. */
  124973. readonly xyzOut: NodeMaterialConnectionPoint;
  124974. /**
  124975. * Gets the xy component (output)
  124976. */
  124977. readonly xyOut: NodeMaterialConnectionPoint;
  124978. /**
  124979. * Gets the x component (output)
  124980. */
  124981. readonly x: NodeMaterialConnectionPoint;
  124982. /**
  124983. * Gets the y component (output)
  124984. */
  124985. readonly y: NodeMaterialConnectionPoint;
  124986. /**
  124987. * Gets the z component (output)
  124988. */
  124989. readonly z: NodeMaterialConnectionPoint;
  124990. /**
  124991. * Gets the w component (output)
  124992. */
  124993. readonly w: NodeMaterialConnectionPoint;
  124994. protected _inputRename(name: string): string;
  124995. protected _outputRename(name: string): string;
  124996. protected _buildBlock(state: NodeMaterialBuildState): this;
  124997. }
  124998. }
  124999. declare module BABYLON {
  125000. /**
  125001. * Block used to lerp between 2 values
  125002. */
  125003. export class LerpBlock extends NodeMaterialBlock {
  125004. /**
  125005. * Creates a new LerpBlock
  125006. * @param name defines the block name
  125007. */
  125008. constructor(name: string);
  125009. /**
  125010. * Gets the current class name
  125011. * @returns the class name
  125012. */
  125013. getClassName(): string;
  125014. /**
  125015. * Gets the left operand input component
  125016. */
  125017. readonly left: NodeMaterialConnectionPoint;
  125018. /**
  125019. * Gets the right operand input component
  125020. */
  125021. readonly right: NodeMaterialConnectionPoint;
  125022. /**
  125023. * Gets the gradient operand input component
  125024. */
  125025. readonly gradient: NodeMaterialConnectionPoint;
  125026. /**
  125027. * Gets the output component
  125028. */
  125029. readonly output: NodeMaterialConnectionPoint;
  125030. protected _buildBlock(state: NodeMaterialBuildState): this;
  125031. }
  125032. }
  125033. declare module BABYLON {
  125034. /**
  125035. * Block used to divide 2 vectors
  125036. */
  125037. export class DivideBlock extends NodeMaterialBlock {
  125038. /**
  125039. * Creates a new DivideBlock
  125040. * @param name defines the block name
  125041. */
  125042. constructor(name: string);
  125043. /**
  125044. * Gets the current class name
  125045. * @returns the class name
  125046. */
  125047. getClassName(): string;
  125048. /**
  125049. * Gets the left operand input component
  125050. */
  125051. readonly left: NodeMaterialConnectionPoint;
  125052. /**
  125053. * Gets the right operand input component
  125054. */
  125055. readonly right: NodeMaterialConnectionPoint;
  125056. /**
  125057. * Gets the output component
  125058. */
  125059. readonly output: NodeMaterialConnectionPoint;
  125060. protected _buildBlock(state: NodeMaterialBuildState): this;
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /**
  125065. * Block used to subtract 2 vectors
  125066. */
  125067. export class SubtractBlock extends NodeMaterialBlock {
  125068. /**
  125069. * Creates a new SubtractBlock
  125070. * @param name defines the block name
  125071. */
  125072. constructor(name: string);
  125073. /**
  125074. * Gets the current class name
  125075. * @returns the class name
  125076. */
  125077. getClassName(): string;
  125078. /**
  125079. * Gets the left operand input component
  125080. */
  125081. readonly left: NodeMaterialConnectionPoint;
  125082. /**
  125083. * Gets the right operand input component
  125084. */
  125085. readonly right: NodeMaterialConnectionPoint;
  125086. /**
  125087. * Gets the output component
  125088. */
  125089. readonly output: NodeMaterialConnectionPoint;
  125090. protected _buildBlock(state: NodeMaterialBuildState): this;
  125091. }
  125092. }
  125093. declare module BABYLON {
  125094. /**
  125095. * Block used to step a value
  125096. */
  125097. export class StepBlock extends NodeMaterialBlock {
  125098. /**
  125099. * Creates a new StepBlock
  125100. * @param name defines the block name
  125101. */
  125102. constructor(name: string);
  125103. /**
  125104. * Gets the current class name
  125105. * @returns the class name
  125106. */
  125107. getClassName(): string;
  125108. /**
  125109. * Gets the value operand input component
  125110. */
  125111. readonly value: NodeMaterialConnectionPoint;
  125112. /**
  125113. * Gets the edge operand input component
  125114. */
  125115. readonly edge: NodeMaterialConnectionPoint;
  125116. /**
  125117. * Gets the output component
  125118. */
  125119. readonly output: NodeMaterialConnectionPoint;
  125120. protected _buildBlock(state: NodeMaterialBuildState): this;
  125121. }
  125122. }
  125123. declare module BABYLON {
  125124. /**
  125125. * Block used to get the opposite (1 - x) of a value
  125126. */
  125127. export class OneMinusBlock extends NodeMaterialBlock {
  125128. /**
  125129. * Creates a new OneMinusBlock
  125130. * @param name defines the block name
  125131. */
  125132. constructor(name: string);
  125133. /**
  125134. * Gets the current class name
  125135. * @returns the class name
  125136. */
  125137. getClassName(): string;
  125138. /**
  125139. * Gets the input component
  125140. */
  125141. readonly input: NodeMaterialConnectionPoint;
  125142. /**
  125143. * Gets the output component
  125144. */
  125145. readonly output: NodeMaterialConnectionPoint;
  125146. protected _buildBlock(state: NodeMaterialBuildState): this;
  125147. }
  125148. }
  125149. declare module BABYLON {
  125150. /**
  125151. * Block used to get the view direction
  125152. */
  125153. export class ViewDirectionBlock extends NodeMaterialBlock {
  125154. /**
  125155. * Creates a new ViewDirectionBlock
  125156. * @param name defines the block name
  125157. */
  125158. constructor(name: string);
  125159. /**
  125160. * Gets the current class name
  125161. * @returns the class name
  125162. */
  125163. getClassName(): string;
  125164. /**
  125165. * Gets the world position component
  125166. */
  125167. readonly worldPosition: NodeMaterialConnectionPoint;
  125168. /**
  125169. * Gets the camera position component
  125170. */
  125171. readonly cameraPosition: NodeMaterialConnectionPoint;
  125172. /**
  125173. * Gets the output component
  125174. */
  125175. readonly output: NodeMaterialConnectionPoint;
  125176. autoConfigure(material: NodeMaterial): void;
  125177. protected _buildBlock(state: NodeMaterialBuildState): this;
  125178. }
  125179. }
  125180. declare module BABYLON {
  125181. /**
  125182. * Block used to compute fresnel value
  125183. */
  125184. export class FresnelBlock extends NodeMaterialBlock {
  125185. /**
  125186. * Create a new FresnelBlock
  125187. * @param name defines the block name
  125188. */
  125189. constructor(name: string);
  125190. /**
  125191. * Gets the current class name
  125192. * @returns the class name
  125193. */
  125194. getClassName(): string;
  125195. /**
  125196. * Gets the world normal input component
  125197. */
  125198. readonly worldNormal: NodeMaterialConnectionPoint;
  125199. /**
  125200. * Gets the view direction input component
  125201. */
  125202. readonly viewDirection: NodeMaterialConnectionPoint;
  125203. /**
  125204. * Gets the bias input component
  125205. */
  125206. readonly bias: NodeMaterialConnectionPoint;
  125207. /**
  125208. * Gets the camera (or eye) position component
  125209. */
  125210. readonly power: NodeMaterialConnectionPoint;
  125211. /**
  125212. * Gets the fresnel output component
  125213. */
  125214. readonly fresnel: NodeMaterialConnectionPoint;
  125215. autoConfigure(material: NodeMaterial): void;
  125216. protected _buildBlock(state: NodeMaterialBuildState): this;
  125217. }
  125218. }
  125219. declare module BABYLON {
  125220. /**
  125221. * Block used to get the max of 2 values
  125222. */
  125223. export class MaxBlock extends NodeMaterialBlock {
  125224. /**
  125225. * Creates a new MaxBlock
  125226. * @param name defines the block name
  125227. */
  125228. constructor(name: string);
  125229. /**
  125230. * Gets the current class name
  125231. * @returns the class name
  125232. */
  125233. getClassName(): string;
  125234. /**
  125235. * Gets the left operand input component
  125236. */
  125237. readonly left: NodeMaterialConnectionPoint;
  125238. /**
  125239. * Gets the right operand input component
  125240. */
  125241. readonly right: NodeMaterialConnectionPoint;
  125242. /**
  125243. * Gets the output component
  125244. */
  125245. readonly output: NodeMaterialConnectionPoint;
  125246. protected _buildBlock(state: NodeMaterialBuildState): this;
  125247. }
  125248. }
  125249. declare module BABYLON {
  125250. /**
  125251. * Block used to get the min of 2 values
  125252. */
  125253. export class MinBlock extends NodeMaterialBlock {
  125254. /**
  125255. * Creates a new MinBlock
  125256. * @param name defines the block name
  125257. */
  125258. constructor(name: string);
  125259. /**
  125260. * Gets the current class name
  125261. * @returns the class name
  125262. */
  125263. getClassName(): string;
  125264. /**
  125265. * Gets the left operand input component
  125266. */
  125267. readonly left: NodeMaterialConnectionPoint;
  125268. /**
  125269. * Gets the right operand input component
  125270. */
  125271. readonly right: NodeMaterialConnectionPoint;
  125272. /**
  125273. * Gets the output component
  125274. */
  125275. readonly output: NodeMaterialConnectionPoint;
  125276. protected _buildBlock(state: NodeMaterialBuildState): this;
  125277. }
  125278. }
  125279. declare module BABYLON {
  125280. /**
  125281. * Block used to get the distance between 2 values
  125282. */
  125283. export class DistanceBlock extends NodeMaterialBlock {
  125284. /**
  125285. * Creates a new DistanceBlock
  125286. * @param name defines the block name
  125287. */
  125288. constructor(name: string);
  125289. /**
  125290. * Gets the current class name
  125291. * @returns the class name
  125292. */
  125293. getClassName(): string;
  125294. /**
  125295. * Gets the left operand input component
  125296. */
  125297. readonly left: NodeMaterialConnectionPoint;
  125298. /**
  125299. * Gets the right operand input component
  125300. */
  125301. readonly right: NodeMaterialConnectionPoint;
  125302. /**
  125303. * Gets the output component
  125304. */
  125305. readonly output: NodeMaterialConnectionPoint;
  125306. protected _buildBlock(state: NodeMaterialBuildState): this;
  125307. }
  125308. }
  125309. declare module BABYLON {
  125310. /**
  125311. * Block used to get the length of a vector
  125312. */
  125313. export class LengthBlock extends NodeMaterialBlock {
  125314. /**
  125315. * Creates a new LengthBlock
  125316. * @param name defines the block name
  125317. */
  125318. constructor(name: string);
  125319. /**
  125320. * Gets the current class name
  125321. * @returns the class name
  125322. */
  125323. getClassName(): string;
  125324. /**
  125325. * Gets the value input component
  125326. */
  125327. readonly value: NodeMaterialConnectionPoint;
  125328. /**
  125329. * Gets the output component
  125330. */
  125331. readonly output: NodeMaterialConnectionPoint;
  125332. protected _buildBlock(state: NodeMaterialBuildState): this;
  125333. }
  125334. }
  125335. declare module BABYLON {
  125336. /**
  125337. * Block used to get negative version of a value (i.e. x * -1)
  125338. */
  125339. export class NegateBlock extends NodeMaterialBlock {
  125340. /**
  125341. * Creates a new NegateBlock
  125342. * @param name defines the block name
  125343. */
  125344. constructor(name: string);
  125345. /**
  125346. * Gets the current class name
  125347. * @returns the class name
  125348. */
  125349. getClassName(): string;
  125350. /**
  125351. * Gets the value input component
  125352. */
  125353. readonly value: NodeMaterialConnectionPoint;
  125354. /**
  125355. * Gets the output component
  125356. */
  125357. readonly output: NodeMaterialConnectionPoint;
  125358. protected _buildBlock(state: NodeMaterialBuildState): this;
  125359. }
  125360. }
  125361. declare module BABYLON {
  125362. /**
  125363. * Block used to get the value of the first parameter raised to the power of the second
  125364. */
  125365. export class PowBlock extends NodeMaterialBlock {
  125366. /**
  125367. * Creates a new PowBlock
  125368. * @param name defines the block name
  125369. */
  125370. constructor(name: string);
  125371. /**
  125372. * Gets the current class name
  125373. * @returns the class name
  125374. */
  125375. getClassName(): string;
  125376. /**
  125377. * Gets the value operand input component
  125378. */
  125379. readonly value: NodeMaterialConnectionPoint;
  125380. /**
  125381. * Gets the power operand input component
  125382. */
  125383. readonly power: NodeMaterialConnectionPoint;
  125384. /**
  125385. * Gets the output component
  125386. */
  125387. readonly output: NodeMaterialConnectionPoint;
  125388. protected _buildBlock(state: NodeMaterialBuildState): this;
  125389. }
  125390. }
  125391. declare module BABYLON {
  125392. /**
  125393. * Block used to get a random number
  125394. */
  125395. export class RandomNumberBlock extends NodeMaterialBlock {
  125396. /**
  125397. * Creates a new RandomNumberBlock
  125398. * @param name defines the block name
  125399. */
  125400. constructor(name: string);
  125401. /**
  125402. * Gets the current class name
  125403. * @returns the class name
  125404. */
  125405. getClassName(): string;
  125406. /**
  125407. * Gets the seed input component
  125408. */
  125409. readonly seed: NodeMaterialConnectionPoint;
  125410. /**
  125411. * Gets the output component
  125412. */
  125413. readonly output: NodeMaterialConnectionPoint;
  125414. protected _buildBlock(state: NodeMaterialBuildState): this;
  125415. }
  125416. }
  125417. declare module BABYLON {
  125418. /**
  125419. * Block used to compute arc tangent of 2 values
  125420. */
  125421. export class ArcTan2Block extends NodeMaterialBlock {
  125422. /**
  125423. * Creates a new ArcTan2Block
  125424. * @param name defines the block name
  125425. */
  125426. constructor(name: string);
  125427. /**
  125428. * Gets the current class name
  125429. * @returns the class name
  125430. */
  125431. getClassName(): string;
  125432. /**
  125433. * Gets the x operand input component
  125434. */
  125435. readonly x: NodeMaterialConnectionPoint;
  125436. /**
  125437. * Gets the y operand input component
  125438. */
  125439. readonly y: NodeMaterialConnectionPoint;
  125440. /**
  125441. * Gets the output component
  125442. */
  125443. readonly output: NodeMaterialConnectionPoint;
  125444. protected _buildBlock(state: NodeMaterialBuildState): this;
  125445. }
  125446. }
  125447. declare module BABYLON {
  125448. /**
  125449. * Block used to smooth step a value
  125450. */
  125451. export class SmoothStepBlock extends NodeMaterialBlock {
  125452. /**
  125453. * Creates a new SmoothStepBlock
  125454. * @param name defines the block name
  125455. */
  125456. constructor(name: string);
  125457. /**
  125458. * Gets the current class name
  125459. * @returns the class name
  125460. */
  125461. getClassName(): string;
  125462. /**
  125463. * Gets the value operand input component
  125464. */
  125465. readonly value: NodeMaterialConnectionPoint;
  125466. /**
  125467. * Gets the first edge operand input component
  125468. */
  125469. readonly edge0: NodeMaterialConnectionPoint;
  125470. /**
  125471. * Gets the second edge operand input component
  125472. */
  125473. readonly edge1: NodeMaterialConnectionPoint;
  125474. /**
  125475. * Gets the output component
  125476. */
  125477. readonly output: NodeMaterialConnectionPoint;
  125478. protected _buildBlock(state: NodeMaterialBuildState): this;
  125479. }
  125480. }
  125481. declare module BABYLON {
  125482. /**
  125483. * Block used to get the reciprocal (1 / x) of a value
  125484. */
  125485. export class ReciprocalBlock extends NodeMaterialBlock {
  125486. /**
  125487. * Creates a new ReciprocalBlock
  125488. * @param name defines the block name
  125489. */
  125490. constructor(name: string);
  125491. /**
  125492. * Gets the current class name
  125493. * @returns the class name
  125494. */
  125495. getClassName(): string;
  125496. /**
  125497. * Gets the input component
  125498. */
  125499. readonly input: NodeMaterialConnectionPoint;
  125500. /**
  125501. * Gets the output component
  125502. */
  125503. readonly output: NodeMaterialConnectionPoint;
  125504. protected _buildBlock(state: NodeMaterialBuildState): this;
  125505. }
  125506. }
  125507. declare module BABYLON {
  125508. /**
  125509. * Block used to replace a color by another one
  125510. */
  125511. export class ReplaceColorBlock extends NodeMaterialBlock {
  125512. /**
  125513. * Creates a new ReplaceColorBlock
  125514. * @param name defines the block name
  125515. */
  125516. constructor(name: string);
  125517. /**
  125518. * Gets the current class name
  125519. * @returns the class name
  125520. */
  125521. getClassName(): string;
  125522. /**
  125523. * Gets the value input component
  125524. */
  125525. readonly value: NodeMaterialConnectionPoint;
  125526. /**
  125527. * Gets the reference input component
  125528. */
  125529. readonly reference: NodeMaterialConnectionPoint;
  125530. /**
  125531. * Gets the distance input component
  125532. */
  125533. readonly distance: NodeMaterialConnectionPoint;
  125534. /**
  125535. * Gets the replacement input component
  125536. */
  125537. readonly replacement: NodeMaterialConnectionPoint;
  125538. /**
  125539. * Gets the output component
  125540. */
  125541. readonly output: NodeMaterialConnectionPoint;
  125542. protected _buildBlock(state: NodeMaterialBuildState): this;
  125543. }
  125544. }
  125545. declare module BABYLON {
  125546. /**
  125547. * Block used to posterize a value
  125548. * @see https://en.wikipedia.org/wiki/Posterization
  125549. */
  125550. export class PosterizeBlock extends NodeMaterialBlock {
  125551. /**
  125552. * Creates a new PosterizeBlock
  125553. * @param name defines the block name
  125554. */
  125555. constructor(name: string);
  125556. /**
  125557. * Gets the current class name
  125558. * @returns the class name
  125559. */
  125560. getClassName(): string;
  125561. /**
  125562. * Gets the value input component
  125563. */
  125564. readonly value: NodeMaterialConnectionPoint;
  125565. /**
  125566. * Gets the steps input component
  125567. */
  125568. readonly steps: NodeMaterialConnectionPoint;
  125569. /**
  125570. * Gets the output component
  125571. */
  125572. readonly output: NodeMaterialConnectionPoint;
  125573. protected _buildBlock(state: NodeMaterialBuildState): this;
  125574. }
  125575. }
  125576. declare module BABYLON {
  125577. /**
  125578. * Operations supported by the Wave block
  125579. */
  125580. export enum WaveBlockKind {
  125581. /** SawTooth */
  125582. SawTooth = 0,
  125583. /** Square */
  125584. Square = 1,
  125585. /** Triangle */
  125586. Triangle = 2
  125587. }
  125588. /**
  125589. * Block used to apply wave operation to floats
  125590. */
  125591. export class WaveBlock extends NodeMaterialBlock {
  125592. /**
  125593. * Gets or sets the kibnd of wave to be applied by the block
  125594. */
  125595. kind: WaveBlockKind;
  125596. /**
  125597. * Creates a new WaveBlock
  125598. * @param name defines the block name
  125599. */
  125600. constructor(name: string);
  125601. /**
  125602. * Gets the current class name
  125603. * @returns the class name
  125604. */
  125605. getClassName(): string;
  125606. /**
  125607. * Gets the input component
  125608. */
  125609. readonly input: NodeMaterialConnectionPoint;
  125610. /**
  125611. * Gets the output component
  125612. */
  125613. readonly output: NodeMaterialConnectionPoint;
  125614. protected _buildBlock(state: NodeMaterialBuildState): this;
  125615. serialize(): any;
  125616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125617. }
  125618. }
  125619. declare module BABYLON {
  125620. /**
  125621. * Class used to store a color step for the GradientBlock
  125622. */
  125623. export class GradientBlockColorStep {
  125624. /**
  125625. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125626. */
  125627. step: number;
  125628. /**
  125629. * Gets or sets the color associated with this step
  125630. */
  125631. color: Color3;
  125632. /**
  125633. * Creates a new GradientBlockColorStep
  125634. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  125635. * @param color defines the color associated with this step
  125636. */
  125637. constructor(
  125638. /**
  125639. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  125640. */
  125641. step: number,
  125642. /**
  125643. * Gets or sets the color associated with this step
  125644. */
  125645. color: Color3);
  125646. }
  125647. /**
  125648. * Block used to return a color from a gradient based on an input value between 0 and 1
  125649. */
  125650. export class GradientBlock extends NodeMaterialBlock {
  125651. /**
  125652. * Gets or sets the list of color steps
  125653. */
  125654. colorSteps: GradientBlockColorStep[];
  125655. /**
  125656. * Creates a new GradientBlock
  125657. * @param name defines the block name
  125658. */
  125659. constructor(name: string);
  125660. /**
  125661. * Gets the current class name
  125662. * @returns the class name
  125663. */
  125664. getClassName(): string;
  125665. /**
  125666. * Gets the gradient input component
  125667. */
  125668. readonly gradient: NodeMaterialConnectionPoint;
  125669. /**
  125670. * Gets the output component
  125671. */
  125672. readonly output: NodeMaterialConnectionPoint;
  125673. private _writeColorConstant;
  125674. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125675. serialize(): any;
  125676. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125677. protected _dumpPropertiesCode(): string;
  125678. }
  125679. }
  125680. declare module BABYLON {
  125681. /**
  125682. * Block used to normalize lerp between 2 values
  125683. */
  125684. export class NLerpBlock extends NodeMaterialBlock {
  125685. /**
  125686. * Creates a new NLerpBlock
  125687. * @param name defines the block name
  125688. */
  125689. constructor(name: string);
  125690. /**
  125691. * Gets the current class name
  125692. * @returns the class name
  125693. */
  125694. getClassName(): string;
  125695. /**
  125696. * Gets the left operand input component
  125697. */
  125698. readonly left: NodeMaterialConnectionPoint;
  125699. /**
  125700. * Gets the right operand input component
  125701. */
  125702. readonly right: NodeMaterialConnectionPoint;
  125703. /**
  125704. * Gets the gradient operand input component
  125705. */
  125706. readonly gradient: NodeMaterialConnectionPoint;
  125707. /**
  125708. * Gets the output component
  125709. */
  125710. readonly output: NodeMaterialConnectionPoint;
  125711. protected _buildBlock(state: NodeMaterialBuildState): this;
  125712. }
  125713. }
  125714. declare module BABYLON {
  125715. /**
  125716. * block used to Generate a Worley Noise 3D Noise Pattern
  125717. */
  125718. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  125719. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  125720. manhattanDistance: boolean;
  125721. /**
  125722. * Creates a new WorleyNoise3DBlock
  125723. * @param name defines the block name
  125724. */
  125725. constructor(name: string);
  125726. /**
  125727. * Gets the current class name
  125728. * @returns the class name
  125729. */
  125730. getClassName(): string;
  125731. /**
  125732. * Gets the seed input component
  125733. */
  125734. readonly seed: NodeMaterialConnectionPoint;
  125735. /**
  125736. * Gets the jitter input component
  125737. */
  125738. readonly jitter: NodeMaterialConnectionPoint;
  125739. /**
  125740. * Gets the output component
  125741. */
  125742. readonly output: NodeMaterialConnectionPoint;
  125743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125744. /**
  125745. * Exposes the properties to the UI?
  125746. */
  125747. protected _dumpPropertiesCode(): string;
  125748. /**
  125749. * Exposes the properties to the Seralize?
  125750. */
  125751. serialize(): any;
  125752. /**
  125753. * Exposes the properties to the deseralize?
  125754. */
  125755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125756. }
  125757. }
  125758. declare module BABYLON {
  125759. /**
  125760. * block used to Generate a Simplex Perlin 3d Noise Pattern
  125761. */
  125762. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  125763. /**
  125764. * Creates a new SimplexPerlin3DBlock
  125765. * @param name defines the block name
  125766. */
  125767. constructor(name: string);
  125768. /**
  125769. * Gets the current class name
  125770. * @returns the class name
  125771. */
  125772. getClassName(): string;
  125773. /**
  125774. * Gets the seed operand input component
  125775. */
  125776. readonly seed: NodeMaterialConnectionPoint;
  125777. /**
  125778. * Gets the output component
  125779. */
  125780. readonly output: NodeMaterialConnectionPoint;
  125781. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125782. }
  125783. }
  125784. declare module BABYLON {
  125785. /**
  125786. * Block used to blend normals
  125787. */
  125788. export class NormalBlendBlock extends NodeMaterialBlock {
  125789. /**
  125790. * Creates a new NormalBlendBlock
  125791. * @param name defines the block name
  125792. */
  125793. constructor(name: string);
  125794. /**
  125795. * Gets the current class name
  125796. * @returns the class name
  125797. */
  125798. getClassName(): string;
  125799. /**
  125800. * Gets the first input component
  125801. */
  125802. readonly normalMap0: NodeMaterialConnectionPoint;
  125803. /**
  125804. * Gets the second input component
  125805. */
  125806. readonly normalMap1: NodeMaterialConnectionPoint;
  125807. /**
  125808. * Gets the output component
  125809. */
  125810. readonly output: NodeMaterialConnectionPoint;
  125811. protected _buildBlock(state: NodeMaterialBuildState): this;
  125812. }
  125813. }
  125814. declare module BABYLON {
  125815. /**
  125816. * Block used to rotate a 2d vector by a given angle
  125817. */
  125818. export class Rotate2dBlock extends NodeMaterialBlock {
  125819. /**
  125820. * Creates a new Rotate2dBlock
  125821. * @param name defines the block name
  125822. */
  125823. constructor(name: string);
  125824. /**
  125825. * Gets the current class name
  125826. * @returns the class name
  125827. */
  125828. getClassName(): string;
  125829. /**
  125830. * Gets the input vector
  125831. */
  125832. readonly input: NodeMaterialConnectionPoint;
  125833. /**
  125834. * Gets the input angle
  125835. */
  125836. readonly angle: NodeMaterialConnectionPoint;
  125837. /**
  125838. * Gets the output component
  125839. */
  125840. readonly output: NodeMaterialConnectionPoint;
  125841. autoConfigure(material: NodeMaterial): void;
  125842. protected _buildBlock(state: NodeMaterialBuildState): this;
  125843. }
  125844. }
  125845. declare module BABYLON {
  125846. /**
  125847. * Block used to get the reflected vector from a direction and a normal
  125848. */
  125849. export class ReflectBlock extends NodeMaterialBlock {
  125850. /**
  125851. * Creates a new ReflectBlock
  125852. * @param name defines the block name
  125853. */
  125854. constructor(name: string);
  125855. /**
  125856. * Gets the current class name
  125857. * @returns the class name
  125858. */
  125859. getClassName(): string;
  125860. /**
  125861. * Gets the incident component
  125862. */
  125863. readonly incident: NodeMaterialConnectionPoint;
  125864. /**
  125865. * Gets the normal component
  125866. */
  125867. readonly normal: NodeMaterialConnectionPoint;
  125868. /**
  125869. * Gets the output component
  125870. */
  125871. readonly output: NodeMaterialConnectionPoint;
  125872. protected _buildBlock(state: NodeMaterialBuildState): this;
  125873. }
  125874. }
  125875. declare module BABYLON {
  125876. /**
  125877. * Block used to get the refracted vector from a direction and a normal
  125878. */
  125879. export class RefractBlock extends NodeMaterialBlock {
  125880. /**
  125881. * Creates a new RefractBlock
  125882. * @param name defines the block name
  125883. */
  125884. constructor(name: string);
  125885. /**
  125886. * Gets the current class name
  125887. * @returns the class name
  125888. */
  125889. getClassName(): string;
  125890. /**
  125891. * Gets the incident component
  125892. */
  125893. readonly incident: NodeMaterialConnectionPoint;
  125894. /**
  125895. * Gets the normal component
  125896. */
  125897. readonly normal: NodeMaterialConnectionPoint;
  125898. /**
  125899. * Gets the index of refraction component
  125900. */
  125901. readonly ior: NodeMaterialConnectionPoint;
  125902. /**
  125903. * Gets the output component
  125904. */
  125905. readonly output: NodeMaterialConnectionPoint;
  125906. protected _buildBlock(state: NodeMaterialBuildState): this;
  125907. }
  125908. }
  125909. declare module BABYLON {
  125910. /**
  125911. * Block used to desaturate a color
  125912. */
  125913. export class DesaturateBlock extends NodeMaterialBlock {
  125914. /**
  125915. * Creates a new DesaturateBlock
  125916. * @param name defines the block name
  125917. */
  125918. constructor(name: string);
  125919. /**
  125920. * Gets the current class name
  125921. * @returns the class name
  125922. */
  125923. getClassName(): string;
  125924. /**
  125925. * Gets the color operand input component
  125926. */
  125927. readonly color: NodeMaterialConnectionPoint;
  125928. /**
  125929. * Gets the level operand input component
  125930. */
  125931. readonly level: NodeMaterialConnectionPoint;
  125932. /**
  125933. * Gets the output component
  125934. */
  125935. readonly output: NodeMaterialConnectionPoint;
  125936. protected _buildBlock(state: NodeMaterialBuildState): this;
  125937. }
  125938. }
  125939. declare module BABYLON {
  125940. /**
  125941. * Effect Render Options
  125942. */
  125943. export interface IEffectRendererOptions {
  125944. /**
  125945. * Defines the vertices positions.
  125946. */
  125947. positions?: number[];
  125948. /**
  125949. * Defines the indices.
  125950. */
  125951. indices?: number[];
  125952. }
  125953. /**
  125954. * Helper class to render one or more effects
  125955. */
  125956. export class EffectRenderer {
  125957. private engine;
  125958. private static _DefaultOptions;
  125959. private _vertexBuffers;
  125960. private _indexBuffer;
  125961. private _ringBufferIndex;
  125962. private _ringScreenBuffer;
  125963. private _fullscreenViewport;
  125964. private _getNextFrameBuffer;
  125965. /**
  125966. * Creates an effect renderer
  125967. * @param engine the engine to use for rendering
  125968. * @param options defines the options of the effect renderer
  125969. */
  125970. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  125971. /**
  125972. * Sets the current viewport in normalized coordinates 0-1
  125973. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  125974. */
  125975. setViewport(viewport?: Viewport): void;
  125976. /**
  125977. * Binds the embedded attributes buffer to the effect.
  125978. * @param effect Defines the effect to bind the attributes for
  125979. */
  125980. bindBuffers(effect: Effect): void;
  125981. /**
  125982. * Sets the current effect wrapper to use during draw.
  125983. * The effect needs to be ready before calling this api.
  125984. * This also sets the default full screen position attribute.
  125985. * @param effectWrapper Defines the effect to draw with
  125986. */
  125987. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  125988. /**
  125989. * Draws a full screen quad.
  125990. */
  125991. draw(): void;
  125992. /**
  125993. * renders one or more effects to a specified texture
  125994. * @param effectWrappers list of effects to renderer
  125995. * @param outputTexture texture to draw to, if null it will render to the screen
  125996. */
  125997. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  125998. /**
  125999. * Disposes of the effect renderer
  126000. */
  126001. dispose(): void;
  126002. }
  126003. /**
  126004. * Options to create an EffectWrapper
  126005. */
  126006. interface EffectWrapperCreationOptions {
  126007. /**
  126008. * Engine to use to create the effect
  126009. */
  126010. engine: ThinEngine;
  126011. /**
  126012. * Fragment shader for the effect
  126013. */
  126014. fragmentShader: string;
  126015. /**
  126016. * Vertex shader for the effect
  126017. */
  126018. vertexShader?: string;
  126019. /**
  126020. * Attributes to use in the shader
  126021. */
  126022. attributeNames?: Array<string>;
  126023. /**
  126024. * Uniforms to use in the shader
  126025. */
  126026. uniformNames?: Array<string>;
  126027. /**
  126028. * Texture sampler names to use in the shader
  126029. */
  126030. samplerNames?: Array<string>;
  126031. /**
  126032. * The friendly name of the effect displayed in Spector.
  126033. */
  126034. name?: string;
  126035. }
  126036. /**
  126037. * Wraps an effect to be used for rendering
  126038. */
  126039. export class EffectWrapper {
  126040. /**
  126041. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126042. */
  126043. onApplyObservable: Observable<{}>;
  126044. /**
  126045. * The underlying effect
  126046. */
  126047. effect: Effect;
  126048. /**
  126049. * Creates an effect to be renderer
  126050. * @param creationOptions options to create the effect
  126051. */
  126052. constructor(creationOptions: EffectWrapperCreationOptions);
  126053. /**
  126054. * Disposes of the effect wrapper
  126055. */
  126056. dispose(): void;
  126057. }
  126058. }
  126059. declare module BABYLON {
  126060. /**
  126061. * Helper class to push actions to a pool of workers.
  126062. */
  126063. export class WorkerPool implements IDisposable {
  126064. private _workerInfos;
  126065. private _pendingActions;
  126066. /**
  126067. * Constructor
  126068. * @param workers Array of workers to use for actions
  126069. */
  126070. constructor(workers: Array<Worker>);
  126071. /**
  126072. * Terminates all workers and clears any pending actions.
  126073. */
  126074. dispose(): void;
  126075. /**
  126076. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126077. * pended until a worker has completed its action.
  126078. * @param action The action to perform. Call onComplete when the action is complete.
  126079. */
  126080. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126081. private _execute;
  126082. }
  126083. }
  126084. declare module BABYLON {
  126085. /**
  126086. * Configuration for Draco compression
  126087. */
  126088. export interface IDracoCompressionConfiguration {
  126089. /**
  126090. * Configuration for the decoder.
  126091. */
  126092. decoder: {
  126093. /**
  126094. * The url to the WebAssembly module.
  126095. */
  126096. wasmUrl?: string;
  126097. /**
  126098. * The url to the WebAssembly binary.
  126099. */
  126100. wasmBinaryUrl?: string;
  126101. /**
  126102. * The url to the fallback JavaScript module.
  126103. */
  126104. fallbackUrl?: string;
  126105. };
  126106. }
  126107. /**
  126108. * Draco compression (https://google.github.io/draco/)
  126109. *
  126110. * This class wraps the Draco module.
  126111. *
  126112. * **Encoder**
  126113. *
  126114. * The encoder is not currently implemented.
  126115. *
  126116. * **Decoder**
  126117. *
  126118. * 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.
  126119. *
  126120. * To update the configuration, use the following code:
  126121. * ```javascript
  126122. * DracoCompression.Configuration = {
  126123. * decoder: {
  126124. * wasmUrl: "<url to the WebAssembly library>",
  126125. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126126. * fallbackUrl: "<url to the fallback JavaScript library>",
  126127. * }
  126128. * };
  126129. * ```
  126130. *
  126131. * 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.
  126132. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126133. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126134. *
  126135. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126136. * ```javascript
  126137. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126138. * ```
  126139. *
  126140. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126141. */
  126142. export class DracoCompression implements IDisposable {
  126143. private _workerPoolPromise?;
  126144. private _decoderModulePromise?;
  126145. /**
  126146. * The configuration. Defaults to the following urls:
  126147. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126148. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126149. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126150. */
  126151. static Configuration: IDracoCompressionConfiguration;
  126152. /**
  126153. * Returns true if the decoder configuration is available.
  126154. */
  126155. static readonly DecoderAvailable: boolean;
  126156. /**
  126157. * Default number of workers to create when creating the draco compression object.
  126158. */
  126159. static DefaultNumWorkers: number;
  126160. private static GetDefaultNumWorkers;
  126161. private static _Default;
  126162. /**
  126163. * Default instance for the draco compression object.
  126164. */
  126165. static readonly Default: DracoCompression;
  126166. /**
  126167. * Constructor
  126168. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126169. */
  126170. constructor(numWorkers?: number);
  126171. /**
  126172. * Stop all async operations and release resources.
  126173. */
  126174. dispose(): void;
  126175. /**
  126176. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126177. * @returns a promise that resolves when ready
  126178. */
  126179. whenReadyAsync(): Promise<void>;
  126180. /**
  126181. * Decode Draco compressed mesh data to vertex data.
  126182. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126183. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126184. * @returns A promise that resolves with the decoded vertex data
  126185. */
  126186. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126187. [kind: string]: number;
  126188. }): Promise<VertexData>;
  126189. }
  126190. }
  126191. declare module BABYLON {
  126192. /**
  126193. * Class for building Constructive Solid Geometry
  126194. */
  126195. export class CSG {
  126196. private polygons;
  126197. /**
  126198. * The world matrix
  126199. */
  126200. matrix: Matrix;
  126201. /**
  126202. * Stores the position
  126203. */
  126204. position: Vector3;
  126205. /**
  126206. * Stores the rotation
  126207. */
  126208. rotation: Vector3;
  126209. /**
  126210. * Stores the rotation quaternion
  126211. */
  126212. rotationQuaternion: Nullable<Quaternion>;
  126213. /**
  126214. * Stores the scaling vector
  126215. */
  126216. scaling: Vector3;
  126217. /**
  126218. * Convert the Mesh to CSG
  126219. * @param mesh The Mesh to convert to CSG
  126220. * @returns A new CSG from the Mesh
  126221. */
  126222. static FromMesh(mesh: Mesh): CSG;
  126223. /**
  126224. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126225. * @param polygons Polygons used to construct a CSG solid
  126226. */
  126227. private static FromPolygons;
  126228. /**
  126229. * Clones, or makes a deep copy, of the CSG
  126230. * @returns A new CSG
  126231. */
  126232. clone(): CSG;
  126233. /**
  126234. * Unions this CSG with another CSG
  126235. * @param csg The CSG to union against this CSG
  126236. * @returns The unioned CSG
  126237. */
  126238. union(csg: CSG): CSG;
  126239. /**
  126240. * Unions this CSG with another CSG in place
  126241. * @param csg The CSG to union against this CSG
  126242. */
  126243. unionInPlace(csg: CSG): void;
  126244. /**
  126245. * Subtracts this CSG with another CSG
  126246. * @param csg The CSG to subtract against this CSG
  126247. * @returns A new CSG
  126248. */
  126249. subtract(csg: CSG): CSG;
  126250. /**
  126251. * Subtracts this CSG with another CSG in place
  126252. * @param csg The CSG to subtact against this CSG
  126253. */
  126254. subtractInPlace(csg: CSG): void;
  126255. /**
  126256. * Intersect this CSG with another CSG
  126257. * @param csg The CSG to intersect against this CSG
  126258. * @returns A new CSG
  126259. */
  126260. intersect(csg: CSG): CSG;
  126261. /**
  126262. * Intersects this CSG with another CSG in place
  126263. * @param csg The CSG to intersect against this CSG
  126264. */
  126265. intersectInPlace(csg: CSG): void;
  126266. /**
  126267. * Return a new CSG solid with solid and empty space switched. This solid is
  126268. * not modified.
  126269. * @returns A new CSG solid with solid and empty space switched
  126270. */
  126271. inverse(): CSG;
  126272. /**
  126273. * Inverses the CSG in place
  126274. */
  126275. inverseInPlace(): void;
  126276. /**
  126277. * This is used to keep meshes transformations so they can be restored
  126278. * when we build back a Babylon Mesh
  126279. * NB : All CSG operations are performed in world coordinates
  126280. * @param csg The CSG to copy the transform attributes from
  126281. * @returns This CSG
  126282. */
  126283. copyTransformAttributes(csg: CSG): CSG;
  126284. /**
  126285. * Build Raw mesh from CSG
  126286. * Coordinates here are in world space
  126287. * @param name The name of the mesh geometry
  126288. * @param scene The Scene
  126289. * @param keepSubMeshes Specifies if the submeshes should be kept
  126290. * @returns A new Mesh
  126291. */
  126292. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126293. /**
  126294. * Build Mesh from CSG taking material and transforms into account
  126295. * @param name The name of the Mesh
  126296. * @param material The material of the Mesh
  126297. * @param scene The Scene
  126298. * @param keepSubMeshes Specifies if submeshes should be kept
  126299. * @returns The new Mesh
  126300. */
  126301. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126302. }
  126303. }
  126304. declare module BABYLON {
  126305. /**
  126306. * Class used to create a trail following a mesh
  126307. */
  126308. export class TrailMesh extends Mesh {
  126309. private _generator;
  126310. private _autoStart;
  126311. private _running;
  126312. private _diameter;
  126313. private _length;
  126314. private _sectionPolygonPointsCount;
  126315. private _sectionVectors;
  126316. private _sectionNormalVectors;
  126317. private _beforeRenderObserver;
  126318. /**
  126319. * @constructor
  126320. * @param name The value used by scene.getMeshByName() to do a lookup.
  126321. * @param generator The mesh to generate a trail.
  126322. * @param scene The scene to add this mesh to.
  126323. * @param diameter Diameter of trailing mesh. Default is 1.
  126324. * @param length Length of trailing mesh. Default is 60.
  126325. * @param autoStart Automatically start trailing mesh. Default true.
  126326. */
  126327. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126328. /**
  126329. * "TrailMesh"
  126330. * @returns "TrailMesh"
  126331. */
  126332. getClassName(): string;
  126333. private _createMesh;
  126334. /**
  126335. * Start trailing mesh.
  126336. */
  126337. start(): void;
  126338. /**
  126339. * Stop trailing mesh.
  126340. */
  126341. stop(): void;
  126342. /**
  126343. * Update trailing mesh geometry.
  126344. */
  126345. update(): void;
  126346. /**
  126347. * Returns a new TrailMesh object.
  126348. * @param name is a string, the name given to the new mesh
  126349. * @param newGenerator use new generator object for cloned trail mesh
  126350. * @returns a new mesh
  126351. */
  126352. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  126353. /**
  126354. * Serializes this trail mesh
  126355. * @param serializationObject object to write serialization to
  126356. */
  126357. serialize(serializationObject: any): void;
  126358. /**
  126359. * Parses a serialized trail mesh
  126360. * @param parsedMesh the serialized mesh
  126361. * @param scene the scene to create the trail mesh in
  126362. * @returns the created trail mesh
  126363. */
  126364. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  126365. }
  126366. }
  126367. declare module BABYLON {
  126368. /**
  126369. * Class containing static functions to help procedurally build meshes
  126370. */
  126371. export class TiledBoxBuilder {
  126372. /**
  126373. * Creates a box mesh
  126374. * 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)
  126375. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126379. * @param name defines the name of the mesh
  126380. * @param options defines the options used to create the mesh
  126381. * @param scene defines the hosting scene
  126382. * @returns the box mesh
  126383. */
  126384. static CreateTiledBox(name: string, options: {
  126385. pattern?: number;
  126386. width?: number;
  126387. height?: number;
  126388. depth?: number;
  126389. tileSize?: number;
  126390. tileWidth?: number;
  126391. tileHeight?: number;
  126392. alignHorizontal?: number;
  126393. alignVertical?: number;
  126394. faceUV?: Vector4[];
  126395. faceColors?: Color4[];
  126396. sideOrientation?: number;
  126397. updatable?: boolean;
  126398. }, scene?: Nullable<Scene>): Mesh;
  126399. }
  126400. }
  126401. declare module BABYLON {
  126402. /**
  126403. * Class containing static functions to help procedurally build meshes
  126404. */
  126405. export class TorusKnotBuilder {
  126406. /**
  126407. * Creates a torus knot mesh
  126408. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126409. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126410. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126411. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126415. * @param name defines the name of the mesh
  126416. * @param options defines the options used to create the mesh
  126417. * @param scene defines the hosting scene
  126418. * @returns the torus knot mesh
  126419. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126420. */
  126421. static CreateTorusKnot(name: string, options: {
  126422. radius?: number;
  126423. tube?: number;
  126424. radialSegments?: number;
  126425. tubularSegments?: number;
  126426. p?: number;
  126427. q?: number;
  126428. updatable?: boolean;
  126429. sideOrientation?: number;
  126430. frontUVs?: Vector4;
  126431. backUVs?: Vector4;
  126432. }, scene: any): Mesh;
  126433. }
  126434. }
  126435. declare module BABYLON {
  126436. /**
  126437. * Polygon
  126438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  126439. */
  126440. export class Polygon {
  126441. /**
  126442. * Creates a rectangle
  126443. * @param xmin bottom X coord
  126444. * @param ymin bottom Y coord
  126445. * @param xmax top X coord
  126446. * @param ymax top Y coord
  126447. * @returns points that make the resulting rectation
  126448. */
  126449. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  126450. /**
  126451. * Creates a circle
  126452. * @param radius radius of circle
  126453. * @param cx scale in x
  126454. * @param cy scale in y
  126455. * @param numberOfSides number of sides that make up the circle
  126456. * @returns points that make the resulting circle
  126457. */
  126458. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  126459. /**
  126460. * Creates a polygon from input string
  126461. * @param input Input polygon data
  126462. * @returns the parsed points
  126463. */
  126464. static Parse(input: string): Vector2[];
  126465. /**
  126466. * Starts building a polygon from x and y coordinates
  126467. * @param x x coordinate
  126468. * @param y y coordinate
  126469. * @returns the started path2
  126470. */
  126471. static StartingAt(x: number, y: number): Path2;
  126472. }
  126473. /**
  126474. * Builds a polygon
  126475. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  126476. */
  126477. export class PolygonMeshBuilder {
  126478. private _points;
  126479. private _outlinepoints;
  126480. private _holes;
  126481. private _name;
  126482. private _scene;
  126483. private _epoints;
  126484. private _eholes;
  126485. private _addToepoint;
  126486. /**
  126487. * Babylon reference to the earcut plugin.
  126488. */
  126489. bjsEarcut: any;
  126490. /**
  126491. * Creates a PolygonMeshBuilder
  126492. * @param name name of the builder
  126493. * @param contours Path of the polygon
  126494. * @param scene scene to add to when creating the mesh
  126495. * @param earcutInjection can be used to inject your own earcut reference
  126496. */
  126497. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  126498. /**
  126499. * Adds a whole within the polygon
  126500. * @param hole Array of points defining the hole
  126501. * @returns this
  126502. */
  126503. addHole(hole: Vector2[]): PolygonMeshBuilder;
  126504. /**
  126505. * Creates the polygon
  126506. * @param updatable If the mesh should be updatable
  126507. * @param depth The depth of the mesh created
  126508. * @returns the created mesh
  126509. */
  126510. build(updatable?: boolean, depth?: number): Mesh;
  126511. /**
  126512. * Creates the polygon
  126513. * @param depth The depth of the mesh created
  126514. * @returns the created VertexData
  126515. */
  126516. buildVertexData(depth?: number): VertexData;
  126517. /**
  126518. * Adds a side to the polygon
  126519. * @param positions points that make the polygon
  126520. * @param normals normals of the polygon
  126521. * @param uvs uvs of the polygon
  126522. * @param indices indices of the polygon
  126523. * @param bounds bounds of the polygon
  126524. * @param points points of the polygon
  126525. * @param depth depth of the polygon
  126526. * @param flip flip of the polygon
  126527. */
  126528. private addSide;
  126529. }
  126530. }
  126531. declare module BABYLON {
  126532. /**
  126533. * Class containing static functions to help procedurally build meshes
  126534. */
  126535. export class PolygonBuilder {
  126536. /**
  126537. * Creates a polygon mesh
  126538. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126539. * * 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
  126540. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126542. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126543. * * Remember you can only change the shape positions, not their number when updating a polygon
  126544. * @param name defines the name of the mesh
  126545. * @param options defines the options used to create the mesh
  126546. * @param scene defines the hosting scene
  126547. * @param earcutInjection can be used to inject your own earcut reference
  126548. * @returns the polygon mesh
  126549. */
  126550. static CreatePolygon(name: string, options: {
  126551. shape: Vector3[];
  126552. holes?: Vector3[][];
  126553. depth?: number;
  126554. faceUV?: Vector4[];
  126555. faceColors?: Color4[];
  126556. updatable?: boolean;
  126557. sideOrientation?: number;
  126558. frontUVs?: Vector4;
  126559. backUVs?: Vector4;
  126560. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126561. /**
  126562. * Creates an extruded polygon mesh, with depth in the Y direction.
  126563. * * 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)
  126564. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126565. * @param name defines the name of the mesh
  126566. * @param options defines the options used to create the mesh
  126567. * @param scene defines the hosting scene
  126568. * @param earcutInjection can be used to inject your own earcut reference
  126569. * @returns the polygon mesh
  126570. */
  126571. static ExtrudePolygon(name: string, options: {
  126572. shape: Vector3[];
  126573. holes?: Vector3[][];
  126574. depth?: number;
  126575. faceUV?: Vector4[];
  126576. faceColors?: Color4[];
  126577. updatable?: boolean;
  126578. sideOrientation?: number;
  126579. frontUVs?: Vector4;
  126580. backUVs?: Vector4;
  126581. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126582. }
  126583. }
  126584. declare module BABYLON {
  126585. /**
  126586. * Class containing static functions to help procedurally build meshes
  126587. */
  126588. export class LatheBuilder {
  126589. /**
  126590. * Creates lathe mesh.
  126591. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126592. * * 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
  126593. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126594. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126595. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126596. * * 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
  126597. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126598. * * 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
  126599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126603. * @param name defines the name of the mesh
  126604. * @param options defines the options used to create the mesh
  126605. * @param scene defines the hosting scene
  126606. * @returns the lathe mesh
  126607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126608. */
  126609. static CreateLathe(name: string, options: {
  126610. shape: Vector3[];
  126611. radius?: number;
  126612. tessellation?: number;
  126613. clip?: number;
  126614. arc?: number;
  126615. closed?: boolean;
  126616. updatable?: boolean;
  126617. sideOrientation?: number;
  126618. frontUVs?: Vector4;
  126619. backUVs?: Vector4;
  126620. cap?: number;
  126621. invertUV?: boolean;
  126622. }, scene?: Nullable<Scene>): Mesh;
  126623. }
  126624. }
  126625. declare module BABYLON {
  126626. /**
  126627. * Class containing static functions to help procedurally build meshes
  126628. */
  126629. export class TiledPlaneBuilder {
  126630. /**
  126631. * Creates a tiled plane mesh
  126632. * * The parameter `pattern` will, depending on value, do nothing or
  126633. * * * flip (reflect about central vertical) alternate tiles across and up
  126634. * * * flip every tile on alternate rows
  126635. * * * rotate (180 degs) alternate tiles across and up
  126636. * * * rotate every tile on alternate rows
  126637. * * * flip and rotate alternate tiles across and up
  126638. * * * flip and rotate every tile on alternate rows
  126639. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  126640. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  126641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126642. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126643. * * 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)
  126644. * * 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)
  126645. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126646. * @param name defines the name of the mesh
  126647. * @param options defines the options used to create the mesh
  126648. * @param scene defines the hosting scene
  126649. * @returns the box mesh
  126650. */
  126651. static CreateTiledPlane(name: string, options: {
  126652. pattern?: number;
  126653. tileSize?: number;
  126654. tileWidth?: number;
  126655. tileHeight?: number;
  126656. size?: number;
  126657. width?: number;
  126658. height?: number;
  126659. alignHorizontal?: number;
  126660. alignVertical?: number;
  126661. sideOrientation?: number;
  126662. frontUVs?: Vector4;
  126663. backUVs?: Vector4;
  126664. updatable?: boolean;
  126665. }, scene?: Nullable<Scene>): Mesh;
  126666. }
  126667. }
  126668. declare module BABYLON {
  126669. /**
  126670. * Class containing static functions to help procedurally build meshes
  126671. */
  126672. export class TubeBuilder {
  126673. /**
  126674. * Creates a tube mesh.
  126675. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126676. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126677. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126678. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126679. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126680. * * 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)
  126681. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126682. * * 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
  126683. * * 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
  126684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126688. * @param name defines the name of the mesh
  126689. * @param options defines the options used to create the mesh
  126690. * @param scene defines the hosting scene
  126691. * @returns the tube mesh
  126692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126693. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126694. */
  126695. static CreateTube(name: string, options: {
  126696. path: Vector3[];
  126697. radius?: number;
  126698. tessellation?: number;
  126699. radiusFunction?: {
  126700. (i: number, distance: number): number;
  126701. };
  126702. cap?: number;
  126703. arc?: number;
  126704. updatable?: boolean;
  126705. sideOrientation?: number;
  126706. frontUVs?: Vector4;
  126707. backUVs?: Vector4;
  126708. instance?: Mesh;
  126709. invertUV?: boolean;
  126710. }, scene?: Nullable<Scene>): Mesh;
  126711. }
  126712. }
  126713. declare module BABYLON {
  126714. /**
  126715. * Class containing static functions to help procedurally build meshes
  126716. */
  126717. export class IcoSphereBuilder {
  126718. /**
  126719. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126720. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126721. * * 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`)
  126722. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126723. * * 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
  126724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126727. * @param name defines the name of the mesh
  126728. * @param options defines the options used to create the mesh
  126729. * @param scene defines the hosting scene
  126730. * @returns the icosahedron mesh
  126731. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126732. */
  126733. static CreateIcoSphere(name: string, options: {
  126734. radius?: number;
  126735. radiusX?: number;
  126736. radiusY?: number;
  126737. radiusZ?: number;
  126738. flat?: boolean;
  126739. subdivisions?: number;
  126740. sideOrientation?: number;
  126741. frontUVs?: Vector4;
  126742. backUVs?: Vector4;
  126743. updatable?: boolean;
  126744. }, scene?: Nullable<Scene>): Mesh;
  126745. }
  126746. }
  126747. declare module BABYLON {
  126748. /**
  126749. * Class containing static functions to help procedurally build meshes
  126750. */
  126751. export class DecalBuilder {
  126752. /**
  126753. * Creates a decal mesh.
  126754. * 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
  126755. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126756. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126757. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126758. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126759. * @param name defines the name of the mesh
  126760. * @param sourceMesh defines the mesh where the decal must be applied
  126761. * @param options defines the options used to create the mesh
  126762. * @param scene defines the hosting scene
  126763. * @returns the decal mesh
  126764. * @see https://doc.babylonjs.com/how_to/decals
  126765. */
  126766. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126767. position?: Vector3;
  126768. normal?: Vector3;
  126769. size?: Vector3;
  126770. angle?: number;
  126771. }): Mesh;
  126772. }
  126773. }
  126774. declare module BABYLON {
  126775. /**
  126776. * Class containing static functions to help procedurally build meshes
  126777. */
  126778. export class MeshBuilder {
  126779. /**
  126780. * Creates a box mesh
  126781. * * The parameter `size` sets the size (float) of each box side (default 1)
  126782. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  126783. * * 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)
  126784. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126788. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  126789. * @param name defines the name of the mesh
  126790. * @param options defines the options used to create the mesh
  126791. * @param scene defines the hosting scene
  126792. * @returns the box mesh
  126793. */
  126794. static CreateBox(name: string, options: {
  126795. size?: number;
  126796. width?: number;
  126797. height?: number;
  126798. depth?: number;
  126799. faceUV?: Vector4[];
  126800. faceColors?: Color4[];
  126801. sideOrientation?: number;
  126802. frontUVs?: Vector4;
  126803. backUVs?: Vector4;
  126804. updatable?: boolean;
  126805. }, scene?: Nullable<Scene>): Mesh;
  126806. /**
  126807. * Creates a tiled box mesh
  126808. * * faceTiles sets the pattern, tile size and number of tiles for a face
  126809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126810. * @param name defines the name of the mesh
  126811. * @param options defines the options used to create the mesh
  126812. * @param scene defines the hosting scene
  126813. * @returns the tiled box mesh
  126814. */
  126815. static CreateTiledBox(name: string, options: {
  126816. pattern?: number;
  126817. size?: number;
  126818. width?: number;
  126819. height?: number;
  126820. depth: number;
  126821. tileSize?: number;
  126822. tileWidth?: number;
  126823. tileHeight?: number;
  126824. faceUV?: Vector4[];
  126825. faceColors?: Color4[];
  126826. alignHorizontal?: number;
  126827. alignVertical?: number;
  126828. sideOrientation?: number;
  126829. updatable?: boolean;
  126830. }, scene?: Nullable<Scene>): Mesh;
  126831. /**
  126832. * Creates a sphere mesh
  126833. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  126834. * * 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`)
  126835. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  126836. * * 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
  126837. * * 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)
  126838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126841. * @param name defines the name of the mesh
  126842. * @param options defines the options used to create the mesh
  126843. * @param scene defines the hosting scene
  126844. * @returns the sphere mesh
  126845. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  126846. */
  126847. static CreateSphere(name: string, options: {
  126848. segments?: number;
  126849. diameter?: number;
  126850. diameterX?: number;
  126851. diameterY?: number;
  126852. diameterZ?: number;
  126853. arc?: number;
  126854. slice?: number;
  126855. sideOrientation?: number;
  126856. frontUVs?: Vector4;
  126857. backUVs?: Vector4;
  126858. updatable?: boolean;
  126859. }, scene?: Nullable<Scene>): Mesh;
  126860. /**
  126861. * Creates a plane polygonal mesh. By default, this is a disc
  126862. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  126863. * * 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
  126864. * * 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
  126865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126868. * @param name defines the name of the mesh
  126869. * @param options defines the options used to create the mesh
  126870. * @param scene defines the hosting scene
  126871. * @returns the plane polygonal mesh
  126872. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  126873. */
  126874. static CreateDisc(name: string, options: {
  126875. radius?: number;
  126876. tessellation?: number;
  126877. arc?: number;
  126878. updatable?: boolean;
  126879. sideOrientation?: number;
  126880. frontUVs?: Vector4;
  126881. backUVs?: Vector4;
  126882. }, scene?: Nullable<Scene>): Mesh;
  126883. /**
  126884. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  126885. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  126886. * * 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`)
  126887. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  126888. * * 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
  126889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126892. * @param name defines the name of the mesh
  126893. * @param options defines the options used to create the mesh
  126894. * @param scene defines the hosting scene
  126895. * @returns the icosahedron mesh
  126896. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  126897. */
  126898. static CreateIcoSphere(name: string, options: {
  126899. radius?: number;
  126900. radiusX?: number;
  126901. radiusY?: number;
  126902. radiusZ?: number;
  126903. flat?: boolean;
  126904. subdivisions?: number;
  126905. sideOrientation?: number;
  126906. frontUVs?: Vector4;
  126907. backUVs?: Vector4;
  126908. updatable?: boolean;
  126909. }, scene?: Nullable<Scene>): Mesh;
  126910. /**
  126911. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126912. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  126913. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  126914. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  126915. * * 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
  126916. * * 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
  126917. * * 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
  126918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126921. * * 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
  126922. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  126923. * * 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
  126924. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  126925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126926. * @param name defines the name of the mesh
  126927. * @param options defines the options used to create the mesh
  126928. * @param scene defines the hosting scene
  126929. * @returns the ribbon mesh
  126930. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  126931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126932. */
  126933. static CreateRibbon(name: string, options: {
  126934. pathArray: Vector3[][];
  126935. closeArray?: boolean;
  126936. closePath?: boolean;
  126937. offset?: number;
  126938. updatable?: boolean;
  126939. sideOrientation?: number;
  126940. frontUVs?: Vector4;
  126941. backUVs?: Vector4;
  126942. instance?: Mesh;
  126943. invertUV?: boolean;
  126944. uvs?: Vector2[];
  126945. colors?: Color4[];
  126946. }, scene?: Nullable<Scene>): Mesh;
  126947. /**
  126948. * Creates a cylinder or a cone mesh
  126949. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126950. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126951. * * 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.
  126952. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126953. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126954. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126955. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126956. * * 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).
  126957. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126958. * * 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).
  126959. * * 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
  126960. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126961. * * 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
  126962. * * 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.
  126963. * * If `enclose` is false, a ring surface is one element.
  126964. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126965. * * 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
  126966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126969. * @param name defines the name of the mesh
  126970. * @param options defines the options used to create the mesh
  126971. * @param scene defines the hosting scene
  126972. * @returns the cylinder mesh
  126973. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126974. */
  126975. static CreateCylinder(name: string, options: {
  126976. height?: number;
  126977. diameterTop?: number;
  126978. diameterBottom?: number;
  126979. diameter?: number;
  126980. tessellation?: number;
  126981. subdivisions?: number;
  126982. arc?: number;
  126983. faceColors?: Color4[];
  126984. faceUV?: Vector4[];
  126985. updatable?: boolean;
  126986. hasRings?: boolean;
  126987. enclose?: boolean;
  126988. cap?: number;
  126989. sideOrientation?: number;
  126990. frontUVs?: Vector4;
  126991. backUVs?: Vector4;
  126992. }, scene?: Nullable<Scene>): Mesh;
  126993. /**
  126994. * Creates a torus mesh
  126995. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126996. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126997. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127001. * @param name defines the name of the mesh
  127002. * @param options defines the options used to create the mesh
  127003. * @param scene defines the hosting scene
  127004. * @returns the torus mesh
  127005. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127006. */
  127007. static CreateTorus(name: string, options: {
  127008. diameter?: number;
  127009. thickness?: number;
  127010. tessellation?: number;
  127011. updatable?: boolean;
  127012. sideOrientation?: number;
  127013. frontUVs?: Vector4;
  127014. backUVs?: Vector4;
  127015. }, scene?: Nullable<Scene>): Mesh;
  127016. /**
  127017. * Creates a torus knot mesh
  127018. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127019. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127020. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127021. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127023. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127025. * @param name defines the name of the mesh
  127026. * @param options defines the options used to create the mesh
  127027. * @param scene defines the hosting scene
  127028. * @returns the torus knot mesh
  127029. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127030. */
  127031. static CreateTorusKnot(name: string, options: {
  127032. radius?: number;
  127033. tube?: number;
  127034. radialSegments?: number;
  127035. tubularSegments?: number;
  127036. p?: number;
  127037. q?: number;
  127038. updatable?: boolean;
  127039. sideOrientation?: number;
  127040. frontUVs?: Vector4;
  127041. backUVs?: Vector4;
  127042. }, scene?: Nullable<Scene>): Mesh;
  127043. /**
  127044. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127045. * * 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
  127046. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127047. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127048. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127049. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127050. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127051. * * 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
  127052. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127055. * @param name defines the name of the new line system
  127056. * @param options defines the options used to create the line system
  127057. * @param scene defines the hosting scene
  127058. * @returns a new line system mesh
  127059. */
  127060. static CreateLineSystem(name: string, options: {
  127061. lines: Vector3[][];
  127062. updatable?: boolean;
  127063. instance?: Nullable<LinesMesh>;
  127064. colors?: Nullable<Color4[][]>;
  127065. useVertexAlpha?: boolean;
  127066. }, scene: Nullable<Scene>): LinesMesh;
  127067. /**
  127068. * Creates a line mesh
  127069. * 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
  127070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127071. * * The parameter `points` is an array successive Vector3
  127072. * * 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
  127073. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127075. * * When updating an instance, remember that only point positions can change, not the number of points
  127076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127078. * @param name defines the name of the new line system
  127079. * @param options defines the options used to create the line system
  127080. * @param scene defines the hosting scene
  127081. * @returns a new line mesh
  127082. */
  127083. static CreateLines(name: string, options: {
  127084. points: Vector3[];
  127085. updatable?: boolean;
  127086. instance?: Nullable<LinesMesh>;
  127087. colors?: Color4[];
  127088. useVertexAlpha?: boolean;
  127089. }, scene?: Nullable<Scene>): LinesMesh;
  127090. /**
  127091. * Creates a dashed line mesh
  127092. * * 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
  127093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127094. * * The parameter `points` is an array successive Vector3
  127095. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127096. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127097. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127098. * * 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
  127099. * * When updating an instance, remember that only point positions can change, not the number of points
  127100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127101. * @param name defines the name of the mesh
  127102. * @param options defines the options used to create the mesh
  127103. * @param scene defines the hosting scene
  127104. * @returns the dashed line mesh
  127105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127106. */
  127107. static CreateDashedLines(name: string, options: {
  127108. points: Vector3[];
  127109. dashSize?: number;
  127110. gapSize?: number;
  127111. dashNb?: number;
  127112. updatable?: boolean;
  127113. instance?: LinesMesh;
  127114. }, scene?: Nullable<Scene>): LinesMesh;
  127115. /**
  127116. * 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.
  127117. * * 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.
  127118. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127119. * * 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.
  127120. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127121. * * 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
  127122. * * 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
  127123. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127126. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127128. * @param name defines the name of the mesh
  127129. * @param options defines the options used to create the mesh
  127130. * @param scene defines the hosting scene
  127131. * @returns the extruded shape mesh
  127132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127134. */
  127135. static ExtrudeShape(name: string, options: {
  127136. shape: Vector3[];
  127137. path: Vector3[];
  127138. scale?: number;
  127139. rotation?: number;
  127140. cap?: number;
  127141. updatable?: boolean;
  127142. sideOrientation?: number;
  127143. frontUVs?: Vector4;
  127144. backUVs?: Vector4;
  127145. instance?: Mesh;
  127146. invertUV?: boolean;
  127147. }, scene?: Nullable<Scene>): Mesh;
  127148. /**
  127149. * Creates an custom extruded shape mesh.
  127150. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127151. * * 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.
  127152. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127153. * * 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
  127154. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127155. * * 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
  127156. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127157. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127158. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127159. * * 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
  127160. * * 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
  127161. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127166. * @param name defines the name of the mesh
  127167. * @param options defines the options used to create the mesh
  127168. * @param scene defines the hosting scene
  127169. * @returns the custom extruded shape mesh
  127170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127173. */
  127174. static ExtrudeShapeCustom(name: string, options: {
  127175. shape: Vector3[];
  127176. path: Vector3[];
  127177. scaleFunction?: any;
  127178. rotationFunction?: any;
  127179. ribbonCloseArray?: boolean;
  127180. ribbonClosePath?: boolean;
  127181. cap?: number;
  127182. updatable?: boolean;
  127183. sideOrientation?: number;
  127184. frontUVs?: Vector4;
  127185. backUVs?: Vector4;
  127186. instance?: Mesh;
  127187. invertUV?: boolean;
  127188. }, scene?: Nullable<Scene>): Mesh;
  127189. /**
  127190. * Creates lathe mesh.
  127191. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127192. * * 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
  127193. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127194. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127195. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127196. * * 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
  127197. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127198. * * 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
  127199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127203. * @param name defines the name of the mesh
  127204. * @param options defines the options used to create the mesh
  127205. * @param scene defines the hosting scene
  127206. * @returns the lathe mesh
  127207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127208. */
  127209. static CreateLathe(name: string, options: {
  127210. shape: Vector3[];
  127211. radius?: number;
  127212. tessellation?: number;
  127213. clip?: number;
  127214. arc?: number;
  127215. closed?: boolean;
  127216. updatable?: boolean;
  127217. sideOrientation?: number;
  127218. frontUVs?: Vector4;
  127219. backUVs?: Vector4;
  127220. cap?: number;
  127221. invertUV?: boolean;
  127222. }, scene?: Nullable<Scene>): Mesh;
  127223. /**
  127224. * Creates a tiled plane mesh
  127225. * * You can set a limited pattern arrangement with the tiles
  127226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127229. * @param name defines the name of the mesh
  127230. * @param options defines the options used to create the mesh
  127231. * @param scene defines the hosting scene
  127232. * @returns the plane mesh
  127233. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127234. */
  127235. static CreateTiledPlane(name: string, options: {
  127236. pattern?: number;
  127237. tileSize?: number;
  127238. tileWidth?: number;
  127239. tileHeight?: number;
  127240. size?: number;
  127241. width?: number;
  127242. height?: number;
  127243. alignHorizontal?: number;
  127244. alignVertical?: number;
  127245. sideOrientation?: number;
  127246. frontUVs?: Vector4;
  127247. backUVs?: Vector4;
  127248. updatable?: boolean;
  127249. }, scene?: Nullable<Scene>): Mesh;
  127250. /**
  127251. * Creates a plane mesh
  127252. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127253. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127254. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127258. * @param name defines the name of the mesh
  127259. * @param options defines the options used to create the mesh
  127260. * @param scene defines the hosting scene
  127261. * @returns the plane mesh
  127262. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127263. */
  127264. static CreatePlane(name: string, options: {
  127265. size?: number;
  127266. width?: number;
  127267. height?: number;
  127268. sideOrientation?: number;
  127269. frontUVs?: Vector4;
  127270. backUVs?: Vector4;
  127271. updatable?: boolean;
  127272. sourcePlane?: Plane;
  127273. }, scene?: Nullable<Scene>): Mesh;
  127274. /**
  127275. * Creates a ground mesh
  127276. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127277. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127279. * @param name defines the name of the mesh
  127280. * @param options defines the options used to create the mesh
  127281. * @param scene defines the hosting scene
  127282. * @returns the ground mesh
  127283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127284. */
  127285. static CreateGround(name: string, options: {
  127286. width?: number;
  127287. height?: number;
  127288. subdivisions?: number;
  127289. subdivisionsX?: number;
  127290. subdivisionsY?: number;
  127291. updatable?: boolean;
  127292. }, scene?: Nullable<Scene>): Mesh;
  127293. /**
  127294. * Creates a tiled ground mesh
  127295. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127296. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127297. * * 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
  127298. * * 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
  127299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127300. * @param name defines the name of the mesh
  127301. * @param options defines the options used to create the mesh
  127302. * @param scene defines the hosting scene
  127303. * @returns the tiled ground mesh
  127304. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127305. */
  127306. static CreateTiledGround(name: string, options: {
  127307. xmin: number;
  127308. zmin: number;
  127309. xmax: number;
  127310. zmax: number;
  127311. subdivisions?: {
  127312. w: number;
  127313. h: number;
  127314. };
  127315. precision?: {
  127316. w: number;
  127317. h: number;
  127318. };
  127319. updatable?: boolean;
  127320. }, scene?: Nullable<Scene>): Mesh;
  127321. /**
  127322. * Creates a ground mesh from a height map
  127323. * * The parameter `url` sets the URL of the height map image resource.
  127324. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127325. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127326. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127327. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127328. * * 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.
  127329. * * 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).
  127330. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127332. * @param name defines the name of the mesh
  127333. * @param url defines the url to the height map
  127334. * @param options defines the options used to create the mesh
  127335. * @param scene defines the hosting scene
  127336. * @returns the ground mesh
  127337. * @see https://doc.babylonjs.com/babylon101/height_map
  127338. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127339. */
  127340. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127341. width?: number;
  127342. height?: number;
  127343. subdivisions?: number;
  127344. minHeight?: number;
  127345. maxHeight?: number;
  127346. colorFilter?: Color3;
  127347. alphaFilter?: number;
  127348. updatable?: boolean;
  127349. onReady?: (mesh: GroundMesh) => void;
  127350. }, scene?: Nullable<Scene>): GroundMesh;
  127351. /**
  127352. * Creates a polygon mesh
  127353. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127354. * * 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
  127355. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127358. * * Remember you can only change the shape positions, not their number when updating a polygon
  127359. * @param name defines the name of the mesh
  127360. * @param options defines the options used to create the mesh
  127361. * @param scene defines the hosting scene
  127362. * @param earcutInjection can be used to inject your own earcut reference
  127363. * @returns the polygon mesh
  127364. */
  127365. static CreatePolygon(name: string, options: {
  127366. shape: Vector3[];
  127367. holes?: Vector3[][];
  127368. depth?: number;
  127369. faceUV?: Vector4[];
  127370. faceColors?: Color4[];
  127371. updatable?: boolean;
  127372. sideOrientation?: number;
  127373. frontUVs?: Vector4;
  127374. backUVs?: Vector4;
  127375. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127376. /**
  127377. * Creates an extruded polygon mesh, with depth in the Y direction.
  127378. * * 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)
  127379. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127380. * @param name defines the name of the mesh
  127381. * @param options defines the options used to create the mesh
  127382. * @param scene defines the hosting scene
  127383. * @param earcutInjection can be used to inject your own earcut reference
  127384. * @returns the polygon mesh
  127385. */
  127386. static ExtrudePolygon(name: string, options: {
  127387. shape: Vector3[];
  127388. holes?: Vector3[][];
  127389. depth?: number;
  127390. faceUV?: Vector4[];
  127391. faceColors?: Color4[];
  127392. updatable?: boolean;
  127393. sideOrientation?: number;
  127394. frontUVs?: Vector4;
  127395. backUVs?: Vector4;
  127396. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127397. /**
  127398. * Creates a tube mesh.
  127399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127404. * * 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)
  127405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127406. * * 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
  127407. * * 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
  127408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127412. * @param name defines the name of the mesh
  127413. * @param options defines the options used to create the mesh
  127414. * @param scene defines the hosting scene
  127415. * @returns the tube mesh
  127416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127418. */
  127419. static CreateTube(name: string, options: {
  127420. path: Vector3[];
  127421. radius?: number;
  127422. tessellation?: number;
  127423. radiusFunction?: {
  127424. (i: number, distance: number): number;
  127425. };
  127426. cap?: number;
  127427. arc?: number;
  127428. updatable?: boolean;
  127429. sideOrientation?: number;
  127430. frontUVs?: Vector4;
  127431. backUVs?: Vector4;
  127432. instance?: Mesh;
  127433. invertUV?: boolean;
  127434. }, scene?: Nullable<Scene>): Mesh;
  127435. /**
  127436. * Creates a polyhedron mesh
  127437. * * 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
  127438. * * The parameter `size` (positive float, default 1) sets the polygon size
  127439. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  127440. * * 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`
  127441. * * 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
  127442. * * 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)`)
  127443. * * 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
  127444. * * 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
  127445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127448. * @param name defines the name of the mesh
  127449. * @param options defines the options used to create the mesh
  127450. * @param scene defines the hosting scene
  127451. * @returns the polyhedron mesh
  127452. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  127453. */
  127454. static CreatePolyhedron(name: string, options: {
  127455. type?: number;
  127456. size?: number;
  127457. sizeX?: number;
  127458. sizeY?: number;
  127459. sizeZ?: number;
  127460. custom?: any;
  127461. faceUV?: Vector4[];
  127462. faceColors?: Color4[];
  127463. flat?: boolean;
  127464. updatable?: boolean;
  127465. sideOrientation?: number;
  127466. frontUVs?: Vector4;
  127467. backUVs?: Vector4;
  127468. }, scene?: Nullable<Scene>): Mesh;
  127469. /**
  127470. * Creates a decal mesh.
  127471. * 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
  127472. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127473. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127474. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127475. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127476. * @param name defines the name of the mesh
  127477. * @param sourceMesh defines the mesh where the decal must be applied
  127478. * @param options defines the options used to create the mesh
  127479. * @param scene defines the hosting scene
  127480. * @returns the decal mesh
  127481. * @see https://doc.babylonjs.com/how_to/decals
  127482. */
  127483. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127484. position?: Vector3;
  127485. normal?: Vector3;
  127486. size?: Vector3;
  127487. angle?: number;
  127488. }): Mesh;
  127489. }
  127490. }
  127491. declare module BABYLON {
  127492. /**
  127493. * A simplifier interface for future simplification implementations
  127494. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127495. */
  127496. export interface ISimplifier {
  127497. /**
  127498. * Simplification of a given mesh according to the given settings.
  127499. * Since this requires computation, it is assumed that the function runs async.
  127500. * @param settings The settings of the simplification, including quality and distance
  127501. * @param successCallback A callback that will be called after the mesh was simplified.
  127502. * @param errorCallback in case of an error, this callback will be called. optional.
  127503. */
  127504. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  127505. }
  127506. /**
  127507. * Expected simplification settings.
  127508. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  127509. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127510. */
  127511. export interface ISimplificationSettings {
  127512. /**
  127513. * Gets or sets the expected quality
  127514. */
  127515. quality: number;
  127516. /**
  127517. * Gets or sets the distance when this optimized version should be used
  127518. */
  127519. distance: number;
  127520. /**
  127521. * Gets an already optimized mesh
  127522. */
  127523. optimizeMesh?: boolean;
  127524. }
  127525. /**
  127526. * Class used to specify simplification options
  127527. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127528. */
  127529. export class SimplificationSettings implements ISimplificationSettings {
  127530. /** expected quality */
  127531. quality: number;
  127532. /** distance when this optimized version should be used */
  127533. distance: number;
  127534. /** already optimized mesh */
  127535. optimizeMesh?: boolean | undefined;
  127536. /**
  127537. * Creates a SimplificationSettings
  127538. * @param quality expected quality
  127539. * @param distance distance when this optimized version should be used
  127540. * @param optimizeMesh already optimized mesh
  127541. */
  127542. constructor(
  127543. /** expected quality */
  127544. quality: number,
  127545. /** distance when this optimized version should be used */
  127546. distance: number,
  127547. /** already optimized mesh */
  127548. optimizeMesh?: boolean | undefined);
  127549. }
  127550. /**
  127551. * Interface used to define a simplification task
  127552. */
  127553. export interface ISimplificationTask {
  127554. /**
  127555. * Array of settings
  127556. */
  127557. settings: Array<ISimplificationSettings>;
  127558. /**
  127559. * Simplification type
  127560. */
  127561. simplificationType: SimplificationType;
  127562. /**
  127563. * Mesh to simplify
  127564. */
  127565. mesh: Mesh;
  127566. /**
  127567. * Callback called on success
  127568. */
  127569. successCallback?: () => void;
  127570. /**
  127571. * Defines if parallel processing can be used
  127572. */
  127573. parallelProcessing: boolean;
  127574. }
  127575. /**
  127576. * Queue used to order the simplification tasks
  127577. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127578. */
  127579. export class SimplificationQueue {
  127580. private _simplificationArray;
  127581. /**
  127582. * Gets a boolean indicating that the process is still running
  127583. */
  127584. running: boolean;
  127585. /**
  127586. * Creates a new queue
  127587. */
  127588. constructor();
  127589. /**
  127590. * Adds a new simplification task
  127591. * @param task defines a task to add
  127592. */
  127593. addTask(task: ISimplificationTask): void;
  127594. /**
  127595. * Execute next task
  127596. */
  127597. executeNext(): void;
  127598. /**
  127599. * Execute a simplification task
  127600. * @param task defines the task to run
  127601. */
  127602. runSimplification(task: ISimplificationTask): void;
  127603. private getSimplifier;
  127604. }
  127605. /**
  127606. * The implemented types of simplification
  127607. * At the moment only Quadratic Error Decimation is implemented
  127608. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127609. */
  127610. export enum SimplificationType {
  127611. /** Quadratic error decimation */
  127612. QUADRATIC = 0
  127613. }
  127614. }
  127615. declare module BABYLON {
  127616. interface Scene {
  127617. /** @hidden (Backing field) */
  127618. _simplificationQueue: SimplificationQueue;
  127619. /**
  127620. * Gets or sets the simplification queue attached to the scene
  127621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  127622. */
  127623. simplificationQueue: SimplificationQueue;
  127624. }
  127625. interface Mesh {
  127626. /**
  127627. * Simplify the mesh according to the given array of settings.
  127628. * Function will return immediately and will simplify async
  127629. * @param settings a collection of simplification settings
  127630. * @param parallelProcessing should all levels calculate parallel or one after the other
  127631. * @param simplificationType the type of simplification to run
  127632. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  127633. * @returns the current mesh
  127634. */
  127635. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  127636. }
  127637. /**
  127638. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  127639. * created in a scene
  127640. */
  127641. export class SimplicationQueueSceneComponent implements ISceneComponent {
  127642. /**
  127643. * The component name helpfull to identify the component in the list of scene components.
  127644. */
  127645. readonly name: string;
  127646. /**
  127647. * The scene the component belongs to.
  127648. */
  127649. scene: Scene;
  127650. /**
  127651. * Creates a new instance of the component for the given scene
  127652. * @param scene Defines the scene to register the component in
  127653. */
  127654. constructor(scene: Scene);
  127655. /**
  127656. * Registers the component in a given scene
  127657. */
  127658. register(): void;
  127659. /**
  127660. * Rebuilds the elements related to this component in case of
  127661. * context lost for instance.
  127662. */
  127663. rebuild(): void;
  127664. /**
  127665. * Disposes the component and the associated ressources
  127666. */
  127667. dispose(): void;
  127668. private _beforeCameraUpdate;
  127669. }
  127670. }
  127671. declare module BABYLON {
  127672. /**
  127673. * Navigation plugin interface to add navigation constrained by a navigation mesh
  127674. */
  127675. export interface INavigationEnginePlugin {
  127676. /**
  127677. * plugin name
  127678. */
  127679. name: string;
  127680. /**
  127681. * Creates a navigation mesh
  127682. * @param meshes array of all the geometry used to compute the navigatio mesh
  127683. * @param parameters bunch of parameters used to filter geometry
  127684. */
  127685. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127686. /**
  127687. * Create a navigation mesh debug mesh
  127688. * @param scene is where the mesh will be added
  127689. * @returns debug display mesh
  127690. */
  127691. createDebugNavMesh(scene: Scene): Mesh;
  127692. /**
  127693. * Get a navigation mesh constrained position, closest to the parameter position
  127694. * @param position world position
  127695. * @returns the closest point to position constrained by the navigation mesh
  127696. */
  127697. getClosestPoint(position: Vector3): Vector3;
  127698. /**
  127699. * Get a navigation mesh constrained position, within a particular radius
  127700. * @param position world position
  127701. * @param maxRadius the maximum distance to the constrained world position
  127702. * @returns the closest point to position constrained by the navigation mesh
  127703. */
  127704. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127705. /**
  127706. * Compute the final position from a segment made of destination-position
  127707. * @param position world position
  127708. * @param destination world position
  127709. * @returns the resulting point along the navmesh
  127710. */
  127711. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127712. /**
  127713. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127714. * @param start world position
  127715. * @param end world position
  127716. * @returns array containing world position composing the path
  127717. */
  127718. computePath(start: Vector3, end: Vector3): Vector3[];
  127719. /**
  127720. * If this plugin is supported
  127721. * @returns true if plugin is supported
  127722. */
  127723. isSupported(): boolean;
  127724. /**
  127725. * Create a new Crowd so you can add agents
  127726. * @param maxAgents the maximum agent count in the crowd
  127727. * @param maxAgentRadius the maximum radius an agent can have
  127728. * @param scene to attach the crowd to
  127729. * @returns the crowd you can add agents to
  127730. */
  127731. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127732. /**
  127733. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127734. * The queries will try to find a solution within those bounds
  127735. * default is (1,1,1)
  127736. * @param extent x,y,z value that define the extent around the queries point of reference
  127737. */
  127738. setDefaultQueryExtent(extent: Vector3): void;
  127739. /**
  127740. * Get the Bounding box extent specified by setDefaultQueryExtent
  127741. * @returns the box extent values
  127742. */
  127743. getDefaultQueryExtent(): Vector3;
  127744. /**
  127745. * Release all resources
  127746. */
  127747. dispose(): void;
  127748. }
  127749. /**
  127750. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  127751. */
  127752. export interface ICrowd {
  127753. /**
  127754. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127755. * You can attach anything to that node. The node position is updated in the scene update tick.
  127756. * @param pos world position that will be constrained by the navigation mesh
  127757. * @param parameters agent parameters
  127758. * @param transform hooked to the agent that will be update by the scene
  127759. * @returns agent index
  127760. */
  127761. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127762. /**
  127763. * Returns the agent position in world space
  127764. * @param index agent index returned by addAgent
  127765. * @returns world space position
  127766. */
  127767. getAgentPosition(index: number): Vector3;
  127768. /**
  127769. * Gets the agent velocity in world space
  127770. * @param index agent index returned by addAgent
  127771. * @returns world space velocity
  127772. */
  127773. getAgentVelocity(index: number): Vector3;
  127774. /**
  127775. * remove a particular agent previously created
  127776. * @param index agent index returned by addAgent
  127777. */
  127778. removeAgent(index: number): void;
  127779. /**
  127780. * get the list of all agents attached to this crowd
  127781. * @returns list of agent indices
  127782. */
  127783. getAgents(): number[];
  127784. /**
  127785. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127786. * @param deltaTime in seconds
  127787. */
  127788. update(deltaTime: number): void;
  127789. /**
  127790. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127791. * @param index agent index returned by addAgent
  127792. * @param destination targeted world position
  127793. */
  127794. agentGoto(index: number, destination: Vector3): void;
  127795. /**
  127796. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127797. * The queries will try to find a solution within those bounds
  127798. * default is (1,1,1)
  127799. * @param extent x,y,z value that define the extent around the queries point of reference
  127800. */
  127801. setDefaultQueryExtent(extent: Vector3): void;
  127802. /**
  127803. * Get the Bounding box extent specified by setDefaultQueryExtent
  127804. * @returns the box extent values
  127805. */
  127806. getDefaultQueryExtent(): Vector3;
  127807. /**
  127808. * Release all resources
  127809. */
  127810. dispose(): void;
  127811. }
  127812. /**
  127813. * Configures an agent
  127814. */
  127815. export interface IAgentParameters {
  127816. /**
  127817. * Agent radius. [Limit: >= 0]
  127818. */
  127819. radius: number;
  127820. /**
  127821. * Agent height. [Limit: > 0]
  127822. */
  127823. height: number;
  127824. /**
  127825. * Maximum allowed acceleration. [Limit: >= 0]
  127826. */
  127827. maxAcceleration: number;
  127828. /**
  127829. * Maximum allowed speed. [Limit: >= 0]
  127830. */
  127831. maxSpeed: number;
  127832. /**
  127833. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  127834. */
  127835. collisionQueryRange: number;
  127836. /**
  127837. * The path visibility optimization range. [Limit: > 0]
  127838. */
  127839. pathOptimizationRange: number;
  127840. /**
  127841. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  127842. */
  127843. separationWeight: number;
  127844. }
  127845. /**
  127846. * Configures the navigation mesh creation
  127847. */
  127848. export interface INavMeshParameters {
  127849. /**
  127850. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  127851. */
  127852. cs: number;
  127853. /**
  127854. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  127855. */
  127856. ch: number;
  127857. /**
  127858. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  127859. */
  127860. walkableSlopeAngle: number;
  127861. /**
  127862. * Minimum floor to 'ceiling' height that will still allow the floor area to
  127863. * be considered walkable. [Limit: >= 3] [Units: vx]
  127864. */
  127865. walkableHeight: number;
  127866. /**
  127867. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  127868. */
  127869. walkableClimb: number;
  127870. /**
  127871. * The distance to erode/shrink the walkable area of the heightfield away from
  127872. * obstructions. [Limit: >=0] [Units: vx]
  127873. */
  127874. walkableRadius: number;
  127875. /**
  127876. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  127877. */
  127878. maxEdgeLen: number;
  127879. /**
  127880. * The maximum distance a simplfied contour's border edges should deviate
  127881. * the original raw contour. [Limit: >=0] [Units: vx]
  127882. */
  127883. maxSimplificationError: number;
  127884. /**
  127885. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  127886. */
  127887. minRegionArea: number;
  127888. /**
  127889. * Any regions with a span count smaller than this value will, if possible,
  127890. * be merged with larger regions. [Limit: >=0] [Units: vx]
  127891. */
  127892. mergeRegionArea: number;
  127893. /**
  127894. * The maximum number of vertices allowed for polygons generated during the
  127895. * contour to polygon conversion process. [Limit: >= 3]
  127896. */
  127897. maxVertsPerPoly: number;
  127898. /**
  127899. * Sets the sampling distance to use when generating the detail mesh.
  127900. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  127901. */
  127902. detailSampleDist: number;
  127903. /**
  127904. * The maximum distance the detail mesh surface should deviate from heightfield
  127905. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  127906. */
  127907. detailSampleMaxError: number;
  127908. }
  127909. }
  127910. declare module BABYLON {
  127911. /**
  127912. * RecastJS navigation plugin
  127913. */
  127914. export class RecastJSPlugin implements INavigationEnginePlugin {
  127915. /**
  127916. * Reference to the Recast library
  127917. */
  127918. bjsRECAST: any;
  127919. /**
  127920. * plugin name
  127921. */
  127922. name: string;
  127923. /**
  127924. * the first navmesh created. We might extend this to support multiple navmeshes
  127925. */
  127926. navMesh: any;
  127927. /**
  127928. * Initializes the recastJS plugin
  127929. * @param recastInjection can be used to inject your own recast reference
  127930. */
  127931. constructor(recastInjection?: any);
  127932. /**
  127933. * Creates a navigation mesh
  127934. * @param meshes array of all the geometry used to compute the navigatio mesh
  127935. * @param parameters bunch of parameters used to filter geometry
  127936. */
  127937. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  127938. /**
  127939. * Create a navigation mesh debug mesh
  127940. * @param scene is where the mesh will be added
  127941. * @returns debug display mesh
  127942. */
  127943. createDebugNavMesh(scene: Scene): Mesh;
  127944. /**
  127945. * Get a navigation mesh constrained position, closest to the parameter position
  127946. * @param position world position
  127947. * @returns the closest point to position constrained by the navigation mesh
  127948. */
  127949. getClosestPoint(position: Vector3): Vector3;
  127950. /**
  127951. * Get a navigation mesh constrained position, within a particular radius
  127952. * @param position world position
  127953. * @param maxRadius the maximum distance to the constrained world position
  127954. * @returns the closest point to position constrained by the navigation mesh
  127955. */
  127956. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  127957. /**
  127958. * Compute the final position from a segment made of destination-position
  127959. * @param position world position
  127960. * @param destination world position
  127961. * @returns the resulting point along the navmesh
  127962. */
  127963. moveAlong(position: Vector3, destination: Vector3): Vector3;
  127964. /**
  127965. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  127966. * @param start world position
  127967. * @param end world position
  127968. * @returns array containing world position composing the path
  127969. */
  127970. computePath(start: Vector3, end: Vector3): Vector3[];
  127971. /**
  127972. * Create a new Crowd so you can add agents
  127973. * @param maxAgents the maximum agent count in the crowd
  127974. * @param maxAgentRadius the maximum radius an agent can have
  127975. * @param scene to attach the crowd to
  127976. * @returns the crowd you can add agents to
  127977. */
  127978. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  127979. /**
  127980. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127981. * The queries will try to find a solution within those bounds
  127982. * default is (1,1,1)
  127983. * @param extent x,y,z value that define the extent around the queries point of reference
  127984. */
  127985. setDefaultQueryExtent(extent: Vector3): void;
  127986. /**
  127987. * Get the Bounding box extent specified by setDefaultQueryExtent
  127988. * @returns the box extent values
  127989. */
  127990. getDefaultQueryExtent(): Vector3;
  127991. /**
  127992. * Disposes
  127993. */
  127994. dispose(): void;
  127995. /**
  127996. * If this plugin is supported
  127997. * @returns true if plugin is supported
  127998. */
  127999. isSupported(): boolean;
  128000. }
  128001. /**
  128002. * Recast detour crowd implementation
  128003. */
  128004. export class RecastJSCrowd implements ICrowd {
  128005. /**
  128006. * Recast/detour plugin
  128007. */
  128008. bjsRECASTPlugin: RecastJSPlugin;
  128009. /**
  128010. * Link to the detour crowd
  128011. */
  128012. recastCrowd: any;
  128013. /**
  128014. * One transform per agent
  128015. */
  128016. transforms: TransformNode[];
  128017. /**
  128018. * All agents created
  128019. */
  128020. agents: number[];
  128021. /**
  128022. * Link to the scene is kept to unregister the crowd from the scene
  128023. */
  128024. private _scene;
  128025. /**
  128026. * Observer for crowd updates
  128027. */
  128028. private _onBeforeAnimationsObserver;
  128029. /**
  128030. * Constructor
  128031. * @param plugin recastJS plugin
  128032. * @param maxAgents the maximum agent count in the crowd
  128033. * @param maxAgentRadius the maximum radius an agent can have
  128034. * @param scene to attach the crowd to
  128035. * @returns the crowd you can add agents to
  128036. */
  128037. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128038. /**
  128039. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128040. * You can attach anything to that node. The node position is updated in the scene update tick.
  128041. * @param pos world position that will be constrained by the navigation mesh
  128042. * @param parameters agent parameters
  128043. * @param transform hooked to the agent that will be update by the scene
  128044. * @returns agent index
  128045. */
  128046. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128047. /**
  128048. * Returns the agent position in world space
  128049. * @param index agent index returned by addAgent
  128050. * @returns world space position
  128051. */
  128052. getAgentPosition(index: number): Vector3;
  128053. /**
  128054. * Returns the agent velocity in world space
  128055. * @param index agent index returned by addAgent
  128056. * @returns world space velocity
  128057. */
  128058. getAgentVelocity(index: number): Vector3;
  128059. /**
  128060. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128061. * @param index agent index returned by addAgent
  128062. * @param destination targeted world position
  128063. */
  128064. agentGoto(index: number, destination: Vector3): void;
  128065. /**
  128066. * remove a particular agent previously created
  128067. * @param index agent index returned by addAgent
  128068. */
  128069. removeAgent(index: number): void;
  128070. /**
  128071. * get the list of all agents attached to this crowd
  128072. * @returns list of agent indices
  128073. */
  128074. getAgents(): number[];
  128075. /**
  128076. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128077. * @param deltaTime in seconds
  128078. */
  128079. update(deltaTime: number): void;
  128080. /**
  128081. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128082. * The queries will try to find a solution within those bounds
  128083. * default is (1,1,1)
  128084. * @param extent x,y,z value that define the extent around the queries point of reference
  128085. */
  128086. setDefaultQueryExtent(extent: Vector3): void;
  128087. /**
  128088. * Get the Bounding box extent specified by setDefaultQueryExtent
  128089. * @returns the box extent values
  128090. */
  128091. getDefaultQueryExtent(): Vector3;
  128092. /**
  128093. * Release all resources
  128094. */
  128095. dispose(): void;
  128096. }
  128097. }
  128098. declare module BABYLON {
  128099. /**
  128100. * Class used to enable access to IndexedDB
  128101. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128102. */
  128103. export class Database implements IOfflineProvider {
  128104. private _callbackManifestChecked;
  128105. private _currentSceneUrl;
  128106. private _db;
  128107. private _enableSceneOffline;
  128108. private _enableTexturesOffline;
  128109. private _manifestVersionFound;
  128110. private _mustUpdateRessources;
  128111. private _hasReachedQuota;
  128112. private _isSupported;
  128113. private _idbFactory;
  128114. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128115. private static IsUASupportingBlobStorage;
  128116. /**
  128117. * Gets a boolean indicating if Database storate is enabled (off by default)
  128118. */
  128119. static IDBStorageEnabled: boolean;
  128120. /**
  128121. * Gets a boolean indicating if scene must be saved in the database
  128122. */
  128123. readonly enableSceneOffline: boolean;
  128124. /**
  128125. * Gets a boolean indicating if textures must be saved in the database
  128126. */
  128127. readonly enableTexturesOffline: boolean;
  128128. /**
  128129. * Creates a new Database
  128130. * @param urlToScene defines the url to load the scene
  128131. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128132. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128133. */
  128134. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128135. private static _ParseURL;
  128136. private static _ReturnFullUrlLocation;
  128137. private _checkManifestFile;
  128138. /**
  128139. * Open the database and make it available
  128140. * @param successCallback defines the callback to call on success
  128141. * @param errorCallback defines the callback to call on error
  128142. */
  128143. open(successCallback: () => void, errorCallback: () => void): void;
  128144. /**
  128145. * Loads an image from the database
  128146. * @param url defines the url to load from
  128147. * @param image defines the target DOM image
  128148. */
  128149. loadImage(url: string, image: HTMLImageElement): void;
  128150. private _loadImageFromDBAsync;
  128151. private _saveImageIntoDBAsync;
  128152. private _checkVersionFromDB;
  128153. private _loadVersionFromDBAsync;
  128154. private _saveVersionIntoDBAsync;
  128155. /**
  128156. * Loads a file from database
  128157. * @param url defines the URL to load from
  128158. * @param sceneLoaded defines a callback to call on success
  128159. * @param progressCallBack defines a callback to call when progress changed
  128160. * @param errorCallback defines a callback to call on error
  128161. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128162. */
  128163. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128164. private _loadFileAsync;
  128165. private _saveFileAsync;
  128166. /**
  128167. * Validates if xhr data is correct
  128168. * @param xhr defines the request to validate
  128169. * @param dataType defines the expected data type
  128170. * @returns true if data is correct
  128171. */
  128172. private static _ValidateXHRData;
  128173. }
  128174. }
  128175. declare module BABYLON {
  128176. /** @hidden */
  128177. export var gpuUpdateParticlesPixelShader: {
  128178. name: string;
  128179. shader: string;
  128180. };
  128181. }
  128182. declare module BABYLON {
  128183. /** @hidden */
  128184. export var gpuUpdateParticlesVertexShader: {
  128185. name: string;
  128186. shader: string;
  128187. };
  128188. }
  128189. declare module BABYLON {
  128190. /** @hidden */
  128191. export var clipPlaneFragmentDeclaration2: {
  128192. name: string;
  128193. shader: string;
  128194. };
  128195. }
  128196. declare module BABYLON {
  128197. /** @hidden */
  128198. export var gpuRenderParticlesPixelShader: {
  128199. name: string;
  128200. shader: string;
  128201. };
  128202. }
  128203. declare module BABYLON {
  128204. /** @hidden */
  128205. export var clipPlaneVertexDeclaration2: {
  128206. name: string;
  128207. shader: string;
  128208. };
  128209. }
  128210. declare module BABYLON {
  128211. /** @hidden */
  128212. export var gpuRenderParticlesVertexShader: {
  128213. name: string;
  128214. shader: string;
  128215. };
  128216. }
  128217. declare module BABYLON {
  128218. /**
  128219. * This represents a GPU particle system in Babylon
  128220. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128221. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128222. */
  128223. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128224. /**
  128225. * The layer mask we are rendering the particles through.
  128226. */
  128227. layerMask: number;
  128228. private _capacity;
  128229. private _activeCount;
  128230. private _currentActiveCount;
  128231. private _accumulatedCount;
  128232. private _renderEffect;
  128233. private _updateEffect;
  128234. private _buffer0;
  128235. private _buffer1;
  128236. private _spriteBuffer;
  128237. private _updateVAO;
  128238. private _renderVAO;
  128239. private _targetIndex;
  128240. private _sourceBuffer;
  128241. private _targetBuffer;
  128242. private _engine;
  128243. private _currentRenderId;
  128244. private _started;
  128245. private _stopped;
  128246. private _timeDelta;
  128247. private _randomTexture;
  128248. private _randomTexture2;
  128249. private _attributesStrideSize;
  128250. private _updateEffectOptions;
  128251. private _randomTextureSize;
  128252. private _actualFrame;
  128253. private readonly _rawTextureWidth;
  128254. /**
  128255. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128256. */
  128257. static readonly IsSupported: boolean;
  128258. /**
  128259. * An event triggered when the system is disposed.
  128260. */
  128261. onDisposeObservable: Observable<GPUParticleSystem>;
  128262. /**
  128263. * Gets the maximum number of particles active at the same time.
  128264. * @returns The max number of active particles.
  128265. */
  128266. getCapacity(): number;
  128267. /**
  128268. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128269. * to override the particles.
  128270. */
  128271. forceDepthWrite: boolean;
  128272. /**
  128273. * Gets or set the number of active particles
  128274. */
  128275. activeParticleCount: number;
  128276. private _preWarmDone;
  128277. /**
  128278. * Is this system ready to be used/rendered
  128279. * @return true if the system is ready
  128280. */
  128281. isReady(): boolean;
  128282. /**
  128283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128284. * @returns True if it has been started, otherwise false.
  128285. */
  128286. isStarted(): boolean;
  128287. /**
  128288. * Starts the particle system and begins to emit
  128289. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128290. */
  128291. start(delay?: number): void;
  128292. /**
  128293. * Stops the particle system.
  128294. */
  128295. stop(): void;
  128296. /**
  128297. * Remove all active particles
  128298. */
  128299. reset(): void;
  128300. /**
  128301. * Returns the string "GPUParticleSystem"
  128302. * @returns a string containing the class name
  128303. */
  128304. getClassName(): string;
  128305. private _colorGradientsTexture;
  128306. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128307. /**
  128308. * Adds a new color gradient
  128309. * @param gradient defines the gradient to use (between 0 and 1)
  128310. * @param color1 defines the color to affect to the specified gradient
  128311. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128312. * @returns the current particle system
  128313. */
  128314. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128315. /**
  128316. * Remove a specific color gradient
  128317. * @param gradient defines the gradient to remove
  128318. * @returns the current particle system
  128319. */
  128320. removeColorGradient(gradient: number): GPUParticleSystem;
  128321. private _angularSpeedGradientsTexture;
  128322. private _sizeGradientsTexture;
  128323. private _velocityGradientsTexture;
  128324. private _limitVelocityGradientsTexture;
  128325. private _dragGradientsTexture;
  128326. private _addFactorGradient;
  128327. /**
  128328. * Adds a new size gradient
  128329. * @param gradient defines the gradient to use (between 0 and 1)
  128330. * @param factor defines the size factor to affect to the specified gradient
  128331. * @returns the current particle system
  128332. */
  128333. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128334. /**
  128335. * Remove a specific size gradient
  128336. * @param gradient defines the gradient to remove
  128337. * @returns the current particle system
  128338. */
  128339. removeSizeGradient(gradient: number): GPUParticleSystem;
  128340. /**
  128341. * Adds a new angular speed gradient
  128342. * @param gradient defines the gradient to use (between 0 and 1)
  128343. * @param factor defines the angular speed to affect to the specified gradient
  128344. * @returns the current particle system
  128345. */
  128346. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  128347. /**
  128348. * Remove a specific angular speed gradient
  128349. * @param gradient defines the gradient to remove
  128350. * @returns the current particle system
  128351. */
  128352. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  128353. /**
  128354. * Adds a new velocity gradient
  128355. * @param gradient defines the gradient to use (between 0 and 1)
  128356. * @param factor defines the velocity to affect to the specified gradient
  128357. * @returns the current particle system
  128358. */
  128359. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128360. /**
  128361. * Remove a specific velocity gradient
  128362. * @param gradient defines the gradient to remove
  128363. * @returns the current particle system
  128364. */
  128365. removeVelocityGradient(gradient: number): GPUParticleSystem;
  128366. /**
  128367. * Adds a new limit velocity gradient
  128368. * @param gradient defines the gradient to use (between 0 and 1)
  128369. * @param factor defines the limit velocity value to affect to the specified gradient
  128370. * @returns the current particle system
  128371. */
  128372. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  128373. /**
  128374. * Remove a specific limit velocity gradient
  128375. * @param gradient defines the gradient to remove
  128376. * @returns the current particle system
  128377. */
  128378. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  128379. /**
  128380. * Adds a new drag gradient
  128381. * @param gradient defines the gradient to use (between 0 and 1)
  128382. * @param factor defines the drag value to affect to the specified gradient
  128383. * @returns the current particle system
  128384. */
  128385. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  128386. /**
  128387. * Remove a specific drag gradient
  128388. * @param gradient defines the gradient to remove
  128389. * @returns the current particle system
  128390. */
  128391. removeDragGradient(gradient: number): GPUParticleSystem;
  128392. /**
  128393. * Not supported by GPUParticleSystem
  128394. * @param gradient defines the gradient to use (between 0 and 1)
  128395. * @param factor defines the emit rate value to affect to the specified gradient
  128396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128397. * @returns the current particle system
  128398. */
  128399. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128400. /**
  128401. * Not supported by GPUParticleSystem
  128402. * @param gradient defines the gradient to remove
  128403. * @returns the current particle system
  128404. */
  128405. removeEmitRateGradient(gradient: number): IParticleSystem;
  128406. /**
  128407. * Not supported by GPUParticleSystem
  128408. * @param gradient defines the gradient to use (between 0 and 1)
  128409. * @param factor defines the start size value to affect to the specified gradient
  128410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128411. * @returns the current particle system
  128412. */
  128413. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128414. /**
  128415. * Not supported by GPUParticleSystem
  128416. * @param gradient defines the gradient to remove
  128417. * @returns the current particle system
  128418. */
  128419. removeStartSizeGradient(gradient: number): IParticleSystem;
  128420. /**
  128421. * Not supported by GPUParticleSystem
  128422. * @param gradient defines the gradient to use (between 0 and 1)
  128423. * @param min defines the color remap minimal range
  128424. * @param max defines the color remap maximal range
  128425. * @returns the current particle system
  128426. */
  128427. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128428. /**
  128429. * Not supported by GPUParticleSystem
  128430. * @param gradient defines the gradient to remove
  128431. * @returns the current particle system
  128432. */
  128433. removeColorRemapGradient(): IParticleSystem;
  128434. /**
  128435. * Not supported by GPUParticleSystem
  128436. * @param gradient defines the gradient to use (between 0 and 1)
  128437. * @param min defines the alpha remap minimal range
  128438. * @param max defines the alpha remap maximal range
  128439. * @returns the current particle system
  128440. */
  128441. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  128442. /**
  128443. * Not supported by GPUParticleSystem
  128444. * @param gradient defines the gradient to remove
  128445. * @returns the current particle system
  128446. */
  128447. removeAlphaRemapGradient(): IParticleSystem;
  128448. /**
  128449. * Not supported by GPUParticleSystem
  128450. * @param gradient defines the gradient to use (between 0 and 1)
  128451. * @param color defines the color to affect to the specified gradient
  128452. * @returns the current particle system
  128453. */
  128454. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  128455. /**
  128456. * Not supported by GPUParticleSystem
  128457. * @param gradient defines the gradient to remove
  128458. * @returns the current particle system
  128459. */
  128460. removeRampGradient(): IParticleSystem;
  128461. /**
  128462. * Not supported by GPUParticleSystem
  128463. * @returns the list of ramp gradients
  128464. */
  128465. getRampGradients(): Nullable<Array<Color3Gradient>>;
  128466. /**
  128467. * Not supported by GPUParticleSystem
  128468. * Gets or sets a boolean indicating that ramp gradients must be used
  128469. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  128470. */
  128471. useRampGradients: boolean;
  128472. /**
  128473. * Not supported by GPUParticleSystem
  128474. * @param gradient defines the gradient to use (between 0 and 1)
  128475. * @param factor defines the life time factor to affect to the specified gradient
  128476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  128477. * @returns the current particle system
  128478. */
  128479. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  128480. /**
  128481. * Not supported by GPUParticleSystem
  128482. * @param gradient defines the gradient to remove
  128483. * @returns the current particle system
  128484. */
  128485. removeLifeTimeGradient(gradient: number): IParticleSystem;
  128486. /**
  128487. * Instantiates a GPU particle system.
  128488. * 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.
  128489. * @param name The name of the particle system
  128490. * @param options The options used to create the system
  128491. * @param scene The scene the particle system belongs to
  128492. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  128493. */
  128494. constructor(name: string, options: Partial<{
  128495. capacity: number;
  128496. randomTextureSize: number;
  128497. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  128498. protected _reset(): void;
  128499. private _createUpdateVAO;
  128500. private _createRenderVAO;
  128501. private _initialize;
  128502. /** @hidden */
  128503. _recreateUpdateEffect(): void;
  128504. /** @hidden */
  128505. _recreateRenderEffect(): void;
  128506. /**
  128507. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  128508. * @param preWarm defines if we are in the pre-warmimg phase
  128509. */
  128510. animate(preWarm?: boolean): void;
  128511. private _createFactorGradientTexture;
  128512. private _createSizeGradientTexture;
  128513. private _createAngularSpeedGradientTexture;
  128514. private _createVelocityGradientTexture;
  128515. private _createLimitVelocityGradientTexture;
  128516. private _createDragGradientTexture;
  128517. private _createColorGradientTexture;
  128518. /**
  128519. * Renders the particle system in its current state
  128520. * @param preWarm defines if the system should only update the particles but not render them
  128521. * @returns the current number of particles
  128522. */
  128523. render(preWarm?: boolean): number;
  128524. /**
  128525. * Rebuilds the particle system
  128526. */
  128527. rebuild(): void;
  128528. private _releaseBuffers;
  128529. private _releaseVAOs;
  128530. /**
  128531. * Disposes the particle system and free the associated resources
  128532. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  128533. */
  128534. dispose(disposeTexture?: boolean): void;
  128535. /**
  128536. * Clones the particle system.
  128537. * @param name The name of the cloned object
  128538. * @param newEmitter The new emitter to use
  128539. * @returns the cloned particle system
  128540. */
  128541. clone(name: string, newEmitter: any): GPUParticleSystem;
  128542. /**
  128543. * Serializes the particle system to a JSON object.
  128544. * @returns the JSON object
  128545. */
  128546. serialize(): any;
  128547. /**
  128548. * Parses a JSON object to create a GPU particle system.
  128549. * @param parsedParticleSystem The JSON object to parse
  128550. * @param scene The scene to create the particle system in
  128551. * @param rootUrl The root url to use to load external dependencies like texture
  128552. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  128553. * @returns the parsed GPU particle system
  128554. */
  128555. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  128556. }
  128557. }
  128558. declare module BABYLON {
  128559. /**
  128560. * Represents a set of particle systems working together to create a specific effect
  128561. */
  128562. export class ParticleSystemSet implements IDisposable {
  128563. /**
  128564. * Gets or sets base Assets URL
  128565. */
  128566. static BaseAssetsUrl: string;
  128567. private _emitterCreationOptions;
  128568. private _emitterNode;
  128569. /**
  128570. * Gets the particle system list
  128571. */
  128572. systems: IParticleSystem[];
  128573. /**
  128574. * Gets the emitter node used with this set
  128575. */
  128576. readonly emitterNode: Nullable<TransformNode>;
  128577. /**
  128578. * Creates a new emitter mesh as a sphere
  128579. * @param options defines the options used to create the sphere
  128580. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  128581. * @param scene defines the hosting scene
  128582. */
  128583. setEmitterAsSphere(options: {
  128584. diameter: number;
  128585. segments: number;
  128586. color: Color3;
  128587. }, renderingGroupId: number, scene: Scene): void;
  128588. /**
  128589. * Starts all particle systems of the set
  128590. * @param emitter defines an optional mesh to use as emitter for the particle systems
  128591. */
  128592. start(emitter?: AbstractMesh): void;
  128593. /**
  128594. * Release all associated resources
  128595. */
  128596. dispose(): void;
  128597. /**
  128598. * Serialize the set into a JSON compatible object
  128599. * @returns a JSON compatible representation of the set
  128600. */
  128601. serialize(): any;
  128602. /**
  128603. * Parse a new ParticleSystemSet from a serialized source
  128604. * @param data defines a JSON compatible representation of the set
  128605. * @param scene defines the hosting scene
  128606. * @param gpu defines if we want GPU particles or CPU particles
  128607. * @returns a new ParticleSystemSet
  128608. */
  128609. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  128610. }
  128611. }
  128612. declare module BABYLON {
  128613. /**
  128614. * This class is made for on one-liner static method to help creating particle system set.
  128615. */
  128616. export class ParticleHelper {
  128617. /**
  128618. * Gets or sets base Assets URL
  128619. */
  128620. static BaseAssetsUrl: string;
  128621. /**
  128622. * Create a default particle system that you can tweak
  128623. * @param emitter defines the emitter to use
  128624. * @param capacity defines the system capacity (default is 500 particles)
  128625. * @param scene defines the hosting scene
  128626. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  128627. * @returns the new Particle system
  128628. */
  128629. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  128630. /**
  128631. * This is the main static method (one-liner) of this helper to create different particle systems
  128632. * @param type This string represents the type to the particle system to create
  128633. * @param scene The scene where the particle system should live
  128634. * @param gpu If the system will use gpu
  128635. * @returns the ParticleSystemSet created
  128636. */
  128637. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  128638. /**
  128639. * Static function used to export a particle system to a ParticleSystemSet variable.
  128640. * Please note that the emitter shape is not exported
  128641. * @param systems defines the particle systems to export
  128642. * @returns the created particle system set
  128643. */
  128644. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. interface Engine {
  128649. /**
  128650. * Create an effect to use with particle systems.
  128651. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  128652. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  128653. * @param uniformsNames defines a list of attribute names
  128654. * @param samplers defines an array of string used to represent textures
  128655. * @param defines defines the string containing the defines to use to compile the shaders
  128656. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  128657. * @param onCompiled defines a function to call when the effect creation is successful
  128658. * @param onError defines a function to call when the effect creation has failed
  128659. * @returns the new Effect
  128660. */
  128661. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  128662. }
  128663. interface Mesh {
  128664. /**
  128665. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  128666. * @returns an array of IParticleSystem
  128667. */
  128668. getEmittedParticleSystems(): IParticleSystem[];
  128669. /**
  128670. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  128671. * @returns an array of IParticleSystem
  128672. */
  128673. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  128674. }
  128675. /**
  128676. * @hidden
  128677. */
  128678. export var _IDoNeedToBeInTheBuild: number;
  128679. }
  128680. declare module BABYLON {
  128681. /** Defines the 4 color options */
  128682. export enum PointColor {
  128683. /** color value */
  128684. Color = 2,
  128685. /** uv value */
  128686. UV = 1,
  128687. /** random value */
  128688. Random = 0,
  128689. /** stated value */
  128690. Stated = 3
  128691. }
  128692. /**
  128693. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  128694. * 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.
  128695. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  128696. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  128697. *
  128698. * Full documentation here : TO BE ENTERED
  128699. */
  128700. export class PointsCloudSystem implements IDisposable {
  128701. /**
  128702. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  128703. * Example : var p = SPS.particles[i];
  128704. */
  128705. particles: CloudPoint[];
  128706. /**
  128707. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  128708. */
  128709. nbParticles: number;
  128710. /**
  128711. * This a counter for your own usage. It's not set by any SPS functions.
  128712. */
  128713. counter: number;
  128714. /**
  128715. * The PCS name. This name is also given to the underlying mesh.
  128716. */
  128717. name: string;
  128718. /**
  128719. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  128720. */
  128721. mesh: Mesh;
  128722. /**
  128723. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  128724. * Please read :
  128725. */
  128726. vars: any;
  128727. /**
  128728. * @hidden
  128729. */
  128730. _size: number;
  128731. private _scene;
  128732. private _promises;
  128733. private _positions;
  128734. private _indices;
  128735. private _normals;
  128736. private _colors;
  128737. private _uvs;
  128738. private _indices32;
  128739. private _positions32;
  128740. private _colors32;
  128741. private _uvs32;
  128742. private _updatable;
  128743. private _isVisibilityBoxLocked;
  128744. private _alwaysVisible;
  128745. private _groups;
  128746. private _groupCounter;
  128747. private _computeParticleColor;
  128748. private _computeParticleTexture;
  128749. private _computeParticleRotation;
  128750. private _computeBoundingBox;
  128751. private _isReady;
  128752. /**
  128753. * Creates a PCS (Points Cloud System) object
  128754. * @param name (String) is the PCS name, this will be the underlying mesh name
  128755. * @param pointSize (number) is the size for each point
  128756. * @param scene (Scene) is the scene in which the PCS is added
  128757. * @param options defines the options of the PCS e.g.
  128758. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  128759. */
  128760. constructor(name: string, pointSize: number, scene: Scene, options?: {
  128761. updatable?: boolean;
  128762. });
  128763. /**
  128764. * Builds the PCS underlying mesh. Returns a standard Mesh.
  128765. * If no points were added to the PCS, the returned mesh is just a single point.
  128766. * @returns a promise for the created mesh
  128767. */
  128768. buildMeshAsync(): Promise<Mesh>;
  128769. /**
  128770. * @hidden
  128771. */
  128772. private _buildMesh;
  128773. private _addParticle;
  128774. private _randomUnitVector;
  128775. private _getColorIndicesForCoord;
  128776. private _setPointsColorOrUV;
  128777. private _colorFromTexture;
  128778. private _calculateDensity;
  128779. /**
  128780. * Adds points to the PCS in random positions within a unit sphere
  128781. * @param nb (positive integer) the number of particles to be created from this model
  128782. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  128783. * @returns the number of groups in the system
  128784. */
  128785. addPoints(nb: number, pointFunction?: any): number;
  128786. /**
  128787. * Adds points to the PCS from the surface of the model shape
  128788. * @param mesh is any Mesh object that will be used as a surface model for the points
  128789. * @param nb (positive integer) the number of particles to be created from this model
  128790. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128791. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128792. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128793. * @returns the number of groups in the system
  128794. */
  128795. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128796. /**
  128797. * Adds points to the PCS inside the model shape
  128798. * @param mesh is any Mesh object that will be used as a surface model for the points
  128799. * @param nb (positive integer) the number of particles to be created from this model
  128800. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  128801. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  128802. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  128803. * @returns the number of groups in the system
  128804. */
  128805. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  128806. /**
  128807. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  128808. * This method calls `updateParticle()` for each particle of the SPS.
  128809. * For an animated SPS, it is usually called within the render loop.
  128810. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  128811. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  128812. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  128813. * @returns the PCS.
  128814. */
  128815. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  128816. /**
  128817. * Disposes the PCS.
  128818. */
  128819. dispose(): void;
  128820. /**
  128821. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  128822. * doc :
  128823. * @returns the PCS.
  128824. */
  128825. refreshVisibleSize(): PointsCloudSystem;
  128826. /**
  128827. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  128828. * @param size the size (float) of the visibility box
  128829. * note : this doesn't lock the PCS mesh bounding box.
  128830. * doc :
  128831. */
  128832. setVisibilityBox(size: number): void;
  128833. /**
  128834. * Gets whether the PCS is always visible or not
  128835. * doc :
  128836. */
  128837. /**
  128838. * Sets the PCS as always visible or not
  128839. * doc :
  128840. */
  128841. isAlwaysVisible: boolean;
  128842. /**
  128843. * Tells to `setParticles()` to compute the particle rotations or not
  128844. * Default value : false. The PCS is faster when it's set to false
  128845. * Note : particle rotations are only applied to parent particles
  128846. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  128847. */
  128848. computeParticleRotation: boolean;
  128849. /**
  128850. * Tells to `setParticles()` to compute the particle colors or not.
  128851. * Default value : true. The PCS is faster when it's set to false.
  128852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128853. */
  128854. /**
  128855. * Gets if `setParticles()` computes the particle colors or not.
  128856. * Default value : false. The PCS is faster when it's set to false.
  128857. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  128858. */
  128859. computeParticleColor: boolean;
  128860. /**
  128861. * Gets if `setParticles()` computes the particle textures or not.
  128862. * Default value : false. The PCS is faster when it's set to false.
  128863. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  128864. */
  128865. computeParticleTexture: boolean;
  128866. /**
  128867. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  128868. */
  128869. /**
  128870. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  128871. */
  128872. computeBoundingBox: boolean;
  128873. /**
  128874. * This function does nothing. It may be overwritten to set all the particle first values.
  128875. * The PCS doesn't call this function, you may have to call it by your own.
  128876. * doc :
  128877. */
  128878. initParticles(): void;
  128879. /**
  128880. * This function does nothing. It may be overwritten to recycle a particle
  128881. * The PCS doesn't call this function, you can to call it
  128882. * doc :
  128883. * @param particle The particle to recycle
  128884. * @returns the recycled particle
  128885. */
  128886. recycleParticle(particle: CloudPoint): CloudPoint;
  128887. /**
  128888. * Updates a particle : this function should be overwritten by the user.
  128889. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  128890. * doc :
  128891. * @example : just set a particle position or velocity and recycle conditions
  128892. * @param particle The particle to update
  128893. * @returns the updated particle
  128894. */
  128895. updateParticle(particle: CloudPoint): CloudPoint;
  128896. /**
  128897. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  128898. * This does nothing and may be overwritten by the user.
  128899. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128900. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128901. * @param update the boolean update value actually passed to setParticles()
  128902. */
  128903. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128904. /**
  128905. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  128906. * This will be passed three parameters.
  128907. * This does nothing and may be overwritten by the user.
  128908. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  128909. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  128910. * @param update the boolean update value actually passed to setParticles()
  128911. */
  128912. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  128913. }
  128914. }
  128915. declare module BABYLON {
  128916. /**
  128917. * Represents one particle of a points cloud system.
  128918. */
  128919. export class CloudPoint {
  128920. /**
  128921. * particle global index
  128922. */
  128923. idx: number;
  128924. /**
  128925. * The color of the particle
  128926. */
  128927. color: Nullable<Color4>;
  128928. /**
  128929. * The world space position of the particle.
  128930. */
  128931. position: Vector3;
  128932. /**
  128933. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  128934. */
  128935. rotation: Vector3;
  128936. /**
  128937. * The world space rotation quaternion of the particle.
  128938. */
  128939. rotationQuaternion: Nullable<Quaternion>;
  128940. /**
  128941. * The uv of the particle.
  128942. */
  128943. uv: Nullable<Vector2>;
  128944. /**
  128945. * The current speed of the particle.
  128946. */
  128947. velocity: Vector3;
  128948. /**
  128949. * The pivot point in the particle local space.
  128950. */
  128951. pivot: Vector3;
  128952. /**
  128953. * Must the particle be translated from its pivot point in its local space ?
  128954. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  128955. * Default : false
  128956. */
  128957. translateFromPivot: boolean;
  128958. /**
  128959. * Index of this particle in the global "positions" array (Internal use)
  128960. * @hidden
  128961. */
  128962. _pos: number;
  128963. /**
  128964. * @hidden Index of this particle in the global "indices" array (Internal use)
  128965. */
  128966. _ind: number;
  128967. /**
  128968. * Group this particle belongs to
  128969. */
  128970. _group: PointsGroup;
  128971. /**
  128972. * Group id of this particle
  128973. */
  128974. groupId: number;
  128975. /**
  128976. * Index of the particle in its group id (Internal use)
  128977. */
  128978. idxInGroup: number;
  128979. /**
  128980. * @hidden Particle BoundingInfo object (Internal use)
  128981. */
  128982. _boundingInfo: BoundingInfo;
  128983. /**
  128984. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  128985. */
  128986. _pcs: PointsCloudSystem;
  128987. /**
  128988. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  128989. */
  128990. _stillInvisible: boolean;
  128991. /**
  128992. * @hidden Last computed particle rotation matrix
  128993. */
  128994. _rotationMatrix: number[];
  128995. /**
  128996. * Parent particle Id, if any.
  128997. * Default null.
  128998. */
  128999. parentId: Nullable<number>;
  129000. /**
  129001. * @hidden Internal global position in the PCS.
  129002. */
  129003. _globalPosition: Vector3;
  129004. /**
  129005. * Creates a Point Cloud object.
  129006. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129007. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129008. * @param group (PointsGroup) is the group the particle belongs to
  129009. * @param groupId (integer) is the group identifier in the PCS.
  129010. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129011. * @param pcs defines the PCS it is associated to
  129012. */
  129013. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129014. /**
  129015. * get point size
  129016. */
  129017. /**
  129018. * Set point size
  129019. */
  129020. size: Vector3;
  129021. /**
  129022. * Legacy support, changed quaternion to rotationQuaternion
  129023. */
  129024. /**
  129025. * Legacy support, changed quaternion to rotationQuaternion
  129026. */
  129027. quaternion: Nullable<Quaternion>;
  129028. /**
  129029. * Returns a boolean. True if the particle intersects a mesh, else false
  129030. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129031. * @param target is the object (point or mesh) what the intersection is computed against
  129032. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129033. * @returns true if it intersects
  129034. */
  129035. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129036. /**
  129037. * get the rotation matrix of the particle
  129038. * @hidden
  129039. */
  129040. getRotationMatrix(m: Matrix): void;
  129041. }
  129042. /**
  129043. * Represents a group of points in a points cloud system
  129044. * * PCS internal tool, don't use it manually.
  129045. */
  129046. export class PointsGroup {
  129047. /**
  129048. * The group id
  129049. * @hidden
  129050. */
  129051. groupID: number;
  129052. /**
  129053. * image data for group (internal use)
  129054. * @hidden
  129055. */
  129056. _groupImageData: Nullable<ArrayBufferView>;
  129057. /**
  129058. * Image Width (internal use)
  129059. * @hidden
  129060. */
  129061. _groupImgWidth: number;
  129062. /**
  129063. * Image Height (internal use)
  129064. * @hidden
  129065. */
  129066. _groupImgHeight: number;
  129067. /**
  129068. * Custom position function (internal use)
  129069. * @hidden
  129070. */
  129071. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129072. /**
  129073. * density per facet for surface points
  129074. * @hidden
  129075. */
  129076. _groupDensity: number[];
  129077. /**
  129078. * Only when points are colored by texture carries pointer to texture list array
  129079. * @hidden
  129080. */
  129081. _textureNb: number;
  129082. /**
  129083. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129084. * PCS internal tool, don't use it manually.
  129085. * @hidden
  129086. */
  129087. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129088. }
  129089. }
  129090. declare module BABYLON {
  129091. interface Scene {
  129092. /** @hidden (Backing field) */
  129093. _physicsEngine: Nullable<IPhysicsEngine>;
  129094. /** @hidden */
  129095. _physicsTimeAccumulator: number;
  129096. /**
  129097. * Gets the current physics engine
  129098. * @returns a IPhysicsEngine or null if none attached
  129099. */
  129100. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129101. /**
  129102. * Enables physics to the current scene
  129103. * @param gravity defines the scene's gravity for the physics engine
  129104. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129105. * @return a boolean indicating if the physics engine was initialized
  129106. */
  129107. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129108. /**
  129109. * Disables and disposes the physics engine associated with the scene
  129110. */
  129111. disablePhysicsEngine(): void;
  129112. /**
  129113. * Gets a boolean indicating if there is an active physics engine
  129114. * @returns a boolean indicating if there is an active physics engine
  129115. */
  129116. isPhysicsEnabled(): boolean;
  129117. /**
  129118. * Deletes a physics compound impostor
  129119. * @param compound defines the compound to delete
  129120. */
  129121. deleteCompoundImpostor(compound: any): void;
  129122. /**
  129123. * An event triggered when physic simulation is about to be run
  129124. */
  129125. onBeforePhysicsObservable: Observable<Scene>;
  129126. /**
  129127. * An event triggered when physic simulation has been done
  129128. */
  129129. onAfterPhysicsObservable: Observable<Scene>;
  129130. }
  129131. interface AbstractMesh {
  129132. /** @hidden */
  129133. _physicsImpostor: Nullable<PhysicsImpostor>;
  129134. /**
  129135. * Gets or sets impostor used for physic simulation
  129136. * @see http://doc.babylonjs.com/features/physics_engine
  129137. */
  129138. physicsImpostor: Nullable<PhysicsImpostor>;
  129139. /**
  129140. * Gets the current physics impostor
  129141. * @see http://doc.babylonjs.com/features/physics_engine
  129142. * @returns a physics impostor or null
  129143. */
  129144. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129145. /** Apply a physic impulse to the mesh
  129146. * @param force defines the force to apply
  129147. * @param contactPoint defines where to apply the force
  129148. * @returns the current mesh
  129149. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129150. */
  129151. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129152. /**
  129153. * Creates a physic joint between two meshes
  129154. * @param otherMesh defines the other mesh to use
  129155. * @param pivot1 defines the pivot to use on this mesh
  129156. * @param pivot2 defines the pivot to use on the other mesh
  129157. * @param options defines additional options (can be plugin dependent)
  129158. * @returns the current mesh
  129159. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129160. */
  129161. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129162. /** @hidden */
  129163. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129164. }
  129165. /**
  129166. * Defines the physics engine scene component responsible to manage a physics engine
  129167. */
  129168. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129169. /**
  129170. * The component name helpful to identify the component in the list of scene components.
  129171. */
  129172. readonly name: string;
  129173. /**
  129174. * The scene the component belongs to.
  129175. */
  129176. scene: Scene;
  129177. /**
  129178. * Creates a new instance of the component for the given scene
  129179. * @param scene Defines the scene to register the component in
  129180. */
  129181. constructor(scene: Scene);
  129182. /**
  129183. * Registers the component in a given scene
  129184. */
  129185. register(): void;
  129186. /**
  129187. * Rebuilds the elements related to this component in case of
  129188. * context lost for instance.
  129189. */
  129190. rebuild(): void;
  129191. /**
  129192. * Disposes the component and the associated ressources
  129193. */
  129194. dispose(): void;
  129195. }
  129196. }
  129197. declare module BABYLON {
  129198. /**
  129199. * A helper for physics simulations
  129200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129201. */
  129202. export class PhysicsHelper {
  129203. private _scene;
  129204. private _physicsEngine;
  129205. /**
  129206. * Initializes the Physics helper
  129207. * @param scene Babylon.js scene
  129208. */
  129209. constructor(scene: Scene);
  129210. /**
  129211. * Applies a radial explosion impulse
  129212. * @param origin the origin of the explosion
  129213. * @param radiusOrEventOptions the radius or the options of radial explosion
  129214. * @param strength the explosion strength
  129215. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129216. * @returns A physics radial explosion event, or null
  129217. */
  129218. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129219. /**
  129220. * Applies a radial explosion force
  129221. * @param origin the origin of the explosion
  129222. * @param radiusOrEventOptions the radius or the options of radial explosion
  129223. * @param strength the explosion strength
  129224. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129225. * @returns A physics radial explosion event, or null
  129226. */
  129227. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129228. /**
  129229. * Creates a gravitational field
  129230. * @param origin the origin of the explosion
  129231. * @param radiusOrEventOptions the radius or the options of radial explosion
  129232. * @param strength the explosion strength
  129233. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129234. * @returns A physics gravitational field event, or null
  129235. */
  129236. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129237. /**
  129238. * Creates a physics updraft event
  129239. * @param origin the origin of the updraft
  129240. * @param radiusOrEventOptions the radius or the options of the updraft
  129241. * @param strength the strength of the updraft
  129242. * @param height the height of the updraft
  129243. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129244. * @returns A physics updraft event, or null
  129245. */
  129246. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129247. /**
  129248. * Creates a physics vortex event
  129249. * @param origin the of the vortex
  129250. * @param radiusOrEventOptions the radius or the options of the vortex
  129251. * @param strength the strength of the vortex
  129252. * @param height the height of the vortex
  129253. * @returns a Physics vortex event, or null
  129254. * A physics vortex event or null
  129255. */
  129256. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129257. }
  129258. /**
  129259. * Represents a physics radial explosion event
  129260. */
  129261. class PhysicsRadialExplosionEvent {
  129262. private _scene;
  129263. private _options;
  129264. private _sphere;
  129265. private _dataFetched;
  129266. /**
  129267. * Initializes a radial explosioin event
  129268. * @param _scene BabylonJS scene
  129269. * @param _options The options for the vortex event
  129270. */
  129271. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129272. /**
  129273. * Returns the data related to the radial explosion event (sphere).
  129274. * @returns The radial explosion event data
  129275. */
  129276. getData(): PhysicsRadialExplosionEventData;
  129277. /**
  129278. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129279. * @param impostor A physics imposter
  129280. * @param origin the origin of the explosion
  129281. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129282. */
  129283. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129284. /**
  129285. * Triggers affecterd impostors callbacks
  129286. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129287. */
  129288. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129289. /**
  129290. * Disposes the sphere.
  129291. * @param force Specifies if the sphere should be disposed by force
  129292. */
  129293. dispose(force?: boolean): void;
  129294. /*** Helpers ***/
  129295. private _prepareSphere;
  129296. private _intersectsWithSphere;
  129297. }
  129298. /**
  129299. * Represents a gravitational field event
  129300. */
  129301. class PhysicsGravitationalFieldEvent {
  129302. private _physicsHelper;
  129303. private _scene;
  129304. private _origin;
  129305. private _options;
  129306. private _tickCallback;
  129307. private _sphere;
  129308. private _dataFetched;
  129309. /**
  129310. * Initializes the physics gravitational field event
  129311. * @param _physicsHelper A physics helper
  129312. * @param _scene BabylonJS scene
  129313. * @param _origin The origin position of the gravitational field event
  129314. * @param _options The options for the vortex event
  129315. */
  129316. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129317. /**
  129318. * Returns the data related to the gravitational field event (sphere).
  129319. * @returns A gravitational field event
  129320. */
  129321. getData(): PhysicsGravitationalFieldEventData;
  129322. /**
  129323. * Enables the gravitational field.
  129324. */
  129325. enable(): void;
  129326. /**
  129327. * Disables the gravitational field.
  129328. */
  129329. disable(): void;
  129330. /**
  129331. * Disposes the sphere.
  129332. * @param force The force to dispose from the gravitational field event
  129333. */
  129334. dispose(force?: boolean): void;
  129335. private _tick;
  129336. }
  129337. /**
  129338. * Represents a physics updraft event
  129339. */
  129340. class PhysicsUpdraftEvent {
  129341. private _scene;
  129342. private _origin;
  129343. private _options;
  129344. private _physicsEngine;
  129345. private _originTop;
  129346. private _originDirection;
  129347. private _tickCallback;
  129348. private _cylinder;
  129349. private _cylinderPosition;
  129350. private _dataFetched;
  129351. /**
  129352. * Initializes the physics updraft event
  129353. * @param _scene BabylonJS scene
  129354. * @param _origin The origin position of the updraft
  129355. * @param _options The options for the updraft event
  129356. */
  129357. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  129358. /**
  129359. * Returns the data related to the updraft event (cylinder).
  129360. * @returns A physics updraft event
  129361. */
  129362. getData(): PhysicsUpdraftEventData;
  129363. /**
  129364. * Enables the updraft.
  129365. */
  129366. enable(): void;
  129367. /**
  129368. * Disables the updraft.
  129369. */
  129370. disable(): void;
  129371. /**
  129372. * Disposes the cylinder.
  129373. * @param force Specifies if the updraft should be disposed by force
  129374. */
  129375. dispose(force?: boolean): void;
  129376. private getImpostorHitData;
  129377. private _tick;
  129378. /*** Helpers ***/
  129379. private _prepareCylinder;
  129380. private _intersectsWithCylinder;
  129381. }
  129382. /**
  129383. * Represents a physics vortex event
  129384. */
  129385. class PhysicsVortexEvent {
  129386. private _scene;
  129387. private _origin;
  129388. private _options;
  129389. private _physicsEngine;
  129390. private _originTop;
  129391. private _tickCallback;
  129392. private _cylinder;
  129393. private _cylinderPosition;
  129394. private _dataFetched;
  129395. /**
  129396. * Initializes the physics vortex event
  129397. * @param _scene The BabylonJS scene
  129398. * @param _origin The origin position of the vortex
  129399. * @param _options The options for the vortex event
  129400. */
  129401. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  129402. /**
  129403. * Returns the data related to the vortex event (cylinder).
  129404. * @returns The physics vortex event data
  129405. */
  129406. getData(): PhysicsVortexEventData;
  129407. /**
  129408. * Enables the vortex.
  129409. */
  129410. enable(): void;
  129411. /**
  129412. * Disables the cortex.
  129413. */
  129414. disable(): void;
  129415. /**
  129416. * Disposes the sphere.
  129417. * @param force
  129418. */
  129419. dispose(force?: boolean): void;
  129420. private getImpostorHitData;
  129421. private _tick;
  129422. /*** Helpers ***/
  129423. private _prepareCylinder;
  129424. private _intersectsWithCylinder;
  129425. }
  129426. /**
  129427. * Options fot the radial explosion event
  129428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129429. */
  129430. export class PhysicsRadialExplosionEventOptions {
  129431. /**
  129432. * The radius of the sphere for the radial explosion.
  129433. */
  129434. radius: number;
  129435. /**
  129436. * The strenth of the explosion.
  129437. */
  129438. strength: number;
  129439. /**
  129440. * The strenght of the force in correspondence to the distance of the affected object
  129441. */
  129442. falloff: PhysicsRadialImpulseFalloff;
  129443. /**
  129444. * Sphere options for the radial explosion.
  129445. */
  129446. sphere: {
  129447. segments: number;
  129448. diameter: number;
  129449. };
  129450. /**
  129451. * Sphere options for the radial explosion.
  129452. */
  129453. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  129454. }
  129455. /**
  129456. * Options fot the updraft event
  129457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129458. */
  129459. export class PhysicsUpdraftEventOptions {
  129460. /**
  129461. * The radius of the cylinder for the vortex
  129462. */
  129463. radius: number;
  129464. /**
  129465. * The strenth of the updraft.
  129466. */
  129467. strength: number;
  129468. /**
  129469. * The height of the cylinder for the updraft.
  129470. */
  129471. height: number;
  129472. /**
  129473. * The mode for the the updraft.
  129474. */
  129475. updraftMode: PhysicsUpdraftMode;
  129476. }
  129477. /**
  129478. * Options fot the vortex event
  129479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129480. */
  129481. export class PhysicsVortexEventOptions {
  129482. /**
  129483. * The radius of the cylinder for the vortex
  129484. */
  129485. radius: number;
  129486. /**
  129487. * The strenth of the vortex.
  129488. */
  129489. strength: number;
  129490. /**
  129491. * The height of the cylinder for the vortex.
  129492. */
  129493. height: number;
  129494. /**
  129495. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  129496. */
  129497. centripetalForceThreshold: number;
  129498. /**
  129499. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  129500. */
  129501. centripetalForceMultiplier: number;
  129502. /**
  129503. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  129504. */
  129505. centrifugalForceMultiplier: number;
  129506. /**
  129507. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  129508. */
  129509. updraftForceMultiplier: number;
  129510. }
  129511. /**
  129512. * The strenght of the force in correspondence to the distance of the affected object
  129513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129514. */
  129515. export enum PhysicsRadialImpulseFalloff {
  129516. /** Defines that impulse is constant in strength across it's whole radius */
  129517. Constant = 0,
  129518. /** Defines that impulse gets weaker if it's further from the origin */
  129519. Linear = 1
  129520. }
  129521. /**
  129522. * The strength of the force in correspondence to the distance of the affected object
  129523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129524. */
  129525. export enum PhysicsUpdraftMode {
  129526. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  129527. Center = 0,
  129528. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  129529. Perpendicular = 1
  129530. }
  129531. /**
  129532. * Interface for a physics hit data
  129533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129534. */
  129535. export interface PhysicsHitData {
  129536. /**
  129537. * The force applied at the contact point
  129538. */
  129539. force: Vector3;
  129540. /**
  129541. * The contact point
  129542. */
  129543. contactPoint: Vector3;
  129544. /**
  129545. * The distance from the origin to the contact point
  129546. */
  129547. distanceFromOrigin: number;
  129548. }
  129549. /**
  129550. * Interface for radial explosion event data
  129551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129552. */
  129553. export interface PhysicsRadialExplosionEventData {
  129554. /**
  129555. * A sphere used for the radial explosion event
  129556. */
  129557. sphere: Mesh;
  129558. }
  129559. /**
  129560. * Interface for gravitational field event data
  129561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129562. */
  129563. export interface PhysicsGravitationalFieldEventData {
  129564. /**
  129565. * A sphere mesh used for the gravitational field event
  129566. */
  129567. sphere: Mesh;
  129568. }
  129569. /**
  129570. * Interface for updraft event data
  129571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129572. */
  129573. export interface PhysicsUpdraftEventData {
  129574. /**
  129575. * A cylinder used for the updraft event
  129576. */
  129577. cylinder: Mesh;
  129578. }
  129579. /**
  129580. * Interface for vortex event data
  129581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129582. */
  129583. export interface PhysicsVortexEventData {
  129584. /**
  129585. * A cylinder used for the vortex event
  129586. */
  129587. cylinder: Mesh;
  129588. }
  129589. /**
  129590. * Interface for an affected physics impostor
  129591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129592. */
  129593. export interface PhysicsAffectedImpostorWithData {
  129594. /**
  129595. * The impostor affected by the effect
  129596. */
  129597. impostor: PhysicsImpostor;
  129598. /**
  129599. * The data about the hit/horce from the explosion
  129600. */
  129601. hitData: PhysicsHitData;
  129602. }
  129603. }
  129604. declare module BABYLON {
  129605. /** @hidden */
  129606. export var blackAndWhitePixelShader: {
  129607. name: string;
  129608. shader: string;
  129609. };
  129610. }
  129611. declare module BABYLON {
  129612. /**
  129613. * Post process used to render in black and white
  129614. */
  129615. export class BlackAndWhitePostProcess extends PostProcess {
  129616. /**
  129617. * Linear about to convert he result to black and white (default: 1)
  129618. */
  129619. degree: number;
  129620. /**
  129621. * Creates a black and white post process
  129622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  129623. * @param name The name of the effect.
  129624. * @param options The required width/height ratio to downsize to before computing the render pass.
  129625. * @param camera The camera to apply the render pass to.
  129626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129627. * @param engine The engine which the post process will be applied. (default: current engine)
  129628. * @param reusable If the post process can be reused on the same frame. (default: false)
  129629. */
  129630. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129631. }
  129632. }
  129633. declare module BABYLON {
  129634. /**
  129635. * This represents a set of one or more post processes in Babylon.
  129636. * A post process can be used to apply a shader to a texture after it is rendered.
  129637. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129638. */
  129639. export class PostProcessRenderEffect {
  129640. private _postProcesses;
  129641. private _getPostProcesses;
  129642. private _singleInstance;
  129643. private _cameras;
  129644. private _indicesForCamera;
  129645. /**
  129646. * Name of the effect
  129647. * @hidden
  129648. */
  129649. _name: string;
  129650. /**
  129651. * Instantiates a post process render effect.
  129652. * A post process can be used to apply a shader to a texture after it is rendered.
  129653. * @param engine The engine the effect is tied to
  129654. * @param name The name of the effect
  129655. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  129656. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  129657. */
  129658. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  129659. /**
  129660. * Checks if all the post processes in the effect are supported.
  129661. */
  129662. readonly isSupported: boolean;
  129663. /**
  129664. * Updates the current state of the effect
  129665. * @hidden
  129666. */
  129667. _update(): void;
  129668. /**
  129669. * Attaches the effect on cameras
  129670. * @param cameras The camera to attach to.
  129671. * @hidden
  129672. */
  129673. _attachCameras(cameras: Camera): void;
  129674. /**
  129675. * Attaches the effect on cameras
  129676. * @param cameras The camera to attach to.
  129677. * @hidden
  129678. */
  129679. _attachCameras(cameras: Camera[]): void;
  129680. /**
  129681. * Detaches the effect on cameras
  129682. * @param cameras The camera to detatch from.
  129683. * @hidden
  129684. */
  129685. _detachCameras(cameras: Camera): void;
  129686. /**
  129687. * Detatches the effect on cameras
  129688. * @param cameras The camera to detatch from.
  129689. * @hidden
  129690. */
  129691. _detachCameras(cameras: Camera[]): void;
  129692. /**
  129693. * Enables the effect on given cameras
  129694. * @param cameras The camera to enable.
  129695. * @hidden
  129696. */
  129697. _enable(cameras: Camera): void;
  129698. /**
  129699. * Enables the effect on given cameras
  129700. * @param cameras The camera to enable.
  129701. * @hidden
  129702. */
  129703. _enable(cameras: Nullable<Camera[]>): void;
  129704. /**
  129705. * Disables the effect on the given cameras
  129706. * @param cameras The camera to disable.
  129707. * @hidden
  129708. */
  129709. _disable(cameras: Camera): void;
  129710. /**
  129711. * Disables the effect on the given cameras
  129712. * @param cameras The camera to disable.
  129713. * @hidden
  129714. */
  129715. _disable(cameras: Nullable<Camera[]>): void;
  129716. /**
  129717. * Gets a list of the post processes contained in the effect.
  129718. * @param camera The camera to get the post processes on.
  129719. * @returns The list of the post processes in the effect.
  129720. */
  129721. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  129722. }
  129723. }
  129724. declare module BABYLON {
  129725. /** @hidden */
  129726. export var extractHighlightsPixelShader: {
  129727. name: string;
  129728. shader: string;
  129729. };
  129730. }
  129731. declare module BABYLON {
  129732. /**
  129733. * 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.
  129734. */
  129735. export class ExtractHighlightsPostProcess extends PostProcess {
  129736. /**
  129737. * The luminance threshold, pixels below this value will be set to black.
  129738. */
  129739. threshold: number;
  129740. /** @hidden */
  129741. _exposure: number;
  129742. /**
  129743. * Post process which has the input texture to be used when performing highlight extraction
  129744. * @hidden
  129745. */
  129746. _inputPostProcess: Nullable<PostProcess>;
  129747. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129748. }
  129749. }
  129750. declare module BABYLON {
  129751. /** @hidden */
  129752. export var bloomMergePixelShader: {
  129753. name: string;
  129754. shader: string;
  129755. };
  129756. }
  129757. declare module BABYLON {
  129758. /**
  129759. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129760. */
  129761. export class BloomMergePostProcess extends PostProcess {
  129762. /** Weight of the bloom to be added to the original input. */
  129763. weight: number;
  129764. /**
  129765. * Creates a new instance of @see BloomMergePostProcess
  129766. * @param name The name of the effect.
  129767. * @param originalFromInput Post process which's input will be used for the merge.
  129768. * @param blurred Blurred highlights post process which's output will be used.
  129769. * @param weight Weight of the bloom to be added to the original input.
  129770. * @param options The required width/height ratio to downsize to before computing the render pass.
  129771. * @param camera The camera to apply the render pass to.
  129772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129773. * @param engine The engine which the post process will be applied. (default: current engine)
  129774. * @param reusable If the post process can be reused on the same frame. (default: false)
  129775. * @param textureType Type of textures used when performing the post process. (default: 0)
  129776. * @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)
  129777. */
  129778. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  129779. /** Weight of the bloom to be added to the original input. */
  129780. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129781. }
  129782. }
  129783. declare module BABYLON {
  129784. /**
  129785. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  129786. */
  129787. export class BloomEffect extends PostProcessRenderEffect {
  129788. private bloomScale;
  129789. /**
  129790. * @hidden Internal
  129791. */
  129792. _effects: Array<PostProcess>;
  129793. /**
  129794. * @hidden Internal
  129795. */
  129796. _downscale: ExtractHighlightsPostProcess;
  129797. private _blurX;
  129798. private _blurY;
  129799. private _merge;
  129800. /**
  129801. * The luminance threshold to find bright areas of the image to bloom.
  129802. */
  129803. threshold: number;
  129804. /**
  129805. * The strength of the bloom.
  129806. */
  129807. weight: number;
  129808. /**
  129809. * Specifies the size of the bloom blur kernel, relative to the final output size
  129810. */
  129811. kernel: number;
  129812. /**
  129813. * Creates a new instance of @see BloomEffect
  129814. * @param scene The scene the effect belongs to.
  129815. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  129816. * @param bloomKernel The size of the kernel to be used when applying the blur.
  129817. * @param bloomWeight The the strength of bloom.
  129818. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129819. * @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)
  129820. */
  129821. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  129822. /**
  129823. * Disposes each of the internal effects for a given camera.
  129824. * @param camera The camera to dispose the effect on.
  129825. */
  129826. disposeEffects(camera: Camera): void;
  129827. /**
  129828. * @hidden Internal
  129829. */
  129830. _updateEffects(): void;
  129831. /**
  129832. * Internal
  129833. * @returns if all the contained post processes are ready.
  129834. * @hidden
  129835. */
  129836. _isReady(): boolean;
  129837. }
  129838. }
  129839. declare module BABYLON {
  129840. /** @hidden */
  129841. export var chromaticAberrationPixelShader: {
  129842. name: string;
  129843. shader: string;
  129844. };
  129845. }
  129846. declare module BABYLON {
  129847. /**
  129848. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  129849. */
  129850. export class ChromaticAberrationPostProcess extends PostProcess {
  129851. /**
  129852. * The amount of seperation of rgb channels (default: 30)
  129853. */
  129854. aberrationAmount: number;
  129855. /**
  129856. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  129857. */
  129858. radialIntensity: number;
  129859. /**
  129860. * 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))
  129861. */
  129862. direction: Vector2;
  129863. /**
  129864. * 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))
  129865. */
  129866. centerPosition: Vector2;
  129867. /**
  129868. * Creates a new instance ChromaticAberrationPostProcess
  129869. * @param name The name of the effect.
  129870. * @param screenWidth The width of the screen to apply the effect on.
  129871. * @param screenHeight The height of the screen to apply the effect on.
  129872. * @param options The required width/height ratio to downsize to before computing the render pass.
  129873. * @param camera The camera to apply the render pass to.
  129874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129875. * @param engine The engine which the post process will be applied. (default: current engine)
  129876. * @param reusable If the post process can be reused on the same frame. (default: false)
  129877. * @param textureType Type of textures used when performing the post process. (default: 0)
  129878. * @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)
  129879. */
  129880. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129881. }
  129882. }
  129883. declare module BABYLON {
  129884. /** @hidden */
  129885. export var circleOfConfusionPixelShader: {
  129886. name: string;
  129887. shader: string;
  129888. };
  129889. }
  129890. declare module BABYLON {
  129891. /**
  129892. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  129893. */
  129894. export class CircleOfConfusionPostProcess extends PostProcess {
  129895. /**
  129896. * 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.
  129897. */
  129898. lensSize: number;
  129899. /**
  129900. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129901. */
  129902. fStop: number;
  129903. /**
  129904. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129905. */
  129906. focusDistance: number;
  129907. /**
  129908. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  129909. */
  129910. focalLength: number;
  129911. private _depthTexture;
  129912. /**
  129913. * Creates a new instance CircleOfConfusionPostProcess
  129914. * @param name The name of the effect.
  129915. * @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.
  129916. * @param options The required width/height ratio to downsize to before computing the render pass.
  129917. * @param camera The camera to apply the render pass to.
  129918. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129919. * @param engine The engine which the post process will be applied. (default: current engine)
  129920. * @param reusable If the post process can be reused on the same frame. (default: false)
  129921. * @param textureType Type of textures used when performing the post process. (default: 0)
  129922. * @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)
  129923. */
  129924. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129925. /**
  129926. * 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.
  129927. */
  129928. depthTexture: RenderTargetTexture;
  129929. }
  129930. }
  129931. declare module BABYLON {
  129932. /** @hidden */
  129933. export var colorCorrectionPixelShader: {
  129934. name: string;
  129935. shader: string;
  129936. };
  129937. }
  129938. declare module BABYLON {
  129939. /**
  129940. *
  129941. * This post-process allows the modification of rendered colors by using
  129942. * a 'look-up table' (LUT). This effect is also called Color Grading.
  129943. *
  129944. * The object needs to be provided an url to a texture containing the color
  129945. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  129946. * Use an image editing software to tweak the LUT to match your needs.
  129947. *
  129948. * For an example of a color LUT, see here:
  129949. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  129950. * For explanations on color grading, see here:
  129951. * @see http://udn.epicgames.com/Three/ColorGrading.html
  129952. *
  129953. */
  129954. export class ColorCorrectionPostProcess extends PostProcess {
  129955. private _colorTableTexture;
  129956. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129957. }
  129958. }
  129959. declare module BABYLON {
  129960. /** @hidden */
  129961. export var convolutionPixelShader: {
  129962. name: string;
  129963. shader: string;
  129964. };
  129965. }
  129966. declare module BABYLON {
  129967. /**
  129968. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  129969. * input texture to perform effects such as edge detection or sharpening
  129970. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129971. */
  129972. export class ConvolutionPostProcess extends PostProcess {
  129973. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129974. kernel: number[];
  129975. /**
  129976. * Creates a new instance ConvolutionPostProcess
  129977. * @param name The name of the effect.
  129978. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  129979. * @param options The required width/height ratio to downsize to before computing the render pass.
  129980. * @param camera The camera to apply the render pass to.
  129981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129982. * @param engine The engine which the post process will be applied. (default: current engine)
  129983. * @param reusable If the post process can be reused on the same frame. (default: false)
  129984. * @param textureType Type of textures used when performing the post process. (default: 0)
  129985. */
  129986. constructor(name: string,
  129987. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  129988. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129989. /**
  129990. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129991. */
  129992. static EdgeDetect0Kernel: number[];
  129993. /**
  129994. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129995. */
  129996. static EdgeDetect1Kernel: number[];
  129997. /**
  129998. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129999. */
  130000. static EdgeDetect2Kernel: number[];
  130001. /**
  130002. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130003. */
  130004. static SharpenKernel: number[];
  130005. /**
  130006. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130007. */
  130008. static EmbossKernel: number[];
  130009. /**
  130010. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130011. */
  130012. static GaussianKernel: number[];
  130013. }
  130014. }
  130015. declare module BABYLON {
  130016. /**
  130017. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130018. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130019. * based on samples that have a large difference in distance than the center pixel.
  130020. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130021. */
  130022. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130023. direction: Vector2;
  130024. /**
  130025. * Creates a new instance CircleOfConfusionPostProcess
  130026. * @param name The name of the effect.
  130027. * @param scene The scene the effect belongs to.
  130028. * @param direction The direction the blur should be applied.
  130029. * @param kernel The size of the kernel used to blur.
  130030. * @param options The required width/height ratio to downsize to before computing the render pass.
  130031. * @param camera The camera to apply the render pass to.
  130032. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130033. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130035. * @param engine The engine which the post process will be applied. (default: current engine)
  130036. * @param reusable If the post process can be reused on the same frame. (default: false)
  130037. * @param textureType Type of textures used when performing the post process. (default: 0)
  130038. * @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)
  130039. */
  130040. 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);
  130041. }
  130042. }
  130043. declare module BABYLON {
  130044. /** @hidden */
  130045. export var depthOfFieldMergePixelShader: {
  130046. name: string;
  130047. shader: string;
  130048. };
  130049. }
  130050. declare module BABYLON {
  130051. /**
  130052. * Options to be set when merging outputs from the default pipeline.
  130053. */
  130054. export class DepthOfFieldMergePostProcessOptions {
  130055. /**
  130056. * The original image to merge on top of
  130057. */
  130058. originalFromInput: PostProcess;
  130059. /**
  130060. * Parameters to perform the merge of the depth of field effect
  130061. */
  130062. depthOfField?: {
  130063. circleOfConfusion: PostProcess;
  130064. blurSteps: Array<PostProcess>;
  130065. };
  130066. /**
  130067. * Parameters to perform the merge of bloom effect
  130068. */
  130069. bloom?: {
  130070. blurred: PostProcess;
  130071. weight: number;
  130072. };
  130073. }
  130074. /**
  130075. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130076. */
  130077. export class DepthOfFieldMergePostProcess extends PostProcess {
  130078. private blurSteps;
  130079. /**
  130080. * Creates a new instance of DepthOfFieldMergePostProcess
  130081. * @param name The name of the effect.
  130082. * @param originalFromInput Post process which's input will be used for the merge.
  130083. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130084. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130085. * @param options The required width/height ratio to downsize to before computing the render pass.
  130086. * @param camera The camera to apply the render pass to.
  130087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130088. * @param engine The engine which the post process will be applied. (default: current engine)
  130089. * @param reusable If the post process can be reused on the same frame. (default: false)
  130090. * @param textureType Type of textures used when performing the post process. (default: 0)
  130091. * @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)
  130092. */
  130093. 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);
  130094. /**
  130095. * Updates the effect with the current post process compile time values and recompiles the shader.
  130096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130099. * @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
  130100. * @param onCompiled Called when the shader has been compiled.
  130101. * @param onError Called if there is an error when compiling a shader.
  130102. */
  130103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130104. }
  130105. }
  130106. declare module BABYLON {
  130107. /**
  130108. * Specifies the level of max blur that should be applied when using the depth of field effect
  130109. */
  130110. export enum DepthOfFieldEffectBlurLevel {
  130111. /**
  130112. * Subtle blur
  130113. */
  130114. Low = 0,
  130115. /**
  130116. * Medium blur
  130117. */
  130118. Medium = 1,
  130119. /**
  130120. * Large blur
  130121. */
  130122. High = 2
  130123. }
  130124. /**
  130125. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130126. */
  130127. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130128. private _circleOfConfusion;
  130129. /**
  130130. * @hidden Internal, blurs from high to low
  130131. */
  130132. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130133. private _depthOfFieldBlurY;
  130134. private _dofMerge;
  130135. /**
  130136. * @hidden Internal post processes in depth of field effect
  130137. */
  130138. _effects: Array<PostProcess>;
  130139. /**
  130140. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130141. */
  130142. focalLength: number;
  130143. /**
  130144. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130145. */
  130146. fStop: number;
  130147. /**
  130148. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130149. */
  130150. focusDistance: number;
  130151. /**
  130152. * 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.
  130153. */
  130154. lensSize: number;
  130155. /**
  130156. * Creates a new instance DepthOfFieldEffect
  130157. * @param scene The scene the effect belongs to.
  130158. * @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.
  130159. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130160. * @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)
  130161. */
  130162. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130163. /**
  130164. * Get the current class name of the current effet
  130165. * @returns "DepthOfFieldEffect"
  130166. */
  130167. getClassName(): string;
  130168. /**
  130169. * 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.
  130170. */
  130171. depthTexture: RenderTargetTexture;
  130172. /**
  130173. * Disposes each of the internal effects for a given camera.
  130174. * @param camera The camera to dispose the effect on.
  130175. */
  130176. disposeEffects(camera: Camera): void;
  130177. /**
  130178. * @hidden Internal
  130179. */
  130180. _updateEffects(): void;
  130181. /**
  130182. * Internal
  130183. * @returns if all the contained post processes are ready.
  130184. * @hidden
  130185. */
  130186. _isReady(): boolean;
  130187. }
  130188. }
  130189. declare module BABYLON {
  130190. /** @hidden */
  130191. export var displayPassPixelShader: {
  130192. name: string;
  130193. shader: string;
  130194. };
  130195. }
  130196. declare module BABYLON {
  130197. /**
  130198. * DisplayPassPostProcess which produces an output the same as it's input
  130199. */
  130200. export class DisplayPassPostProcess extends PostProcess {
  130201. /**
  130202. * Creates the DisplayPassPostProcess
  130203. * @param name The name of the effect.
  130204. * @param options The required width/height ratio to downsize to before computing the render pass.
  130205. * @param camera The camera to apply the render pass to.
  130206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130207. * @param engine The engine which the post process will be applied. (default: current engine)
  130208. * @param reusable If the post process can be reused on the same frame. (default: false)
  130209. */
  130210. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130211. }
  130212. }
  130213. declare module BABYLON {
  130214. /** @hidden */
  130215. export var filterPixelShader: {
  130216. name: string;
  130217. shader: string;
  130218. };
  130219. }
  130220. declare module BABYLON {
  130221. /**
  130222. * Applies a kernel filter to the image
  130223. */
  130224. export class FilterPostProcess extends PostProcess {
  130225. /** The matrix to be applied to the image */
  130226. kernelMatrix: Matrix;
  130227. /**
  130228. *
  130229. * @param name The name of the effect.
  130230. * @param kernelMatrix The matrix to be applied to the image
  130231. * @param options The required width/height ratio to downsize to before computing the render pass.
  130232. * @param camera The camera to apply the render pass to.
  130233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130234. * @param engine The engine which the post process will be applied. (default: current engine)
  130235. * @param reusable If the post process can be reused on the same frame. (default: false)
  130236. */
  130237. constructor(name: string,
  130238. /** The matrix to be applied to the image */
  130239. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130240. }
  130241. }
  130242. declare module BABYLON {
  130243. /** @hidden */
  130244. export var fxaaPixelShader: {
  130245. name: string;
  130246. shader: string;
  130247. };
  130248. }
  130249. declare module BABYLON {
  130250. /** @hidden */
  130251. export var fxaaVertexShader: {
  130252. name: string;
  130253. shader: string;
  130254. };
  130255. }
  130256. declare module BABYLON {
  130257. /**
  130258. * Fxaa post process
  130259. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130260. */
  130261. export class FxaaPostProcess extends PostProcess {
  130262. /** @hidden */
  130263. texelWidth: number;
  130264. /** @hidden */
  130265. texelHeight: number;
  130266. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130267. private _getDefines;
  130268. }
  130269. }
  130270. declare module BABYLON {
  130271. /** @hidden */
  130272. export var grainPixelShader: {
  130273. name: string;
  130274. shader: string;
  130275. };
  130276. }
  130277. declare module BABYLON {
  130278. /**
  130279. * The GrainPostProcess adds noise to the image at mid luminance levels
  130280. */
  130281. export class GrainPostProcess extends PostProcess {
  130282. /**
  130283. * The intensity of the grain added (default: 30)
  130284. */
  130285. intensity: number;
  130286. /**
  130287. * If the grain should be randomized on every frame
  130288. */
  130289. animated: boolean;
  130290. /**
  130291. * Creates a new instance of @see GrainPostProcess
  130292. * @param name The name of the effect.
  130293. * @param options The required width/height ratio to downsize to before computing the render pass.
  130294. * @param camera The camera to apply the render pass to.
  130295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130296. * @param engine The engine which the post process will be applied. (default: current engine)
  130297. * @param reusable If the post process can be reused on the same frame. (default: false)
  130298. * @param textureType Type of textures used when performing the post process. (default: 0)
  130299. * @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)
  130300. */
  130301. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130302. }
  130303. }
  130304. declare module BABYLON {
  130305. /** @hidden */
  130306. export var highlightsPixelShader: {
  130307. name: string;
  130308. shader: string;
  130309. };
  130310. }
  130311. declare module BABYLON {
  130312. /**
  130313. * Extracts highlights from the image
  130314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130315. */
  130316. export class HighlightsPostProcess extends PostProcess {
  130317. /**
  130318. * Extracts highlights from the image
  130319. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130320. * @param name The name of the effect.
  130321. * @param options The required width/height ratio to downsize to before computing the render pass.
  130322. * @param camera The camera to apply the render pass to.
  130323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130324. * @param engine The engine which the post process will be applied. (default: current engine)
  130325. * @param reusable If the post process can be reused on the same frame. (default: false)
  130326. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130327. */
  130328. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130329. }
  130330. }
  130331. declare module BABYLON {
  130332. /** @hidden */
  130333. export var mrtFragmentDeclaration: {
  130334. name: string;
  130335. shader: string;
  130336. };
  130337. }
  130338. declare module BABYLON {
  130339. /** @hidden */
  130340. export var geometryPixelShader: {
  130341. name: string;
  130342. shader: string;
  130343. };
  130344. }
  130345. declare module BABYLON {
  130346. /** @hidden */
  130347. export var geometryVertexShader: {
  130348. name: string;
  130349. shader: string;
  130350. };
  130351. }
  130352. declare module BABYLON {
  130353. /** @hidden */
  130354. interface ISavedTransformationMatrix {
  130355. world: Matrix;
  130356. viewProjection: Matrix;
  130357. }
  130358. /**
  130359. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  130360. */
  130361. export class GeometryBufferRenderer {
  130362. /**
  130363. * Constant used to retrieve the position texture index in the G-Buffer textures array
  130364. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  130365. */
  130366. static readonly POSITION_TEXTURE_TYPE: number;
  130367. /**
  130368. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  130369. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  130370. */
  130371. static readonly VELOCITY_TEXTURE_TYPE: number;
  130372. /**
  130373. * Dictionary used to store the previous transformation matrices of each rendered mesh
  130374. * in order to compute objects velocities when enableVelocity is set to "true"
  130375. * @hidden
  130376. */
  130377. _previousTransformationMatrices: {
  130378. [index: number]: ISavedTransformationMatrix;
  130379. };
  130380. /**
  130381. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  130382. * in order to compute objects velocities when enableVelocity is set to "true"
  130383. * @hidden
  130384. */
  130385. _previousBonesTransformationMatrices: {
  130386. [index: number]: Float32Array;
  130387. };
  130388. /**
  130389. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  130390. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  130391. */
  130392. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  130393. private _scene;
  130394. private _multiRenderTarget;
  130395. private _ratio;
  130396. private _enablePosition;
  130397. private _enableVelocity;
  130398. private _positionIndex;
  130399. private _velocityIndex;
  130400. protected _effect: Effect;
  130401. protected _cachedDefines: string;
  130402. /**
  130403. * Set the render list (meshes to be rendered) used in the G buffer.
  130404. */
  130405. renderList: Mesh[];
  130406. /**
  130407. * Gets wether or not G buffer are supported by the running hardware.
  130408. * This requires draw buffer supports
  130409. */
  130410. readonly isSupported: boolean;
  130411. /**
  130412. * Returns the index of the given texture type in the G-Buffer textures array
  130413. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  130414. * @returns the index of the given texture type in the G-Buffer textures array
  130415. */
  130416. getTextureIndex(textureType: number): number;
  130417. /**
  130418. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  130419. */
  130420. /**
  130421. * Sets whether or not objects positions are enabled for the G buffer.
  130422. */
  130423. enablePosition: boolean;
  130424. /**
  130425. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  130426. */
  130427. /**
  130428. * Sets wether or not objects velocities are enabled for the G buffer.
  130429. */
  130430. enableVelocity: boolean;
  130431. /**
  130432. * Gets the scene associated with the buffer.
  130433. */
  130434. readonly scene: Scene;
  130435. /**
  130436. * Gets the ratio used by the buffer during its creation.
  130437. * How big is the buffer related to the main canvas.
  130438. */
  130439. readonly ratio: number;
  130440. /** @hidden */
  130441. static _SceneComponentInitialization: (scene: Scene) => void;
  130442. /**
  130443. * Creates a new G Buffer for the scene
  130444. * @param scene The scene the buffer belongs to
  130445. * @param ratio How big is the buffer related to the main canvas.
  130446. */
  130447. constructor(scene: Scene, ratio?: number);
  130448. /**
  130449. * Checks wether everything is ready to render a submesh to the G buffer.
  130450. * @param subMesh the submesh to check readiness for
  130451. * @param useInstances is the mesh drawn using instance or not
  130452. * @returns true if ready otherwise false
  130453. */
  130454. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  130455. /**
  130456. * Gets the current underlying G Buffer.
  130457. * @returns the buffer
  130458. */
  130459. getGBuffer(): MultiRenderTarget;
  130460. /**
  130461. * Gets the number of samples used to render the buffer (anti aliasing).
  130462. */
  130463. /**
  130464. * Sets the number of samples used to render the buffer (anti aliasing).
  130465. */
  130466. samples: number;
  130467. /**
  130468. * Disposes the renderer and frees up associated resources.
  130469. */
  130470. dispose(): void;
  130471. protected _createRenderTargets(): void;
  130472. private _copyBonesTransformationMatrices;
  130473. }
  130474. }
  130475. declare module BABYLON {
  130476. interface Scene {
  130477. /** @hidden (Backing field) */
  130478. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130479. /**
  130480. * Gets or Sets the current geometry buffer associated to the scene.
  130481. */
  130482. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  130483. /**
  130484. * Enables a GeometryBufferRender and associates it with the scene
  130485. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  130486. * @returns the GeometryBufferRenderer
  130487. */
  130488. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  130489. /**
  130490. * Disables the GeometryBufferRender associated with the scene
  130491. */
  130492. disableGeometryBufferRenderer(): void;
  130493. }
  130494. /**
  130495. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  130496. * in several rendering techniques.
  130497. */
  130498. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  130499. /**
  130500. * The component name helpful to identify the component in the list of scene components.
  130501. */
  130502. readonly name: string;
  130503. /**
  130504. * The scene the component belongs to.
  130505. */
  130506. scene: Scene;
  130507. /**
  130508. * Creates a new instance of the component for the given scene
  130509. * @param scene Defines the scene to register the component in
  130510. */
  130511. constructor(scene: Scene);
  130512. /**
  130513. * Registers the component in a given scene
  130514. */
  130515. register(): void;
  130516. /**
  130517. * Rebuilds the elements related to this component in case of
  130518. * context lost for instance.
  130519. */
  130520. rebuild(): void;
  130521. /**
  130522. * Disposes the component and the associated ressources
  130523. */
  130524. dispose(): void;
  130525. private _gatherRenderTargets;
  130526. }
  130527. }
  130528. declare module BABYLON {
  130529. /** @hidden */
  130530. export var motionBlurPixelShader: {
  130531. name: string;
  130532. shader: string;
  130533. };
  130534. }
  130535. declare module BABYLON {
  130536. /**
  130537. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  130538. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  130539. * As an example, all you have to do is to create the post-process:
  130540. * var mb = new BABYLON.MotionBlurPostProcess(
  130541. * 'mb', // The name of the effect.
  130542. * scene, // The scene containing the objects to blur according to their velocity.
  130543. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  130544. * camera // The camera to apply the render pass to.
  130545. * );
  130546. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  130547. */
  130548. export class MotionBlurPostProcess extends PostProcess {
  130549. /**
  130550. * Defines how much the image is blurred by the movement. Default value is equal to 1
  130551. */
  130552. motionStrength: number;
  130553. /**
  130554. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  130555. */
  130556. /**
  130557. * Sets the number of iterations to be used for motion blur quality
  130558. */
  130559. motionBlurSamples: number;
  130560. private _motionBlurSamples;
  130561. private _geometryBufferRenderer;
  130562. /**
  130563. * Creates a new instance MotionBlurPostProcess
  130564. * @param name The name of the effect.
  130565. * @param scene The scene containing the objects to blur according to their velocity.
  130566. * @param options The required width/height ratio to downsize to before computing the render pass.
  130567. * @param camera The camera to apply the render pass to.
  130568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130569. * @param engine The engine which the post process will be applied. (default: current engine)
  130570. * @param reusable If the post process can be reused on the same frame. (default: false)
  130571. * @param textureType Type of textures used when performing the post process. (default: 0)
  130572. * @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)
  130573. */
  130574. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130575. /**
  130576. * Excludes the given skinned mesh from computing bones velocities.
  130577. * 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.
  130578. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  130579. */
  130580. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130581. /**
  130582. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  130583. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  130584. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  130585. */
  130586. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  130587. /**
  130588. * Disposes the post process.
  130589. * @param camera The camera to dispose the post process on.
  130590. */
  130591. dispose(camera?: Camera): void;
  130592. }
  130593. }
  130594. declare module BABYLON {
  130595. /** @hidden */
  130596. export var refractionPixelShader: {
  130597. name: string;
  130598. shader: string;
  130599. };
  130600. }
  130601. declare module BABYLON {
  130602. /**
  130603. * Post process which applies a refractin texture
  130604. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130605. */
  130606. export class RefractionPostProcess extends PostProcess {
  130607. /** the base color of the refraction (used to taint the rendering) */
  130608. color: Color3;
  130609. /** simulated refraction depth */
  130610. depth: number;
  130611. /** the coefficient of the base color (0 to remove base color tainting) */
  130612. colorLevel: number;
  130613. private _refTexture;
  130614. private _ownRefractionTexture;
  130615. /**
  130616. * Gets or sets the refraction texture
  130617. * Please note that you are responsible for disposing the texture if you set it manually
  130618. */
  130619. refractionTexture: Texture;
  130620. /**
  130621. * Initializes the RefractionPostProcess
  130622. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  130623. * @param name The name of the effect.
  130624. * @param refractionTextureUrl Url of the refraction texture to use
  130625. * @param color the base color of the refraction (used to taint the rendering)
  130626. * @param depth simulated refraction depth
  130627. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  130628. * @param camera The camera to apply the render pass to.
  130629. * @param options The required width/height ratio to downsize to before computing the render pass.
  130630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130631. * @param engine The engine which the post process will be applied. (default: current engine)
  130632. * @param reusable If the post process can be reused on the same frame. (default: false)
  130633. */
  130634. constructor(name: string, refractionTextureUrl: string,
  130635. /** the base color of the refraction (used to taint the rendering) */
  130636. color: Color3,
  130637. /** simulated refraction depth */
  130638. depth: number,
  130639. /** the coefficient of the base color (0 to remove base color tainting) */
  130640. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130641. /**
  130642. * Disposes of the post process
  130643. * @param camera Camera to dispose post process on
  130644. */
  130645. dispose(camera: Camera): void;
  130646. }
  130647. }
  130648. declare module BABYLON {
  130649. /** @hidden */
  130650. export var sharpenPixelShader: {
  130651. name: string;
  130652. shader: string;
  130653. };
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * The SharpenPostProcess applies a sharpen kernel to every pixel
  130658. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130659. */
  130660. export class SharpenPostProcess extends PostProcess {
  130661. /**
  130662. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  130663. */
  130664. colorAmount: number;
  130665. /**
  130666. * How much sharpness should be applied (default: 0.3)
  130667. */
  130668. edgeAmount: number;
  130669. /**
  130670. * Creates a new instance ConvolutionPostProcess
  130671. * @param name The name of the effect.
  130672. * @param options The required width/height ratio to downsize to before computing the render pass.
  130673. * @param camera The camera to apply the render pass to.
  130674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130675. * @param engine The engine which the post process will be applied. (default: current engine)
  130676. * @param reusable If the post process can be reused on the same frame. (default: false)
  130677. * @param textureType Type of textures used when performing the post process. (default: 0)
  130678. * @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)
  130679. */
  130680. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130681. }
  130682. }
  130683. declare module BABYLON {
  130684. /**
  130685. * PostProcessRenderPipeline
  130686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130687. */
  130688. export class PostProcessRenderPipeline {
  130689. private engine;
  130690. private _renderEffects;
  130691. private _renderEffectsForIsolatedPass;
  130692. /**
  130693. * List of inspectable custom properties (used by the Inspector)
  130694. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  130695. */
  130696. inspectableCustomProperties: IInspectable[];
  130697. /**
  130698. * @hidden
  130699. */
  130700. protected _cameras: Camera[];
  130701. /** @hidden */
  130702. _name: string;
  130703. /**
  130704. * Gets pipeline name
  130705. */
  130706. readonly name: string;
  130707. /** Gets the list of attached cameras */
  130708. readonly cameras: Camera[];
  130709. /**
  130710. * Initializes a PostProcessRenderPipeline
  130711. * @param engine engine to add the pipeline to
  130712. * @param name name of the pipeline
  130713. */
  130714. constructor(engine: Engine, name: string);
  130715. /**
  130716. * Gets the class name
  130717. * @returns "PostProcessRenderPipeline"
  130718. */
  130719. getClassName(): string;
  130720. /**
  130721. * If all the render effects in the pipeline are supported
  130722. */
  130723. readonly isSupported: boolean;
  130724. /**
  130725. * Adds an effect to the pipeline
  130726. * @param renderEffect the effect to add
  130727. */
  130728. addEffect(renderEffect: PostProcessRenderEffect): void;
  130729. /** @hidden */
  130730. _rebuild(): void;
  130731. /** @hidden */
  130732. _enableEffect(renderEffectName: string, cameras: Camera): void;
  130733. /** @hidden */
  130734. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  130735. /** @hidden */
  130736. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130737. /** @hidden */
  130738. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  130739. /** @hidden */
  130740. _attachCameras(cameras: Camera, unique: boolean): void;
  130741. /** @hidden */
  130742. _attachCameras(cameras: Camera[], unique: boolean): void;
  130743. /** @hidden */
  130744. _detachCameras(cameras: Camera): void;
  130745. /** @hidden */
  130746. _detachCameras(cameras: Nullable<Camera[]>): void;
  130747. /** @hidden */
  130748. _update(): void;
  130749. /** @hidden */
  130750. _reset(): void;
  130751. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  130752. /**
  130753. * Disposes of the pipeline
  130754. */
  130755. dispose(): void;
  130756. }
  130757. }
  130758. declare module BABYLON {
  130759. /**
  130760. * PostProcessRenderPipelineManager class
  130761. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130762. */
  130763. export class PostProcessRenderPipelineManager {
  130764. private _renderPipelines;
  130765. /**
  130766. * Initializes a PostProcessRenderPipelineManager
  130767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130768. */
  130769. constructor();
  130770. /**
  130771. * Gets the list of supported render pipelines
  130772. */
  130773. readonly supportedPipelines: PostProcessRenderPipeline[];
  130774. /**
  130775. * Adds a pipeline to the manager
  130776. * @param renderPipeline The pipeline to add
  130777. */
  130778. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  130779. /**
  130780. * Attaches a camera to the pipeline
  130781. * @param renderPipelineName The name of the pipeline to attach to
  130782. * @param cameras the camera to attach
  130783. * @param unique if the camera can be attached multiple times to the pipeline
  130784. */
  130785. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  130786. /**
  130787. * Detaches a camera from the pipeline
  130788. * @param renderPipelineName The name of the pipeline to detach from
  130789. * @param cameras the camera to detach
  130790. */
  130791. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  130792. /**
  130793. * Enables an effect by name on a pipeline
  130794. * @param renderPipelineName the name of the pipeline to enable the effect in
  130795. * @param renderEffectName the name of the effect to enable
  130796. * @param cameras the cameras that the effect should be enabled on
  130797. */
  130798. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130799. /**
  130800. * Disables an effect by name on a pipeline
  130801. * @param renderPipelineName the name of the pipeline to disable the effect in
  130802. * @param renderEffectName the name of the effect to disable
  130803. * @param cameras the cameras that the effect should be disabled on
  130804. */
  130805. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  130806. /**
  130807. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  130808. */
  130809. update(): void;
  130810. /** @hidden */
  130811. _rebuild(): void;
  130812. /**
  130813. * Disposes of the manager and pipelines
  130814. */
  130815. dispose(): void;
  130816. }
  130817. }
  130818. declare module BABYLON {
  130819. interface Scene {
  130820. /** @hidden (Backing field) */
  130821. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130822. /**
  130823. * Gets the postprocess render pipeline manager
  130824. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130825. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130826. */
  130827. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  130828. }
  130829. /**
  130830. * Defines the Render Pipeline scene component responsible to rendering pipelines
  130831. */
  130832. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  130833. /**
  130834. * The component name helpfull to identify the component in the list of scene components.
  130835. */
  130836. readonly name: string;
  130837. /**
  130838. * The scene the component belongs to.
  130839. */
  130840. scene: Scene;
  130841. /**
  130842. * Creates a new instance of the component for the given scene
  130843. * @param scene Defines the scene to register the component in
  130844. */
  130845. constructor(scene: Scene);
  130846. /**
  130847. * Registers the component in a given scene
  130848. */
  130849. register(): void;
  130850. /**
  130851. * Rebuilds the elements related to this component in case of
  130852. * context lost for instance.
  130853. */
  130854. rebuild(): void;
  130855. /**
  130856. * Disposes the component and the associated ressources
  130857. */
  130858. dispose(): void;
  130859. private _gatherRenderTargets;
  130860. }
  130861. }
  130862. declare module BABYLON {
  130863. /**
  130864. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  130865. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  130866. */
  130867. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130868. private _scene;
  130869. private _camerasToBeAttached;
  130870. /**
  130871. * ID of the sharpen post process,
  130872. */
  130873. private readonly SharpenPostProcessId;
  130874. /**
  130875. * @ignore
  130876. * ID of the image processing post process;
  130877. */
  130878. readonly ImageProcessingPostProcessId: string;
  130879. /**
  130880. * @ignore
  130881. * ID of the Fast Approximate Anti-Aliasing post process;
  130882. */
  130883. readonly FxaaPostProcessId: string;
  130884. /**
  130885. * ID of the chromatic aberration post process,
  130886. */
  130887. private readonly ChromaticAberrationPostProcessId;
  130888. /**
  130889. * ID of the grain post process
  130890. */
  130891. private readonly GrainPostProcessId;
  130892. /**
  130893. * Sharpen post process which will apply a sharpen convolution to enhance edges
  130894. */
  130895. sharpen: SharpenPostProcess;
  130896. private _sharpenEffect;
  130897. private bloom;
  130898. /**
  130899. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  130900. */
  130901. depthOfField: DepthOfFieldEffect;
  130902. /**
  130903. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130904. */
  130905. fxaa: FxaaPostProcess;
  130906. /**
  130907. * Image post processing pass used to perform operations such as tone mapping or color grading.
  130908. */
  130909. imageProcessing: ImageProcessingPostProcess;
  130910. /**
  130911. * Chromatic aberration post process which will shift rgb colors in the image
  130912. */
  130913. chromaticAberration: ChromaticAberrationPostProcess;
  130914. private _chromaticAberrationEffect;
  130915. /**
  130916. * Grain post process which add noise to the image
  130917. */
  130918. grain: GrainPostProcess;
  130919. private _grainEffect;
  130920. /**
  130921. * Glow post process which adds a glow to emissive areas of the image
  130922. */
  130923. private _glowLayer;
  130924. /**
  130925. * Animations which can be used to tweak settings over a period of time
  130926. */
  130927. animations: Animation[];
  130928. private _imageProcessingConfigurationObserver;
  130929. private _sharpenEnabled;
  130930. private _bloomEnabled;
  130931. private _depthOfFieldEnabled;
  130932. private _depthOfFieldBlurLevel;
  130933. private _fxaaEnabled;
  130934. private _imageProcessingEnabled;
  130935. private _defaultPipelineTextureType;
  130936. private _bloomScale;
  130937. private _chromaticAberrationEnabled;
  130938. private _grainEnabled;
  130939. private _buildAllowed;
  130940. /**
  130941. * Gets active scene
  130942. */
  130943. readonly scene: Scene;
  130944. /**
  130945. * Enable or disable the sharpen process from the pipeline
  130946. */
  130947. sharpenEnabled: boolean;
  130948. private _resizeObserver;
  130949. private _hardwareScaleLevel;
  130950. private _bloomKernel;
  130951. /**
  130952. * Specifies the size of the bloom blur kernel, relative to the final output size
  130953. */
  130954. bloomKernel: number;
  130955. /**
  130956. * Specifies the weight of the bloom in the final rendering
  130957. */
  130958. private _bloomWeight;
  130959. /**
  130960. * Specifies the luma threshold for the area that will be blurred by the bloom
  130961. */
  130962. private _bloomThreshold;
  130963. private _hdr;
  130964. /**
  130965. * The strength of the bloom.
  130966. */
  130967. bloomWeight: number;
  130968. /**
  130969. * The strength of the bloom.
  130970. */
  130971. bloomThreshold: number;
  130972. /**
  130973. * The scale of the bloom, lower value will provide better performance.
  130974. */
  130975. bloomScale: number;
  130976. /**
  130977. * Enable or disable the bloom from the pipeline
  130978. */
  130979. bloomEnabled: boolean;
  130980. private _rebuildBloom;
  130981. /**
  130982. * If the depth of field is enabled.
  130983. */
  130984. depthOfFieldEnabled: boolean;
  130985. /**
  130986. * Blur level of the depth of field effect. (Higher blur will effect performance)
  130987. */
  130988. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  130989. /**
  130990. * If the anti aliasing is enabled.
  130991. */
  130992. fxaaEnabled: boolean;
  130993. private _samples;
  130994. /**
  130995. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130996. */
  130997. samples: number;
  130998. /**
  130999. * If image processing is enabled.
  131000. */
  131001. imageProcessingEnabled: boolean;
  131002. /**
  131003. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131004. */
  131005. glowLayerEnabled: boolean;
  131006. /**
  131007. * Gets the glow layer (or null if not defined)
  131008. */
  131009. readonly glowLayer: Nullable<GlowLayer>;
  131010. /**
  131011. * Enable or disable the chromaticAberration process from the pipeline
  131012. */
  131013. chromaticAberrationEnabled: boolean;
  131014. /**
  131015. * Enable or disable the grain process from the pipeline
  131016. */
  131017. grainEnabled: boolean;
  131018. /**
  131019. * @constructor
  131020. * @param name - The rendering pipeline name (default: "")
  131021. * @param hdr - If high dynamic range textures should be used (default: true)
  131022. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131023. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131024. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131025. */
  131026. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131027. /**
  131028. * Get the class name
  131029. * @returns "DefaultRenderingPipeline"
  131030. */
  131031. getClassName(): string;
  131032. /**
  131033. * Force the compilation of the entire pipeline.
  131034. */
  131035. prepare(): void;
  131036. private _hasCleared;
  131037. private _prevPostProcess;
  131038. private _prevPrevPostProcess;
  131039. private _setAutoClearAndTextureSharing;
  131040. private _depthOfFieldSceneObserver;
  131041. private _buildPipeline;
  131042. private _disposePostProcesses;
  131043. /**
  131044. * Adds a camera to the pipeline
  131045. * @param camera the camera to be added
  131046. */
  131047. addCamera(camera: Camera): void;
  131048. /**
  131049. * Removes a camera from the pipeline
  131050. * @param camera the camera to remove
  131051. */
  131052. removeCamera(camera: Camera): void;
  131053. /**
  131054. * Dispose of the pipeline and stop all post processes
  131055. */
  131056. dispose(): void;
  131057. /**
  131058. * Serialize the rendering pipeline (Used when exporting)
  131059. * @returns the serialized object
  131060. */
  131061. serialize(): any;
  131062. /**
  131063. * Parse the serialized pipeline
  131064. * @param source Source pipeline.
  131065. * @param scene The scene to load the pipeline to.
  131066. * @param rootUrl The URL of the serialized pipeline.
  131067. * @returns An instantiated pipeline from the serialized object.
  131068. */
  131069. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131070. }
  131071. }
  131072. declare module BABYLON {
  131073. /** @hidden */
  131074. export var lensHighlightsPixelShader: {
  131075. name: string;
  131076. shader: string;
  131077. };
  131078. }
  131079. declare module BABYLON {
  131080. /** @hidden */
  131081. export var depthOfFieldPixelShader: {
  131082. name: string;
  131083. shader: string;
  131084. };
  131085. }
  131086. declare module BABYLON {
  131087. /**
  131088. * BABYLON.JS Chromatic Aberration GLSL Shader
  131089. * Author: Olivier Guyot
  131090. * Separates very slightly R, G and B colors on the edges of the screen
  131091. * Inspired by Francois Tarlier & Martins Upitis
  131092. */
  131093. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131094. /**
  131095. * @ignore
  131096. * The chromatic aberration PostProcess id in the pipeline
  131097. */
  131098. LensChromaticAberrationEffect: string;
  131099. /**
  131100. * @ignore
  131101. * The highlights enhancing PostProcess id in the pipeline
  131102. */
  131103. HighlightsEnhancingEffect: string;
  131104. /**
  131105. * @ignore
  131106. * The depth-of-field PostProcess id in the pipeline
  131107. */
  131108. LensDepthOfFieldEffect: string;
  131109. private _scene;
  131110. private _depthTexture;
  131111. private _grainTexture;
  131112. private _chromaticAberrationPostProcess;
  131113. private _highlightsPostProcess;
  131114. private _depthOfFieldPostProcess;
  131115. private _edgeBlur;
  131116. private _grainAmount;
  131117. private _chromaticAberration;
  131118. private _distortion;
  131119. private _highlightsGain;
  131120. private _highlightsThreshold;
  131121. private _dofDistance;
  131122. private _dofAperture;
  131123. private _dofDarken;
  131124. private _dofPentagon;
  131125. private _blurNoise;
  131126. /**
  131127. * @constructor
  131128. *
  131129. * Effect parameters are as follow:
  131130. * {
  131131. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131132. * edge_blur: number; // from 0 to x (1 for realism)
  131133. * distortion: number; // from 0 to x (1 for realism)
  131134. * grain_amount: number; // from 0 to 1
  131135. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131136. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131137. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131138. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131139. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131140. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131141. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131142. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131143. * }
  131144. * Note: if an effect parameter is unset, effect is disabled
  131145. *
  131146. * @param name The rendering pipeline name
  131147. * @param parameters - An object containing all parameters (see above)
  131148. * @param scene The scene linked to this pipeline
  131149. * @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)
  131150. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131151. */
  131152. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131153. /**
  131154. * Get the class name
  131155. * @returns "LensRenderingPipeline"
  131156. */
  131157. getClassName(): string;
  131158. /**
  131159. * Gets associated scene
  131160. */
  131161. readonly scene: Scene;
  131162. /**
  131163. * Gets or sets the edge blur
  131164. */
  131165. edgeBlur: number;
  131166. /**
  131167. * Gets or sets the grain amount
  131168. */
  131169. grainAmount: number;
  131170. /**
  131171. * Gets or sets the chromatic aberration amount
  131172. */
  131173. chromaticAberration: number;
  131174. /**
  131175. * Gets or sets the depth of field aperture
  131176. */
  131177. dofAperture: number;
  131178. /**
  131179. * Gets or sets the edge distortion
  131180. */
  131181. edgeDistortion: number;
  131182. /**
  131183. * Gets or sets the depth of field distortion
  131184. */
  131185. dofDistortion: number;
  131186. /**
  131187. * Gets or sets the darken out of focus amount
  131188. */
  131189. darkenOutOfFocus: number;
  131190. /**
  131191. * Gets or sets a boolean indicating if blur noise is enabled
  131192. */
  131193. blurNoise: boolean;
  131194. /**
  131195. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131196. */
  131197. pentagonBokeh: boolean;
  131198. /**
  131199. * Gets or sets the highlight grain amount
  131200. */
  131201. highlightsGain: number;
  131202. /**
  131203. * Gets or sets the highlight threshold
  131204. */
  131205. highlightsThreshold: number;
  131206. /**
  131207. * Sets the amount of blur at the edges
  131208. * @param amount blur amount
  131209. */
  131210. setEdgeBlur(amount: number): void;
  131211. /**
  131212. * Sets edge blur to 0
  131213. */
  131214. disableEdgeBlur(): void;
  131215. /**
  131216. * Sets the amout of grain
  131217. * @param amount Amount of grain
  131218. */
  131219. setGrainAmount(amount: number): void;
  131220. /**
  131221. * Set grain amount to 0
  131222. */
  131223. disableGrain(): void;
  131224. /**
  131225. * Sets the chromatic aberration amount
  131226. * @param amount amount of chromatic aberration
  131227. */
  131228. setChromaticAberration(amount: number): void;
  131229. /**
  131230. * Sets chromatic aberration amount to 0
  131231. */
  131232. disableChromaticAberration(): void;
  131233. /**
  131234. * Sets the EdgeDistortion amount
  131235. * @param amount amount of EdgeDistortion
  131236. */
  131237. setEdgeDistortion(amount: number): void;
  131238. /**
  131239. * Sets edge distortion to 0
  131240. */
  131241. disableEdgeDistortion(): void;
  131242. /**
  131243. * Sets the FocusDistance amount
  131244. * @param amount amount of FocusDistance
  131245. */
  131246. setFocusDistance(amount: number): void;
  131247. /**
  131248. * Disables depth of field
  131249. */
  131250. disableDepthOfField(): void;
  131251. /**
  131252. * Sets the Aperture amount
  131253. * @param amount amount of Aperture
  131254. */
  131255. setAperture(amount: number): void;
  131256. /**
  131257. * Sets the DarkenOutOfFocus amount
  131258. * @param amount amount of DarkenOutOfFocus
  131259. */
  131260. setDarkenOutOfFocus(amount: number): void;
  131261. private _pentagonBokehIsEnabled;
  131262. /**
  131263. * Creates a pentagon bokeh effect
  131264. */
  131265. enablePentagonBokeh(): void;
  131266. /**
  131267. * Disables the pentagon bokeh effect
  131268. */
  131269. disablePentagonBokeh(): void;
  131270. /**
  131271. * Enables noise blur
  131272. */
  131273. enableNoiseBlur(): void;
  131274. /**
  131275. * Disables noise blur
  131276. */
  131277. disableNoiseBlur(): void;
  131278. /**
  131279. * Sets the HighlightsGain amount
  131280. * @param amount amount of HighlightsGain
  131281. */
  131282. setHighlightsGain(amount: number): void;
  131283. /**
  131284. * Sets the HighlightsThreshold amount
  131285. * @param amount amount of HighlightsThreshold
  131286. */
  131287. setHighlightsThreshold(amount: number): void;
  131288. /**
  131289. * Disables highlights
  131290. */
  131291. disableHighlights(): void;
  131292. /**
  131293. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131294. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131295. */
  131296. dispose(disableDepthRender?: boolean): void;
  131297. private _createChromaticAberrationPostProcess;
  131298. private _createHighlightsPostProcess;
  131299. private _createDepthOfFieldPostProcess;
  131300. private _createGrainTexture;
  131301. }
  131302. }
  131303. declare module BABYLON {
  131304. /** @hidden */
  131305. export var ssao2PixelShader: {
  131306. name: string;
  131307. shader: string;
  131308. };
  131309. }
  131310. declare module BABYLON {
  131311. /** @hidden */
  131312. export var ssaoCombinePixelShader: {
  131313. name: string;
  131314. shader: string;
  131315. };
  131316. }
  131317. declare module BABYLON {
  131318. /**
  131319. * Render pipeline to produce ssao effect
  131320. */
  131321. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131322. /**
  131323. * @ignore
  131324. * The PassPostProcess id in the pipeline that contains the original scene color
  131325. */
  131326. SSAOOriginalSceneColorEffect: string;
  131327. /**
  131328. * @ignore
  131329. * The SSAO PostProcess id in the pipeline
  131330. */
  131331. SSAORenderEffect: string;
  131332. /**
  131333. * @ignore
  131334. * The horizontal blur PostProcess id in the pipeline
  131335. */
  131336. SSAOBlurHRenderEffect: string;
  131337. /**
  131338. * @ignore
  131339. * The vertical blur PostProcess id in the pipeline
  131340. */
  131341. SSAOBlurVRenderEffect: string;
  131342. /**
  131343. * @ignore
  131344. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131345. */
  131346. SSAOCombineRenderEffect: string;
  131347. /**
  131348. * The output strength of the SSAO post-process. Default value is 1.0.
  131349. */
  131350. totalStrength: number;
  131351. /**
  131352. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  131353. */
  131354. maxZ: number;
  131355. /**
  131356. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  131357. */
  131358. minZAspect: number;
  131359. private _samples;
  131360. /**
  131361. * Number of samples used for the SSAO calculations. Default value is 8
  131362. */
  131363. samples: number;
  131364. private _textureSamples;
  131365. /**
  131366. * Number of samples to use for antialiasing
  131367. */
  131368. textureSamples: number;
  131369. /**
  131370. * Ratio object used for SSAO ratio and blur ratio
  131371. */
  131372. private _ratio;
  131373. /**
  131374. * Dynamically generated sphere sampler.
  131375. */
  131376. private _sampleSphere;
  131377. /**
  131378. * Blur filter offsets
  131379. */
  131380. private _samplerOffsets;
  131381. private _expensiveBlur;
  131382. /**
  131383. * If bilateral blur should be used
  131384. */
  131385. expensiveBlur: boolean;
  131386. /**
  131387. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  131388. */
  131389. radius: number;
  131390. /**
  131391. * The base color of the SSAO post-process
  131392. * The final result is "base + ssao" between [0, 1]
  131393. */
  131394. base: number;
  131395. /**
  131396. * Support test.
  131397. */
  131398. static readonly IsSupported: boolean;
  131399. private _scene;
  131400. private _depthTexture;
  131401. private _normalTexture;
  131402. private _randomTexture;
  131403. private _originalColorPostProcess;
  131404. private _ssaoPostProcess;
  131405. private _blurHPostProcess;
  131406. private _blurVPostProcess;
  131407. private _ssaoCombinePostProcess;
  131408. /**
  131409. * Gets active scene
  131410. */
  131411. readonly scene: Scene;
  131412. /**
  131413. * @constructor
  131414. * @param name The rendering pipeline name
  131415. * @param scene The scene linked to this pipeline
  131416. * @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 }
  131417. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131418. */
  131419. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131420. /**
  131421. * Get the class name
  131422. * @returns "SSAO2RenderingPipeline"
  131423. */
  131424. getClassName(): string;
  131425. /**
  131426. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131427. */
  131428. dispose(disableGeometryBufferRenderer?: boolean): void;
  131429. private _createBlurPostProcess;
  131430. /** @hidden */
  131431. _rebuild(): void;
  131432. private _bits;
  131433. private _radicalInverse_VdC;
  131434. private _hammersley;
  131435. private _hemisphereSample_uniform;
  131436. private _generateHemisphere;
  131437. private _createSSAOPostProcess;
  131438. private _createSSAOCombinePostProcess;
  131439. private _createRandomTexture;
  131440. /**
  131441. * Serialize the rendering pipeline (Used when exporting)
  131442. * @returns the serialized object
  131443. */
  131444. serialize(): any;
  131445. /**
  131446. * Parse the serialized pipeline
  131447. * @param source Source pipeline.
  131448. * @param scene The scene to load the pipeline to.
  131449. * @param rootUrl The URL of the serialized pipeline.
  131450. * @returns An instantiated pipeline from the serialized object.
  131451. */
  131452. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  131453. }
  131454. }
  131455. declare module BABYLON {
  131456. /** @hidden */
  131457. export var ssaoPixelShader: {
  131458. name: string;
  131459. shader: string;
  131460. };
  131461. }
  131462. declare module BABYLON {
  131463. /**
  131464. * Render pipeline to produce ssao effect
  131465. */
  131466. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  131467. /**
  131468. * @ignore
  131469. * The PassPostProcess id in the pipeline that contains the original scene color
  131470. */
  131471. SSAOOriginalSceneColorEffect: string;
  131472. /**
  131473. * @ignore
  131474. * The SSAO PostProcess id in the pipeline
  131475. */
  131476. SSAORenderEffect: string;
  131477. /**
  131478. * @ignore
  131479. * The horizontal blur PostProcess id in the pipeline
  131480. */
  131481. SSAOBlurHRenderEffect: string;
  131482. /**
  131483. * @ignore
  131484. * The vertical blur PostProcess id in the pipeline
  131485. */
  131486. SSAOBlurVRenderEffect: string;
  131487. /**
  131488. * @ignore
  131489. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  131490. */
  131491. SSAOCombineRenderEffect: string;
  131492. /**
  131493. * The output strength of the SSAO post-process. Default value is 1.0.
  131494. */
  131495. totalStrength: number;
  131496. /**
  131497. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  131498. */
  131499. radius: number;
  131500. /**
  131501. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  131502. * Must not be equal to fallOff and superior to fallOff.
  131503. * Default value is 0.0075
  131504. */
  131505. area: number;
  131506. /**
  131507. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  131508. * Must not be equal to area and inferior to area.
  131509. * Default value is 0.000001
  131510. */
  131511. fallOff: number;
  131512. /**
  131513. * The base color of the SSAO post-process
  131514. * The final result is "base + ssao" between [0, 1]
  131515. */
  131516. base: number;
  131517. private _scene;
  131518. private _depthTexture;
  131519. private _randomTexture;
  131520. private _originalColorPostProcess;
  131521. private _ssaoPostProcess;
  131522. private _blurHPostProcess;
  131523. private _blurVPostProcess;
  131524. private _ssaoCombinePostProcess;
  131525. private _firstUpdate;
  131526. /**
  131527. * Gets active scene
  131528. */
  131529. readonly scene: Scene;
  131530. /**
  131531. * @constructor
  131532. * @param name - The rendering pipeline name
  131533. * @param scene - The scene linked to this pipeline
  131534. * @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 }
  131535. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  131536. */
  131537. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  131538. /**
  131539. * Get the class name
  131540. * @returns "SSAORenderingPipeline"
  131541. */
  131542. getClassName(): string;
  131543. /**
  131544. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  131545. */
  131546. dispose(disableDepthRender?: boolean): void;
  131547. private _createBlurPostProcess;
  131548. /** @hidden */
  131549. _rebuild(): void;
  131550. private _createSSAOPostProcess;
  131551. private _createSSAOCombinePostProcess;
  131552. private _createRandomTexture;
  131553. }
  131554. }
  131555. declare module BABYLON {
  131556. /** @hidden */
  131557. export var standardPixelShader: {
  131558. name: string;
  131559. shader: string;
  131560. };
  131561. }
  131562. declare module BABYLON {
  131563. /**
  131564. * Standard rendering pipeline
  131565. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131566. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  131567. */
  131568. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131569. /**
  131570. * Public members
  131571. */
  131572. /**
  131573. * Post-process which contains the original scene color before the pipeline applies all the effects
  131574. */
  131575. originalPostProcess: Nullable<PostProcess>;
  131576. /**
  131577. * Post-process used to down scale an image x4
  131578. */
  131579. downSampleX4PostProcess: Nullable<PostProcess>;
  131580. /**
  131581. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  131582. */
  131583. brightPassPostProcess: Nullable<PostProcess>;
  131584. /**
  131585. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  131586. */
  131587. blurHPostProcesses: PostProcess[];
  131588. /**
  131589. * Post-process array storing all the vertical blur post-processes used by the pipeline
  131590. */
  131591. blurVPostProcesses: PostProcess[];
  131592. /**
  131593. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  131594. */
  131595. textureAdderPostProcess: Nullable<PostProcess>;
  131596. /**
  131597. * Post-process used to create volumetric lighting effect
  131598. */
  131599. volumetricLightPostProcess: Nullable<PostProcess>;
  131600. /**
  131601. * Post-process used to smooth the previous volumetric light post-process on the X axis
  131602. */
  131603. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  131604. /**
  131605. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  131606. */
  131607. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  131608. /**
  131609. * Post-process used to merge the volumetric light effect and the real scene color
  131610. */
  131611. volumetricLightMergePostProces: Nullable<PostProcess>;
  131612. /**
  131613. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  131614. */
  131615. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  131616. /**
  131617. * Base post-process used to calculate the average luminance of the final image for HDR
  131618. */
  131619. luminancePostProcess: Nullable<PostProcess>;
  131620. /**
  131621. * Post-processes used to create down sample post-processes in order to get
  131622. * the average luminance of the final image for HDR
  131623. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  131624. */
  131625. luminanceDownSamplePostProcesses: PostProcess[];
  131626. /**
  131627. * Post-process used to create a HDR effect (light adaptation)
  131628. */
  131629. hdrPostProcess: Nullable<PostProcess>;
  131630. /**
  131631. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  131632. */
  131633. textureAdderFinalPostProcess: Nullable<PostProcess>;
  131634. /**
  131635. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  131636. */
  131637. lensFlareFinalPostProcess: Nullable<PostProcess>;
  131638. /**
  131639. * Post-process used to merge the final HDR post-process and the real scene color
  131640. */
  131641. hdrFinalPostProcess: Nullable<PostProcess>;
  131642. /**
  131643. * Post-process used to create a lens flare effect
  131644. */
  131645. lensFlarePostProcess: Nullable<PostProcess>;
  131646. /**
  131647. * Post-process that merges the result of the lens flare post-process and the real scene color
  131648. */
  131649. lensFlareComposePostProcess: Nullable<PostProcess>;
  131650. /**
  131651. * Post-process used to create a motion blur effect
  131652. */
  131653. motionBlurPostProcess: Nullable<PostProcess>;
  131654. /**
  131655. * Post-process used to create a depth of field effect
  131656. */
  131657. depthOfFieldPostProcess: Nullable<PostProcess>;
  131658. /**
  131659. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131660. */
  131661. fxaaPostProcess: Nullable<FxaaPostProcess>;
  131662. /**
  131663. * Represents the brightness threshold in order to configure the illuminated surfaces
  131664. */
  131665. brightThreshold: number;
  131666. /**
  131667. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  131668. */
  131669. blurWidth: number;
  131670. /**
  131671. * Sets if the blur for highlighted surfaces must be only horizontal
  131672. */
  131673. horizontalBlur: boolean;
  131674. /**
  131675. * Gets the overall exposure used by the pipeline
  131676. */
  131677. /**
  131678. * Sets the overall exposure used by the pipeline
  131679. */
  131680. exposure: number;
  131681. /**
  131682. * Texture used typically to simulate "dirty" on camera lens
  131683. */
  131684. lensTexture: Nullable<Texture>;
  131685. /**
  131686. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  131687. */
  131688. volumetricLightCoefficient: number;
  131689. /**
  131690. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  131691. */
  131692. volumetricLightPower: number;
  131693. /**
  131694. * Used the set the blur intensity to smooth the volumetric lights
  131695. */
  131696. volumetricLightBlurScale: number;
  131697. /**
  131698. * Light (spot or directional) used to generate the volumetric lights rays
  131699. * The source light must have a shadow generate so the pipeline can get its
  131700. * depth map
  131701. */
  131702. sourceLight: Nullable<SpotLight | DirectionalLight>;
  131703. /**
  131704. * For eye adaptation, represents the minimum luminance the eye can see
  131705. */
  131706. hdrMinimumLuminance: number;
  131707. /**
  131708. * For eye adaptation, represents the decrease luminance speed
  131709. */
  131710. hdrDecreaseRate: number;
  131711. /**
  131712. * For eye adaptation, represents the increase luminance speed
  131713. */
  131714. hdrIncreaseRate: number;
  131715. /**
  131716. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131717. */
  131718. /**
  131719. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  131720. */
  131721. hdrAutoExposure: boolean;
  131722. /**
  131723. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  131724. */
  131725. lensColorTexture: Nullable<Texture>;
  131726. /**
  131727. * The overall strengh for the lens flare effect
  131728. */
  131729. lensFlareStrength: number;
  131730. /**
  131731. * Dispersion coefficient for lens flare ghosts
  131732. */
  131733. lensFlareGhostDispersal: number;
  131734. /**
  131735. * Main lens flare halo width
  131736. */
  131737. lensFlareHaloWidth: number;
  131738. /**
  131739. * Based on the lens distortion effect, defines how much the lens flare result
  131740. * is distorted
  131741. */
  131742. lensFlareDistortionStrength: number;
  131743. /**
  131744. * Configures the blur intensity used for for lens flare (halo)
  131745. */
  131746. lensFlareBlurWidth: number;
  131747. /**
  131748. * Lens star texture must be used to simulate rays on the flares and is available
  131749. * in the documentation
  131750. */
  131751. lensStarTexture: Nullable<Texture>;
  131752. /**
  131753. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  131754. * flare effect by taking account of the dirt texture
  131755. */
  131756. lensFlareDirtTexture: Nullable<Texture>;
  131757. /**
  131758. * Represents the focal length for the depth of field effect
  131759. */
  131760. depthOfFieldDistance: number;
  131761. /**
  131762. * Represents the blur intensity for the blurred part of the depth of field effect
  131763. */
  131764. depthOfFieldBlurWidth: number;
  131765. /**
  131766. * Gets how much the image is blurred by the movement while using the motion blur post-process
  131767. */
  131768. /**
  131769. * Sets how much the image is blurred by the movement while using the motion blur post-process
  131770. */
  131771. motionStrength: number;
  131772. /**
  131773. * Gets wether or not the motion blur post-process is object based or screen based.
  131774. */
  131775. /**
  131776. * Sets wether or not the motion blur post-process should be object based or screen based
  131777. */
  131778. objectBasedMotionBlur: boolean;
  131779. /**
  131780. * List of animations for the pipeline (IAnimatable implementation)
  131781. */
  131782. animations: Animation[];
  131783. /**
  131784. * Private members
  131785. */
  131786. private _scene;
  131787. private _currentDepthOfFieldSource;
  131788. private _basePostProcess;
  131789. private _fixedExposure;
  131790. private _currentExposure;
  131791. private _hdrAutoExposure;
  131792. private _hdrCurrentLuminance;
  131793. private _motionStrength;
  131794. private _isObjectBasedMotionBlur;
  131795. private _floatTextureType;
  131796. private _camerasToBeAttached;
  131797. private _ratio;
  131798. private _bloomEnabled;
  131799. private _depthOfFieldEnabled;
  131800. private _vlsEnabled;
  131801. private _lensFlareEnabled;
  131802. private _hdrEnabled;
  131803. private _motionBlurEnabled;
  131804. private _fxaaEnabled;
  131805. private _motionBlurSamples;
  131806. private _volumetricLightStepsCount;
  131807. private _samples;
  131808. /**
  131809. * @ignore
  131810. * Specifies if the bloom pipeline is enabled
  131811. */
  131812. BloomEnabled: boolean;
  131813. /**
  131814. * @ignore
  131815. * Specifies if the depth of field pipeline is enabed
  131816. */
  131817. DepthOfFieldEnabled: boolean;
  131818. /**
  131819. * @ignore
  131820. * Specifies if the lens flare pipeline is enabed
  131821. */
  131822. LensFlareEnabled: boolean;
  131823. /**
  131824. * @ignore
  131825. * Specifies if the HDR pipeline is enabled
  131826. */
  131827. HDREnabled: boolean;
  131828. /**
  131829. * @ignore
  131830. * Specifies if the volumetric lights scattering effect is enabled
  131831. */
  131832. VLSEnabled: boolean;
  131833. /**
  131834. * @ignore
  131835. * Specifies if the motion blur effect is enabled
  131836. */
  131837. MotionBlurEnabled: boolean;
  131838. /**
  131839. * Specifies if anti-aliasing is enabled
  131840. */
  131841. fxaaEnabled: boolean;
  131842. /**
  131843. * Specifies the number of steps used to calculate the volumetric lights
  131844. * Typically in interval [50, 200]
  131845. */
  131846. volumetricLightStepsCount: number;
  131847. /**
  131848. * Specifies the number of samples used for the motion blur effect
  131849. * Typically in interval [16, 64]
  131850. */
  131851. motionBlurSamples: number;
  131852. /**
  131853. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131854. */
  131855. samples: number;
  131856. /**
  131857. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  131858. * @constructor
  131859. * @param name The rendering pipeline name
  131860. * @param scene The scene linked to this pipeline
  131861. * @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)
  131862. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  131863. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131864. */
  131865. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  131866. private _buildPipeline;
  131867. private _createDownSampleX4PostProcess;
  131868. private _createBrightPassPostProcess;
  131869. private _createBlurPostProcesses;
  131870. private _createTextureAdderPostProcess;
  131871. private _createVolumetricLightPostProcess;
  131872. private _createLuminancePostProcesses;
  131873. private _createHdrPostProcess;
  131874. private _createLensFlarePostProcess;
  131875. private _createDepthOfFieldPostProcess;
  131876. private _createMotionBlurPostProcess;
  131877. private _getDepthTexture;
  131878. private _disposePostProcesses;
  131879. /**
  131880. * Dispose of the pipeline and stop all post processes
  131881. */
  131882. dispose(): void;
  131883. /**
  131884. * Serialize the rendering pipeline (Used when exporting)
  131885. * @returns the serialized object
  131886. */
  131887. serialize(): any;
  131888. /**
  131889. * Parse the serialized pipeline
  131890. * @param source Source pipeline.
  131891. * @param scene The scene to load the pipeline to.
  131892. * @param rootUrl The URL of the serialized pipeline.
  131893. * @returns An instantiated pipeline from the serialized object.
  131894. */
  131895. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  131896. /**
  131897. * Luminance steps
  131898. */
  131899. static LuminanceSteps: number;
  131900. }
  131901. }
  131902. declare module BABYLON {
  131903. /** @hidden */
  131904. export var tonemapPixelShader: {
  131905. name: string;
  131906. shader: string;
  131907. };
  131908. }
  131909. declare module BABYLON {
  131910. /** Defines operator used for tonemapping */
  131911. export enum TonemappingOperator {
  131912. /** Hable */
  131913. Hable = 0,
  131914. /** Reinhard */
  131915. Reinhard = 1,
  131916. /** HejiDawson */
  131917. HejiDawson = 2,
  131918. /** Photographic */
  131919. Photographic = 3
  131920. }
  131921. /**
  131922. * Defines a post process to apply tone mapping
  131923. */
  131924. export class TonemapPostProcess extends PostProcess {
  131925. private _operator;
  131926. /** Defines the required exposure adjustement */
  131927. exposureAdjustment: number;
  131928. /**
  131929. * Creates a new TonemapPostProcess
  131930. * @param name defines the name of the postprocess
  131931. * @param _operator defines the operator to use
  131932. * @param exposureAdjustment defines the required exposure adjustement
  131933. * @param camera defines the camera to use (can be null)
  131934. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  131935. * @param engine defines the hosting engine (can be ignore if camera is set)
  131936. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131937. */
  131938. constructor(name: string, _operator: TonemappingOperator,
  131939. /** Defines the required exposure adjustement */
  131940. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  131941. }
  131942. }
  131943. declare module BABYLON {
  131944. /** @hidden */
  131945. export var depthVertexShader: {
  131946. name: string;
  131947. shader: string;
  131948. };
  131949. }
  131950. declare module BABYLON {
  131951. /** @hidden */
  131952. export var volumetricLightScatteringPixelShader: {
  131953. name: string;
  131954. shader: string;
  131955. };
  131956. }
  131957. declare module BABYLON {
  131958. /** @hidden */
  131959. export var volumetricLightScatteringPassVertexShader: {
  131960. name: string;
  131961. shader: string;
  131962. };
  131963. }
  131964. declare module BABYLON {
  131965. /** @hidden */
  131966. export var volumetricLightScatteringPassPixelShader: {
  131967. name: string;
  131968. shader: string;
  131969. };
  131970. }
  131971. declare module BABYLON {
  131972. /**
  131973. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  131974. */
  131975. export class VolumetricLightScatteringPostProcess extends PostProcess {
  131976. private _volumetricLightScatteringPass;
  131977. private _volumetricLightScatteringRTT;
  131978. private _viewPort;
  131979. private _screenCoordinates;
  131980. private _cachedDefines;
  131981. /**
  131982. * If not undefined, the mesh position is computed from the attached node position
  131983. */
  131984. attachedNode: {
  131985. position: Vector3;
  131986. };
  131987. /**
  131988. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  131989. */
  131990. customMeshPosition: Vector3;
  131991. /**
  131992. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  131993. */
  131994. useCustomMeshPosition: boolean;
  131995. /**
  131996. * If the post-process should inverse the light scattering direction
  131997. */
  131998. invert: boolean;
  131999. /**
  132000. * The internal mesh used by the post-process
  132001. */
  132002. mesh: Mesh;
  132003. /**
  132004. * @hidden
  132005. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132006. */
  132007. useDiffuseColor: boolean;
  132008. /**
  132009. * Array containing the excluded meshes not rendered in the internal pass
  132010. */
  132011. excludedMeshes: AbstractMesh[];
  132012. /**
  132013. * Controls the overall intensity of the post-process
  132014. */
  132015. exposure: number;
  132016. /**
  132017. * Dissipates each sample's contribution in range [0, 1]
  132018. */
  132019. decay: number;
  132020. /**
  132021. * Controls the overall intensity of each sample
  132022. */
  132023. weight: number;
  132024. /**
  132025. * Controls the density of each sample
  132026. */
  132027. density: number;
  132028. /**
  132029. * @constructor
  132030. * @param name The post-process name
  132031. * @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)
  132032. * @param camera The camera that the post-process will be attached to
  132033. * @param mesh The mesh used to create the light scattering
  132034. * @param samples The post-process quality, default 100
  132035. * @param samplingModeThe post-process filtering mode
  132036. * @param engine The babylon engine
  132037. * @param reusable If the post-process is reusable
  132038. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132039. */
  132040. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132041. /**
  132042. * Returns the string "VolumetricLightScatteringPostProcess"
  132043. * @returns "VolumetricLightScatteringPostProcess"
  132044. */
  132045. getClassName(): string;
  132046. private _isReady;
  132047. /**
  132048. * Sets the new light position for light scattering effect
  132049. * @param position The new custom light position
  132050. */
  132051. setCustomMeshPosition(position: Vector3): void;
  132052. /**
  132053. * Returns the light position for light scattering effect
  132054. * @return Vector3 The custom light position
  132055. */
  132056. getCustomMeshPosition(): Vector3;
  132057. /**
  132058. * Disposes the internal assets and detaches the post-process from the camera
  132059. */
  132060. dispose(camera: Camera): void;
  132061. /**
  132062. * Returns the render target texture used by the post-process
  132063. * @return the render target texture used by the post-process
  132064. */
  132065. getPass(): RenderTargetTexture;
  132066. private _meshExcluded;
  132067. private _createPass;
  132068. private _updateMeshScreenCoordinates;
  132069. /**
  132070. * Creates a default mesh for the Volumeric Light Scattering post-process
  132071. * @param name The mesh name
  132072. * @param scene The scene where to create the mesh
  132073. * @return the default mesh
  132074. */
  132075. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132076. }
  132077. }
  132078. declare module BABYLON {
  132079. interface Scene {
  132080. /** @hidden (Backing field) */
  132081. _boundingBoxRenderer: BoundingBoxRenderer;
  132082. /** @hidden (Backing field) */
  132083. _forceShowBoundingBoxes: boolean;
  132084. /**
  132085. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132086. */
  132087. forceShowBoundingBoxes: boolean;
  132088. /**
  132089. * Gets the bounding box renderer associated with the scene
  132090. * @returns a BoundingBoxRenderer
  132091. */
  132092. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132093. }
  132094. interface AbstractMesh {
  132095. /** @hidden (Backing field) */
  132096. _showBoundingBox: boolean;
  132097. /**
  132098. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132099. */
  132100. showBoundingBox: boolean;
  132101. }
  132102. /**
  132103. * Component responsible of rendering the bounding box of the meshes in a scene.
  132104. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132105. */
  132106. export class BoundingBoxRenderer implements ISceneComponent {
  132107. /**
  132108. * The component name helpfull to identify the component in the list of scene components.
  132109. */
  132110. readonly name: string;
  132111. /**
  132112. * The scene the component belongs to.
  132113. */
  132114. scene: Scene;
  132115. /**
  132116. * Color of the bounding box lines placed in front of an object
  132117. */
  132118. frontColor: Color3;
  132119. /**
  132120. * Color of the bounding box lines placed behind an object
  132121. */
  132122. backColor: Color3;
  132123. /**
  132124. * Defines if the renderer should show the back lines or not
  132125. */
  132126. showBackLines: boolean;
  132127. /**
  132128. * @hidden
  132129. */
  132130. renderList: SmartArray<BoundingBox>;
  132131. private _colorShader;
  132132. private _vertexBuffers;
  132133. private _indexBuffer;
  132134. private _fillIndexBuffer;
  132135. private _fillIndexData;
  132136. /**
  132137. * Instantiates a new bounding box renderer in a scene.
  132138. * @param scene the scene the renderer renders in
  132139. */
  132140. constructor(scene: Scene);
  132141. /**
  132142. * Registers the component in a given scene
  132143. */
  132144. register(): void;
  132145. private _evaluateSubMesh;
  132146. private _activeMesh;
  132147. private _prepareRessources;
  132148. private _createIndexBuffer;
  132149. /**
  132150. * Rebuilds the elements related to this component in case of
  132151. * context lost for instance.
  132152. */
  132153. rebuild(): void;
  132154. /**
  132155. * @hidden
  132156. */
  132157. reset(): void;
  132158. /**
  132159. * Render the bounding boxes of a specific rendering group
  132160. * @param renderingGroupId defines the rendering group to render
  132161. */
  132162. render(renderingGroupId: number): void;
  132163. /**
  132164. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132165. * @param mesh Define the mesh to render the occlusion bounding box for
  132166. */
  132167. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132168. /**
  132169. * Dispose and release the resources attached to this renderer.
  132170. */
  132171. dispose(): void;
  132172. }
  132173. }
  132174. declare module BABYLON {
  132175. /** @hidden */
  132176. export var depthPixelShader: {
  132177. name: string;
  132178. shader: string;
  132179. };
  132180. }
  132181. declare module BABYLON {
  132182. /**
  132183. * This represents a depth renderer in Babylon.
  132184. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132185. */
  132186. export class DepthRenderer {
  132187. private _scene;
  132188. private _depthMap;
  132189. private _effect;
  132190. private readonly _storeNonLinearDepth;
  132191. private readonly _clearColor;
  132192. /** Get if the depth renderer is using packed depth or not */
  132193. readonly isPacked: boolean;
  132194. private _cachedDefines;
  132195. private _camera;
  132196. /**
  132197. * Specifiess that the depth renderer will only be used within
  132198. * the camera it is created for.
  132199. * This can help forcing its rendering during the camera processing.
  132200. */
  132201. useOnlyInActiveCamera: boolean;
  132202. /** @hidden */
  132203. static _SceneComponentInitialization: (scene: Scene) => void;
  132204. /**
  132205. * Instantiates a depth renderer
  132206. * @param scene The scene the renderer belongs to
  132207. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132208. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132209. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132210. */
  132211. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132212. /**
  132213. * Creates the depth rendering effect and checks if the effect is ready.
  132214. * @param subMesh The submesh to be used to render the depth map of
  132215. * @param useInstances If multiple world instances should be used
  132216. * @returns if the depth renderer is ready to render the depth map
  132217. */
  132218. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132219. /**
  132220. * Gets the texture which the depth map will be written to.
  132221. * @returns The depth map texture
  132222. */
  132223. getDepthMap(): RenderTargetTexture;
  132224. /**
  132225. * Disposes of the depth renderer.
  132226. */
  132227. dispose(): void;
  132228. }
  132229. }
  132230. declare module BABYLON {
  132231. interface Scene {
  132232. /** @hidden (Backing field) */
  132233. _depthRenderer: {
  132234. [id: string]: DepthRenderer;
  132235. };
  132236. /**
  132237. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132238. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132239. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132240. * @returns the created depth renderer
  132241. */
  132242. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132243. /**
  132244. * Disables a depth renderer for a given camera
  132245. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132246. */
  132247. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132248. }
  132249. /**
  132250. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132251. * in several rendering techniques.
  132252. */
  132253. export class DepthRendererSceneComponent implements ISceneComponent {
  132254. /**
  132255. * The component name helpfull to identify the component in the list of scene components.
  132256. */
  132257. readonly name: string;
  132258. /**
  132259. * The scene the component belongs to.
  132260. */
  132261. scene: Scene;
  132262. /**
  132263. * Creates a new instance of the component for the given scene
  132264. * @param scene Defines the scene to register the component in
  132265. */
  132266. constructor(scene: Scene);
  132267. /**
  132268. * Registers the component in a given scene
  132269. */
  132270. register(): void;
  132271. /**
  132272. * Rebuilds the elements related to this component in case of
  132273. * context lost for instance.
  132274. */
  132275. rebuild(): void;
  132276. /**
  132277. * Disposes the component and the associated ressources
  132278. */
  132279. dispose(): void;
  132280. private _gatherRenderTargets;
  132281. private _gatherActiveCameraRenderTargets;
  132282. }
  132283. }
  132284. declare module BABYLON {
  132285. /** @hidden */
  132286. export var outlinePixelShader: {
  132287. name: string;
  132288. shader: string;
  132289. };
  132290. }
  132291. declare module BABYLON {
  132292. /** @hidden */
  132293. export var outlineVertexShader: {
  132294. name: string;
  132295. shader: string;
  132296. };
  132297. }
  132298. declare module BABYLON {
  132299. interface Scene {
  132300. /** @hidden */
  132301. _outlineRenderer: OutlineRenderer;
  132302. /**
  132303. * Gets the outline renderer associated with the scene
  132304. * @returns a OutlineRenderer
  132305. */
  132306. getOutlineRenderer(): OutlineRenderer;
  132307. }
  132308. interface AbstractMesh {
  132309. /** @hidden (Backing field) */
  132310. _renderOutline: boolean;
  132311. /**
  132312. * Gets or sets a boolean indicating if the outline must be rendered as well
  132313. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132314. */
  132315. renderOutline: boolean;
  132316. /** @hidden (Backing field) */
  132317. _renderOverlay: boolean;
  132318. /**
  132319. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132320. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132321. */
  132322. renderOverlay: boolean;
  132323. }
  132324. /**
  132325. * This class is responsible to draw bothe outline/overlay of meshes.
  132326. * It should not be used directly but through the available method on mesh.
  132327. */
  132328. export class OutlineRenderer implements ISceneComponent {
  132329. /**
  132330. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132331. */
  132332. private static _StencilReference;
  132333. /**
  132334. * The name of the component. Each component must have a unique name.
  132335. */
  132336. name: string;
  132337. /**
  132338. * The scene the component belongs to.
  132339. */
  132340. scene: Scene;
  132341. /**
  132342. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132343. */
  132344. zOffset: number;
  132345. private _engine;
  132346. private _effect;
  132347. private _cachedDefines;
  132348. private _savedDepthWrite;
  132349. /**
  132350. * Instantiates a new outline renderer. (There could be only one per scene).
  132351. * @param scene Defines the scene it belongs to
  132352. */
  132353. constructor(scene: Scene);
  132354. /**
  132355. * Register the component to one instance of a scene.
  132356. */
  132357. register(): void;
  132358. /**
  132359. * Rebuilds the elements related to this component in case of
  132360. * context lost for instance.
  132361. */
  132362. rebuild(): void;
  132363. /**
  132364. * Disposes the component and the associated ressources.
  132365. */
  132366. dispose(): void;
  132367. /**
  132368. * Renders the outline in the canvas.
  132369. * @param subMesh Defines the sumesh to render
  132370. * @param batch Defines the batch of meshes in case of instances
  132371. * @param useOverlay Defines if the rendering is for the overlay or the outline
  132372. */
  132373. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  132374. /**
  132375. * Returns whether or not the outline renderer is ready for a given submesh.
  132376. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  132377. * @param subMesh Defines the submesh to check readyness for
  132378. * @param useInstances Defines wheter wee are trying to render instances or not
  132379. * @returns true if ready otherwise false
  132380. */
  132381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132382. private _beforeRenderingMesh;
  132383. private _afterRenderingMesh;
  132384. }
  132385. }
  132386. declare module BABYLON {
  132387. /**
  132388. * Class used to manage multiple sprites of different sizes on the same spritesheet
  132389. * @see http://doc.babylonjs.com/babylon101/sprites
  132390. */
  132391. export class SpritePackedManager extends SpriteManager {
  132392. /** defines the packed manager's name */
  132393. name: string;
  132394. /**
  132395. * Creates a new sprite manager from a packed sprite sheet
  132396. * @param name defines the manager's name
  132397. * @param imgUrl defines the sprite sheet url
  132398. * @param capacity defines the maximum allowed number of sprites
  132399. * @param scene defines the hosting scene
  132400. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  132401. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  132402. * @param samplingMode defines the smapling mode to use with spritesheet
  132403. * @param fromPacked set to true; do not alter
  132404. */
  132405. constructor(
  132406. /** defines the packed manager's name */
  132407. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  132408. }
  132409. }
  132410. declare module BABYLON {
  132411. /**
  132412. * Defines the list of states available for a task inside a AssetsManager
  132413. */
  132414. export enum AssetTaskState {
  132415. /**
  132416. * Initialization
  132417. */
  132418. INIT = 0,
  132419. /**
  132420. * Running
  132421. */
  132422. RUNNING = 1,
  132423. /**
  132424. * Done
  132425. */
  132426. DONE = 2,
  132427. /**
  132428. * Error
  132429. */
  132430. ERROR = 3
  132431. }
  132432. /**
  132433. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  132434. */
  132435. export abstract class AbstractAssetTask {
  132436. /**
  132437. * Task name
  132438. */ name: string;
  132439. /**
  132440. * Callback called when the task is successful
  132441. */
  132442. onSuccess: (task: any) => void;
  132443. /**
  132444. * Callback called when the task is not successful
  132445. */
  132446. onError: (task: any, message?: string, exception?: any) => void;
  132447. /**
  132448. * Creates a new AssetsManager
  132449. * @param name defines the name of the task
  132450. */
  132451. constructor(
  132452. /**
  132453. * Task name
  132454. */ name: string);
  132455. private _isCompleted;
  132456. private _taskState;
  132457. private _errorObject;
  132458. /**
  132459. * Get if the task is completed
  132460. */
  132461. readonly isCompleted: boolean;
  132462. /**
  132463. * Gets the current state of the task
  132464. */
  132465. readonly taskState: AssetTaskState;
  132466. /**
  132467. * Gets the current error object (if task is in error)
  132468. */
  132469. readonly errorObject: {
  132470. message?: string;
  132471. exception?: any;
  132472. };
  132473. /**
  132474. * Internal only
  132475. * @hidden
  132476. */
  132477. _setErrorObject(message?: string, exception?: any): void;
  132478. /**
  132479. * Execute the current task
  132480. * @param scene defines the scene where you want your assets to be loaded
  132481. * @param onSuccess is a callback called when the task is successfully executed
  132482. * @param onError is a callback called if an error occurs
  132483. */
  132484. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132485. /**
  132486. * Execute the current task
  132487. * @param scene defines the scene where you want your assets to be loaded
  132488. * @param onSuccess is a callback called when the task is successfully executed
  132489. * @param onError is a callback called if an error occurs
  132490. */
  132491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132492. /**
  132493. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  132494. * This can be used with failed tasks that have the reason for failure fixed.
  132495. */
  132496. reset(): void;
  132497. private onErrorCallback;
  132498. private onDoneCallback;
  132499. }
  132500. /**
  132501. * Define the interface used by progress events raised during assets loading
  132502. */
  132503. export interface IAssetsProgressEvent {
  132504. /**
  132505. * Defines the number of remaining tasks to process
  132506. */
  132507. remainingCount: number;
  132508. /**
  132509. * Defines the total number of tasks
  132510. */
  132511. totalCount: number;
  132512. /**
  132513. * Defines the task that was just processed
  132514. */
  132515. task: AbstractAssetTask;
  132516. }
  132517. /**
  132518. * Class used to share progress information about assets loading
  132519. */
  132520. export class AssetsProgressEvent implements IAssetsProgressEvent {
  132521. /**
  132522. * Defines the number of remaining tasks to process
  132523. */
  132524. remainingCount: number;
  132525. /**
  132526. * Defines the total number of tasks
  132527. */
  132528. totalCount: number;
  132529. /**
  132530. * Defines the task that was just processed
  132531. */
  132532. task: AbstractAssetTask;
  132533. /**
  132534. * Creates a AssetsProgressEvent
  132535. * @param remainingCount defines the number of remaining tasks to process
  132536. * @param totalCount defines the total number of tasks
  132537. * @param task defines the task that was just processed
  132538. */
  132539. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  132540. }
  132541. /**
  132542. * Define a task used by AssetsManager to load meshes
  132543. */
  132544. export class MeshAssetTask extends AbstractAssetTask {
  132545. /**
  132546. * Defines the name of the task
  132547. */
  132548. name: string;
  132549. /**
  132550. * Defines the list of mesh's names you want to load
  132551. */
  132552. meshesNames: any;
  132553. /**
  132554. * Defines the root url to use as a base to load your meshes and associated resources
  132555. */
  132556. rootUrl: string;
  132557. /**
  132558. * Defines the filename of the scene to load from
  132559. */
  132560. sceneFilename: string;
  132561. /**
  132562. * Gets the list of loaded meshes
  132563. */
  132564. loadedMeshes: Array<AbstractMesh>;
  132565. /**
  132566. * Gets the list of loaded particle systems
  132567. */
  132568. loadedParticleSystems: Array<IParticleSystem>;
  132569. /**
  132570. * Gets the list of loaded skeletons
  132571. */
  132572. loadedSkeletons: Array<Skeleton>;
  132573. /**
  132574. * Gets the list of loaded animation groups
  132575. */
  132576. loadedAnimationGroups: Array<AnimationGroup>;
  132577. /**
  132578. * Callback called when the task is successful
  132579. */
  132580. onSuccess: (task: MeshAssetTask) => void;
  132581. /**
  132582. * Callback called when the task is successful
  132583. */
  132584. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  132585. /**
  132586. * Creates a new MeshAssetTask
  132587. * @param name defines the name of the task
  132588. * @param meshesNames defines the list of mesh's names you want to load
  132589. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  132590. * @param sceneFilename defines the filename of the scene to load from
  132591. */
  132592. constructor(
  132593. /**
  132594. * Defines the name of the task
  132595. */
  132596. name: string,
  132597. /**
  132598. * Defines the list of mesh's names you want to load
  132599. */
  132600. meshesNames: any,
  132601. /**
  132602. * Defines the root url to use as a base to load your meshes and associated resources
  132603. */
  132604. rootUrl: string,
  132605. /**
  132606. * Defines the filename of the scene to load from
  132607. */
  132608. sceneFilename: string);
  132609. /**
  132610. * Execute the current task
  132611. * @param scene defines the scene where you want your assets to be loaded
  132612. * @param onSuccess is a callback called when the task is successfully executed
  132613. * @param onError is a callback called if an error occurs
  132614. */
  132615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132616. }
  132617. /**
  132618. * Define a task used by AssetsManager to load text content
  132619. */
  132620. export class TextFileAssetTask extends AbstractAssetTask {
  132621. /**
  132622. * Defines the name of the task
  132623. */
  132624. name: string;
  132625. /**
  132626. * Defines the location of the file to load
  132627. */
  132628. url: string;
  132629. /**
  132630. * Gets the loaded text string
  132631. */
  132632. text: string;
  132633. /**
  132634. * Callback called when the task is successful
  132635. */
  132636. onSuccess: (task: TextFileAssetTask) => void;
  132637. /**
  132638. * Callback called when the task is successful
  132639. */
  132640. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  132641. /**
  132642. * Creates a new TextFileAssetTask object
  132643. * @param name defines the name of the task
  132644. * @param url defines the location of the file to load
  132645. */
  132646. constructor(
  132647. /**
  132648. * Defines the name of the task
  132649. */
  132650. name: string,
  132651. /**
  132652. * Defines the location of the file to load
  132653. */
  132654. url: string);
  132655. /**
  132656. * Execute the current task
  132657. * @param scene defines the scene where you want your assets to be loaded
  132658. * @param onSuccess is a callback called when the task is successfully executed
  132659. * @param onError is a callback called if an error occurs
  132660. */
  132661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132662. }
  132663. /**
  132664. * Define a task used by AssetsManager to load binary data
  132665. */
  132666. export class BinaryFileAssetTask extends AbstractAssetTask {
  132667. /**
  132668. * Defines the name of the task
  132669. */
  132670. name: string;
  132671. /**
  132672. * Defines the location of the file to load
  132673. */
  132674. url: string;
  132675. /**
  132676. * Gets the lodaded data (as an array buffer)
  132677. */
  132678. data: ArrayBuffer;
  132679. /**
  132680. * Callback called when the task is successful
  132681. */
  132682. onSuccess: (task: BinaryFileAssetTask) => void;
  132683. /**
  132684. * Callback called when the task is successful
  132685. */
  132686. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  132687. /**
  132688. * Creates a new BinaryFileAssetTask object
  132689. * @param name defines the name of the new task
  132690. * @param url defines the location of the file to load
  132691. */
  132692. constructor(
  132693. /**
  132694. * Defines the name of the task
  132695. */
  132696. name: string,
  132697. /**
  132698. * Defines the location of the file to load
  132699. */
  132700. url: string);
  132701. /**
  132702. * Execute the current task
  132703. * @param scene defines the scene where you want your assets to be loaded
  132704. * @param onSuccess is a callback called when the task is successfully executed
  132705. * @param onError is a callback called if an error occurs
  132706. */
  132707. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132708. }
  132709. /**
  132710. * Define a task used by AssetsManager to load images
  132711. */
  132712. export class ImageAssetTask extends AbstractAssetTask {
  132713. /**
  132714. * Defines the name of the task
  132715. */
  132716. name: string;
  132717. /**
  132718. * Defines the location of the image to load
  132719. */
  132720. url: string;
  132721. /**
  132722. * Gets the loaded images
  132723. */
  132724. image: HTMLImageElement;
  132725. /**
  132726. * Callback called when the task is successful
  132727. */
  132728. onSuccess: (task: ImageAssetTask) => void;
  132729. /**
  132730. * Callback called when the task is successful
  132731. */
  132732. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  132733. /**
  132734. * Creates a new ImageAssetTask
  132735. * @param name defines the name of the task
  132736. * @param url defines the location of the image to load
  132737. */
  132738. constructor(
  132739. /**
  132740. * Defines the name of the task
  132741. */
  132742. name: string,
  132743. /**
  132744. * Defines the location of the image to load
  132745. */
  132746. url: string);
  132747. /**
  132748. * Execute the current task
  132749. * @param scene defines the scene where you want your assets to be loaded
  132750. * @param onSuccess is a callback called when the task is successfully executed
  132751. * @param onError is a callback called if an error occurs
  132752. */
  132753. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132754. }
  132755. /**
  132756. * Defines the interface used by texture loading tasks
  132757. */
  132758. export interface ITextureAssetTask<TEX extends BaseTexture> {
  132759. /**
  132760. * Gets the loaded texture
  132761. */
  132762. texture: TEX;
  132763. }
  132764. /**
  132765. * Define a task used by AssetsManager to load 2D textures
  132766. */
  132767. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  132768. /**
  132769. * Defines the name of the task
  132770. */
  132771. name: string;
  132772. /**
  132773. * Defines the location of the file to load
  132774. */
  132775. url: string;
  132776. /**
  132777. * Defines if mipmap should not be generated (default is false)
  132778. */
  132779. noMipmap?: boolean | undefined;
  132780. /**
  132781. * Defines if texture must be inverted on Y axis (default is false)
  132782. */
  132783. invertY?: boolean | undefined;
  132784. /**
  132785. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132786. */
  132787. samplingMode: number;
  132788. /**
  132789. * Gets the loaded texture
  132790. */
  132791. texture: Texture;
  132792. /**
  132793. * Callback called when the task is successful
  132794. */
  132795. onSuccess: (task: TextureAssetTask) => void;
  132796. /**
  132797. * Callback called when the task is successful
  132798. */
  132799. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  132800. /**
  132801. * Creates a new TextureAssetTask object
  132802. * @param name defines the name of the task
  132803. * @param url defines the location of the file to load
  132804. * @param noMipmap defines if mipmap should not be generated (default is false)
  132805. * @param invertY defines if texture must be inverted on Y axis (default is false)
  132806. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132807. */
  132808. constructor(
  132809. /**
  132810. * Defines the name of the task
  132811. */
  132812. name: string,
  132813. /**
  132814. * Defines the location of the file to load
  132815. */
  132816. url: string,
  132817. /**
  132818. * Defines if mipmap should not be generated (default is false)
  132819. */
  132820. noMipmap?: boolean | undefined,
  132821. /**
  132822. * Defines if texture must be inverted on Y axis (default is false)
  132823. */
  132824. invertY?: boolean | undefined,
  132825. /**
  132826. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  132827. */
  132828. samplingMode?: number);
  132829. /**
  132830. * Execute the current task
  132831. * @param scene defines the scene where you want your assets to be loaded
  132832. * @param onSuccess is a callback called when the task is successfully executed
  132833. * @param onError is a callback called if an error occurs
  132834. */
  132835. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132836. }
  132837. /**
  132838. * Define a task used by AssetsManager to load cube textures
  132839. */
  132840. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  132841. /**
  132842. * Defines the name of the task
  132843. */
  132844. name: string;
  132845. /**
  132846. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132847. */
  132848. url: string;
  132849. /**
  132850. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132851. */
  132852. extensions?: string[] | undefined;
  132853. /**
  132854. * Defines if mipmaps should not be generated (default is false)
  132855. */
  132856. noMipmap?: boolean | undefined;
  132857. /**
  132858. * Defines the explicit list of files (undefined by default)
  132859. */
  132860. files?: string[] | undefined;
  132861. /**
  132862. * Gets the loaded texture
  132863. */
  132864. texture: CubeTexture;
  132865. /**
  132866. * Callback called when the task is successful
  132867. */
  132868. onSuccess: (task: CubeTextureAssetTask) => void;
  132869. /**
  132870. * Callback called when the task is successful
  132871. */
  132872. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  132873. /**
  132874. * Creates a new CubeTextureAssetTask
  132875. * @param name defines the name of the task
  132876. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132877. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132878. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132879. * @param files defines the explicit list of files (undefined by default)
  132880. */
  132881. constructor(
  132882. /**
  132883. * Defines the name of the task
  132884. */
  132885. name: string,
  132886. /**
  132887. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  132888. */
  132889. url: string,
  132890. /**
  132891. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  132892. */
  132893. extensions?: string[] | undefined,
  132894. /**
  132895. * Defines if mipmaps should not be generated (default is false)
  132896. */
  132897. noMipmap?: boolean | undefined,
  132898. /**
  132899. * Defines the explicit list of files (undefined by default)
  132900. */
  132901. files?: string[] | undefined);
  132902. /**
  132903. * Execute the current task
  132904. * @param scene defines the scene where you want your assets to be loaded
  132905. * @param onSuccess is a callback called when the task is successfully executed
  132906. * @param onError is a callback called if an error occurs
  132907. */
  132908. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132909. }
  132910. /**
  132911. * Define a task used by AssetsManager to load HDR cube textures
  132912. */
  132913. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  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 the desired size (the more it increases the longer the generation will be)
  132924. */
  132925. size: number;
  132926. /**
  132927. * Defines if mipmaps should not be generated (default is false)
  132928. */
  132929. noMipmap: boolean;
  132930. /**
  132931. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132932. */
  132933. generateHarmonics: boolean;
  132934. /**
  132935. * 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)
  132936. */
  132937. gammaSpace: boolean;
  132938. /**
  132939. * Internal Use Only
  132940. */
  132941. reserved: boolean;
  132942. /**
  132943. * Gets the loaded texture
  132944. */
  132945. texture: HDRCubeTexture;
  132946. /**
  132947. * Callback called when the task is successful
  132948. */
  132949. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  132950. /**
  132951. * Callback called when the task is successful
  132952. */
  132953. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  132954. /**
  132955. * Creates a new HDRCubeTextureAssetTask object
  132956. * @param name defines the name of the task
  132957. * @param url defines the location of the file to load
  132958. * @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.
  132959. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132960. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132961. * @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)
  132962. * @param reserved Internal use only
  132963. */
  132964. constructor(
  132965. /**
  132966. * Defines the name of the task
  132967. */
  132968. name: string,
  132969. /**
  132970. * Defines the location of the file to load
  132971. */
  132972. url: string,
  132973. /**
  132974. * Defines the desired size (the more it increases the longer the generation will be)
  132975. */
  132976. size: number,
  132977. /**
  132978. * Defines if mipmaps should not be generated (default is false)
  132979. */
  132980. noMipmap?: boolean,
  132981. /**
  132982. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  132983. */
  132984. generateHarmonics?: boolean,
  132985. /**
  132986. * 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)
  132987. */
  132988. gammaSpace?: boolean,
  132989. /**
  132990. * Internal Use Only
  132991. */
  132992. reserved?: boolean);
  132993. /**
  132994. * Execute the current task
  132995. * @param scene defines the scene where you want your assets to be loaded
  132996. * @param onSuccess is a callback called when the task is successfully executed
  132997. * @param onError is a callback called if an error occurs
  132998. */
  132999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133000. }
  133001. /**
  133002. * Define a task used by AssetsManager to load Equirectangular cube textures
  133003. */
  133004. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133005. /**
  133006. * Defines the name of the task
  133007. */
  133008. name: string;
  133009. /**
  133010. * Defines the location of the file to load
  133011. */
  133012. url: string;
  133013. /**
  133014. * Defines the desired size (the more it increases the longer the generation will be)
  133015. */
  133016. size: number;
  133017. /**
  133018. * Defines if mipmaps should not be generated (default is false)
  133019. */
  133020. noMipmap: boolean;
  133021. /**
  133022. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133023. * but the standard material would require them in Gamma space) (default is true)
  133024. */
  133025. gammaSpace: boolean;
  133026. /**
  133027. * Gets the loaded texture
  133028. */
  133029. texture: EquiRectangularCubeTexture;
  133030. /**
  133031. * Callback called when the task is successful
  133032. */
  133033. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133034. /**
  133035. * Callback called when the task is successful
  133036. */
  133037. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133038. /**
  133039. * Creates a new EquiRectangularCubeTextureAssetTask object
  133040. * @param name defines the name of the task
  133041. * @param url defines the location of the file to load
  133042. * @param size defines the desired size (the more it increases the longer the generation will be)
  133043. * If the size is omitted this implies you are using a preprocessed cubemap.
  133044. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133045. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133046. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133047. * (default is true)
  133048. */
  133049. constructor(
  133050. /**
  133051. * Defines the name of the task
  133052. */
  133053. name: string,
  133054. /**
  133055. * Defines the location of the file to load
  133056. */
  133057. url: string,
  133058. /**
  133059. * Defines the desired size (the more it increases the longer the generation will be)
  133060. */
  133061. size: number,
  133062. /**
  133063. * Defines if mipmaps should not be generated (default is false)
  133064. */
  133065. noMipmap?: boolean,
  133066. /**
  133067. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133068. * but the standard material would require them in Gamma space) (default is true)
  133069. */
  133070. gammaSpace?: boolean);
  133071. /**
  133072. * Execute the current task
  133073. * @param scene defines the scene where you want your assets to be loaded
  133074. * @param onSuccess is a callback called when the task is successfully executed
  133075. * @param onError is a callback called if an error occurs
  133076. */
  133077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133078. }
  133079. /**
  133080. * This class can be used to easily import assets into a scene
  133081. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  133082. */
  133083. export class AssetsManager {
  133084. private _scene;
  133085. private _isLoading;
  133086. protected _tasks: AbstractAssetTask[];
  133087. protected _waitingTasksCount: number;
  133088. protected _totalTasksCount: number;
  133089. /**
  133090. * Callback called when all tasks are processed
  133091. */
  133092. onFinish: (tasks: AbstractAssetTask[]) => void;
  133093. /**
  133094. * Callback called when a task is successful
  133095. */
  133096. onTaskSuccess: (task: AbstractAssetTask) => void;
  133097. /**
  133098. * Callback called when a task had an error
  133099. */
  133100. onTaskError: (task: AbstractAssetTask) => void;
  133101. /**
  133102. * Callback called when a task is done (whatever the result is)
  133103. */
  133104. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  133105. /**
  133106. * Observable called when all tasks are processed
  133107. */
  133108. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  133109. /**
  133110. * Observable called when a task had an error
  133111. */
  133112. onTaskErrorObservable: Observable<AbstractAssetTask>;
  133113. /**
  133114. * Observable called when all tasks were executed
  133115. */
  133116. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  133117. /**
  133118. * Observable called when a task is done (whatever the result is)
  133119. */
  133120. onProgressObservable: Observable<IAssetsProgressEvent>;
  133121. /**
  133122. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  133123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  133124. */
  133125. useDefaultLoadingScreen: boolean;
  133126. /**
  133127. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  133128. * when all assets have been downloaded.
  133129. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  133130. */
  133131. autoHideLoadingUI: boolean;
  133132. /**
  133133. * Creates a new AssetsManager
  133134. * @param scene defines the scene to work on
  133135. */
  133136. constructor(scene: Scene);
  133137. /**
  133138. * Add a MeshAssetTask to the list of active tasks
  133139. * @param taskName defines the name of the new task
  133140. * @param meshesNames defines the name of meshes to load
  133141. * @param rootUrl defines the root url to use to locate files
  133142. * @param sceneFilename defines the filename of the scene file
  133143. * @returns a new MeshAssetTask object
  133144. */
  133145. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  133146. /**
  133147. * Add a TextFileAssetTask to the list of active tasks
  133148. * @param taskName defines the name of the new task
  133149. * @param url defines the url of the file to load
  133150. * @returns a new TextFileAssetTask object
  133151. */
  133152. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  133153. /**
  133154. * Add a BinaryFileAssetTask to the list of active tasks
  133155. * @param taskName defines the name of the new task
  133156. * @param url defines the url of the file to load
  133157. * @returns a new BinaryFileAssetTask object
  133158. */
  133159. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  133160. /**
  133161. * Add a ImageAssetTask to the list of active tasks
  133162. * @param taskName defines the name of the new task
  133163. * @param url defines the url of the file to load
  133164. * @returns a new ImageAssetTask object
  133165. */
  133166. addImageTask(taskName: string, url: string): ImageAssetTask;
  133167. /**
  133168. * Add a TextureAssetTask to the list of active tasks
  133169. * @param taskName defines the name of the new task
  133170. * @param url defines the url of the file to load
  133171. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133172. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  133173. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  133174. * @returns a new TextureAssetTask object
  133175. */
  133176. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  133177. /**
  133178. * Add a CubeTextureAssetTask to the list of active tasks
  133179. * @param taskName defines the name of the new task
  133180. * @param url defines the url of the file to load
  133181. * @param extensions defines the extension to use to load the cube map (can be null)
  133182. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133183. * @param files defines the list of files to load (can be null)
  133184. * @returns a new CubeTextureAssetTask object
  133185. */
  133186. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  133187. /**
  133188. *
  133189. * Add a HDRCubeTextureAssetTask to the list of active tasks
  133190. * @param taskName defines the name of the new task
  133191. * @param url defines the url of the file to load
  133192. * @param size defines the size you want for the cubemap (can be null)
  133193. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133194. * @param generateHarmonics defines if you want to automatically generate (true by default)
  133195. * @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)
  133196. * @param reserved Internal use only
  133197. * @returns a new HDRCubeTextureAssetTask object
  133198. */
  133199. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  133200. /**
  133201. *
  133202. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  133203. * @param taskName defines the name of the new task
  133204. * @param url defines the url of the file to load
  133205. * @param size defines the size you want for the cubemap (can be null)
  133206. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  133207. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  133208. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  133209. * @returns a new EquiRectangularCubeTextureAssetTask object
  133210. */
  133211. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  133212. /**
  133213. * Remove a task from the assets manager.
  133214. * @param task the task to remove
  133215. */
  133216. removeTask(task: AbstractAssetTask): void;
  133217. private _decreaseWaitingTasksCount;
  133218. private _runTask;
  133219. /**
  133220. * Reset the AssetsManager and remove all tasks
  133221. * @return the current instance of the AssetsManager
  133222. */
  133223. reset(): AssetsManager;
  133224. /**
  133225. * Start the loading process
  133226. * @return the current instance of the AssetsManager
  133227. */
  133228. load(): AssetsManager;
  133229. /**
  133230. * Start the loading process as an async operation
  133231. * @return a promise returning the list of failed tasks
  133232. */
  133233. loadAsync(): Promise<void>;
  133234. }
  133235. }
  133236. declare module BABYLON {
  133237. /**
  133238. * Wrapper class for promise with external resolve and reject.
  133239. */
  133240. export class Deferred<T> {
  133241. /**
  133242. * The promise associated with this deferred object.
  133243. */
  133244. readonly promise: Promise<T>;
  133245. private _resolve;
  133246. private _reject;
  133247. /**
  133248. * The resolve method of the promise associated with this deferred object.
  133249. */
  133250. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  133251. /**
  133252. * The reject method of the promise associated with this deferred object.
  133253. */
  133254. readonly reject: (reason?: any) => void;
  133255. /**
  133256. * Constructor for this deferred object.
  133257. */
  133258. constructor();
  133259. }
  133260. }
  133261. declare module BABYLON {
  133262. /**
  133263. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  133264. */
  133265. export class MeshExploder {
  133266. private _centerMesh;
  133267. private _meshes;
  133268. private _meshesOrigins;
  133269. private _toCenterVectors;
  133270. private _scaledDirection;
  133271. private _newPosition;
  133272. private _centerPosition;
  133273. /**
  133274. * Explodes meshes from a center mesh.
  133275. * @param meshes The meshes to explode.
  133276. * @param centerMesh The mesh to be center of explosion.
  133277. */
  133278. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  133279. private _setCenterMesh;
  133280. /**
  133281. * Get class name
  133282. * @returns "MeshExploder"
  133283. */
  133284. getClassName(): string;
  133285. /**
  133286. * "Exploded meshes"
  133287. * @returns Array of meshes with the centerMesh at index 0.
  133288. */
  133289. getMeshes(): Array<Mesh>;
  133290. /**
  133291. * Explodes meshes giving a specific direction
  133292. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  133293. */
  133294. explode(direction?: number): void;
  133295. }
  133296. }
  133297. declare module BABYLON {
  133298. /**
  133299. * Class used to help managing file picking and drag'n'drop
  133300. */
  133301. export class FilesInput {
  133302. /**
  133303. * List of files ready to be loaded
  133304. */
  133305. static readonly FilesToLoad: {
  133306. [key: string]: File;
  133307. };
  133308. /**
  133309. * Callback called when a file is processed
  133310. */
  133311. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  133312. private _engine;
  133313. private _currentScene;
  133314. private _sceneLoadedCallback;
  133315. private _progressCallback;
  133316. private _additionalRenderLoopLogicCallback;
  133317. private _textureLoadingCallback;
  133318. private _startingProcessingFilesCallback;
  133319. private _onReloadCallback;
  133320. private _errorCallback;
  133321. private _elementToMonitor;
  133322. private _sceneFileToLoad;
  133323. private _filesToLoad;
  133324. /**
  133325. * Creates a new FilesInput
  133326. * @param engine defines the rendering engine
  133327. * @param scene defines the hosting scene
  133328. * @param sceneLoadedCallback callback called when scene is loaded
  133329. * @param progressCallback callback called to track progress
  133330. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  133331. * @param textureLoadingCallback callback called when a texture is loading
  133332. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  133333. * @param onReloadCallback callback called when a reload is requested
  133334. * @param errorCallback callback call if an error occurs
  133335. */
  133336. 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);
  133337. private _dragEnterHandler;
  133338. private _dragOverHandler;
  133339. private _dropHandler;
  133340. /**
  133341. * Calls this function to listen to drag'n'drop events on a specific DOM element
  133342. * @param elementToMonitor defines the DOM element to track
  133343. */
  133344. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  133345. /**
  133346. * Release all associated resources
  133347. */
  133348. dispose(): void;
  133349. private renderFunction;
  133350. private drag;
  133351. private drop;
  133352. private _traverseFolder;
  133353. private _processFiles;
  133354. /**
  133355. * Load files from a drop event
  133356. * @param event defines the drop event to use as source
  133357. */
  133358. loadFiles(event: any): void;
  133359. private _processReload;
  133360. /**
  133361. * Reload the current scene from the loaded files
  133362. */
  133363. reload(): void;
  133364. }
  133365. }
  133366. declare module BABYLON {
  133367. /**
  133368. * Defines the root class used to create scene optimization to use with SceneOptimizer
  133369. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133370. */
  133371. export class SceneOptimization {
  133372. /**
  133373. * Defines the priority of this optimization (0 by default which means first in the list)
  133374. */
  133375. priority: number;
  133376. /**
  133377. * Gets a string describing the action executed by the current optimization
  133378. * @returns description string
  133379. */
  133380. getDescription(): string;
  133381. /**
  133382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133383. * @param scene defines the current scene where to apply this optimization
  133384. * @param optimizer defines the current optimizer
  133385. * @returns true if everything that can be done was applied
  133386. */
  133387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133388. /**
  133389. * Creates the SceneOptimization object
  133390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133391. * @param desc defines the description associated with the optimization
  133392. */
  133393. constructor(
  133394. /**
  133395. * Defines the priority of this optimization (0 by default which means first in the list)
  133396. */
  133397. priority?: number);
  133398. }
  133399. /**
  133400. * Defines an optimization used to reduce the size of render target textures
  133401. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133402. */
  133403. export class TextureOptimization extends SceneOptimization {
  133404. /**
  133405. * Defines the priority of this optimization (0 by default which means first in the list)
  133406. */
  133407. priority: number;
  133408. /**
  133409. * 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
  133410. */
  133411. maximumSize: number;
  133412. /**
  133413. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133414. */
  133415. step: number;
  133416. /**
  133417. * Gets a string describing the action executed by the current optimization
  133418. * @returns description string
  133419. */
  133420. getDescription(): string;
  133421. /**
  133422. * Creates the TextureOptimization object
  133423. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133424. * @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
  133425. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133426. */
  133427. constructor(
  133428. /**
  133429. * Defines the priority of this optimization (0 by default which means first in the list)
  133430. */
  133431. priority?: number,
  133432. /**
  133433. * 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
  133434. */
  133435. maximumSize?: number,
  133436. /**
  133437. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  133438. */
  133439. step?: number);
  133440. /**
  133441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133442. * @param scene defines the current scene where to apply this optimization
  133443. * @param optimizer defines the current optimizer
  133444. * @returns true if everything that can be done was applied
  133445. */
  133446. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133447. }
  133448. /**
  133449. * Defines an optimization used to increase or decrease the rendering resolution
  133450. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133451. */
  133452. export class HardwareScalingOptimization extends SceneOptimization {
  133453. /**
  133454. * Defines the priority of this optimization (0 by default which means first in the list)
  133455. */
  133456. priority: number;
  133457. /**
  133458. * Defines the maximum scale to use (2 by default)
  133459. */
  133460. maximumScale: number;
  133461. /**
  133462. * Defines the step to use between two passes (0.5 by default)
  133463. */
  133464. step: number;
  133465. private _currentScale;
  133466. private _directionOffset;
  133467. /**
  133468. * Gets a string describing the action executed by the current optimization
  133469. * @return description string
  133470. */
  133471. getDescription(): string;
  133472. /**
  133473. * Creates the HardwareScalingOptimization object
  133474. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133475. * @param maximumScale defines the maximum scale to use (2 by default)
  133476. * @param step defines the step to use between two passes (0.5 by default)
  133477. */
  133478. constructor(
  133479. /**
  133480. * Defines the priority of this optimization (0 by default which means first in the list)
  133481. */
  133482. priority?: number,
  133483. /**
  133484. * Defines the maximum scale to use (2 by default)
  133485. */
  133486. maximumScale?: number,
  133487. /**
  133488. * Defines the step to use between two passes (0.5 by default)
  133489. */
  133490. step?: number);
  133491. /**
  133492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133493. * @param scene defines the current scene where to apply this optimization
  133494. * @param optimizer defines the current optimizer
  133495. * @returns true if everything that can be done was applied
  133496. */
  133497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133498. }
  133499. /**
  133500. * Defines an optimization used to remove shadows
  133501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133502. */
  133503. export class ShadowsOptimization extends SceneOptimization {
  133504. /**
  133505. * Gets a string describing the action executed by the current optimization
  133506. * @return description string
  133507. */
  133508. getDescription(): string;
  133509. /**
  133510. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133511. * @param scene defines the current scene where to apply this optimization
  133512. * @param optimizer defines the current optimizer
  133513. * @returns true if everything that can be done was applied
  133514. */
  133515. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133516. }
  133517. /**
  133518. * Defines an optimization used to turn post-processes off
  133519. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133520. */
  133521. export class PostProcessesOptimization extends SceneOptimization {
  133522. /**
  133523. * Gets a string describing the action executed by the current optimization
  133524. * @return description string
  133525. */
  133526. getDescription(): string;
  133527. /**
  133528. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133529. * @param scene defines the current scene where to apply this optimization
  133530. * @param optimizer defines the current optimizer
  133531. * @returns true if everything that can be done was applied
  133532. */
  133533. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133534. }
  133535. /**
  133536. * Defines an optimization used to turn lens flares off
  133537. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133538. */
  133539. export class LensFlaresOptimization extends SceneOptimization {
  133540. /**
  133541. * Gets a string describing the action executed by the current optimization
  133542. * @return description string
  133543. */
  133544. getDescription(): string;
  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 based on user defined callback.
  133555. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133556. */
  133557. export class CustomOptimization extends SceneOptimization {
  133558. /**
  133559. * Callback called to apply the custom optimization.
  133560. */
  133561. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  133562. /**
  133563. * Callback called to get custom description
  133564. */
  133565. onGetDescription: () => string;
  133566. /**
  133567. * Gets a string describing the action executed by the current optimization
  133568. * @returns description string
  133569. */
  133570. getDescription(): string;
  133571. /**
  133572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133573. * @param scene defines the current scene where to apply this optimization
  133574. * @param optimizer defines the current optimizer
  133575. * @returns true if everything that can be done was applied
  133576. */
  133577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133578. }
  133579. /**
  133580. * Defines an optimization used to turn particles off
  133581. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133582. */
  133583. export class ParticlesOptimization extends SceneOptimization {
  133584. /**
  133585. * Gets a string describing the action executed by the current optimization
  133586. * @return description string
  133587. */
  133588. getDescription(): string;
  133589. /**
  133590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133591. * @param scene defines the current scene where to apply this optimization
  133592. * @param optimizer defines the current optimizer
  133593. * @returns true if everything that can be done was applied
  133594. */
  133595. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133596. }
  133597. /**
  133598. * Defines an optimization used to turn render targets off
  133599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133600. */
  133601. export class RenderTargetsOptimization extends SceneOptimization {
  133602. /**
  133603. * Gets a string describing the action executed by the current optimization
  133604. * @return description string
  133605. */
  133606. getDescription(): string;
  133607. /**
  133608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133609. * @param scene defines the current scene where to apply this optimization
  133610. * @param optimizer defines the current optimizer
  133611. * @returns true if everything that can be done was applied
  133612. */
  133613. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  133614. }
  133615. /**
  133616. * Defines an optimization used to merge meshes with compatible materials
  133617. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133618. */
  133619. export class MergeMeshesOptimization extends SceneOptimization {
  133620. private static _UpdateSelectionTree;
  133621. /**
  133622. * Gets or sets a boolean which defines if optimization octree has to be updated
  133623. */
  133624. /**
  133625. * Gets or sets a boolean which defines if optimization octree has to be updated
  133626. */
  133627. static UpdateSelectionTree: boolean;
  133628. /**
  133629. * Gets a string describing the action executed by the current optimization
  133630. * @return description string
  133631. */
  133632. getDescription(): string;
  133633. private _canBeMerged;
  133634. /**
  133635. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  133636. * @param scene defines the current scene where to apply this optimization
  133637. * @param optimizer defines the current optimizer
  133638. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  133639. * @returns true if everything that can be done was applied
  133640. */
  133641. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  133642. }
  133643. /**
  133644. * Defines a list of options used by SceneOptimizer
  133645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133646. */
  133647. export class SceneOptimizerOptions {
  133648. /**
  133649. * Defines the target frame rate to reach (60 by default)
  133650. */
  133651. targetFrameRate: number;
  133652. /**
  133653. * Defines the interval between two checkes (2000ms by default)
  133654. */
  133655. trackerDuration: number;
  133656. /**
  133657. * Gets the list of optimizations to apply
  133658. */
  133659. optimizations: SceneOptimization[];
  133660. /**
  133661. * Creates a new list of options used by SceneOptimizer
  133662. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  133663. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  133664. */
  133665. constructor(
  133666. /**
  133667. * Defines the target frame rate to reach (60 by default)
  133668. */
  133669. targetFrameRate?: number,
  133670. /**
  133671. * Defines the interval between two checkes (2000ms by default)
  133672. */
  133673. trackerDuration?: number);
  133674. /**
  133675. * Add a new optimization
  133676. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  133677. * @returns the current SceneOptimizerOptions
  133678. */
  133679. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  133680. /**
  133681. * Add a new custom optimization
  133682. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  133683. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  133684. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  133685. * @returns the current SceneOptimizerOptions
  133686. */
  133687. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  133688. /**
  133689. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  133690. * @param targetFrameRate defines the target frame rate (60 by default)
  133691. * @returns a SceneOptimizerOptions object
  133692. */
  133693. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133694. /**
  133695. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  133696. * @param targetFrameRate defines the target frame rate (60 by default)
  133697. * @returns a SceneOptimizerOptions object
  133698. */
  133699. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133700. /**
  133701. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  133702. * @param targetFrameRate defines the target frame rate (60 by default)
  133703. * @returns a SceneOptimizerOptions object
  133704. */
  133705. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  133706. }
  133707. /**
  133708. * Class used to run optimizations in order to reach a target frame rate
  133709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  133710. */
  133711. export class SceneOptimizer implements IDisposable {
  133712. private _isRunning;
  133713. private _options;
  133714. private _scene;
  133715. private _currentPriorityLevel;
  133716. private _targetFrameRate;
  133717. private _trackerDuration;
  133718. private _currentFrameRate;
  133719. private _sceneDisposeObserver;
  133720. private _improvementMode;
  133721. /**
  133722. * Defines an observable called when the optimizer reaches the target frame rate
  133723. */
  133724. onSuccessObservable: Observable<SceneOptimizer>;
  133725. /**
  133726. * Defines an observable called when the optimizer enables an optimization
  133727. */
  133728. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  133729. /**
  133730. * Defines an observable called when the optimizer is not able to reach the target frame rate
  133731. */
  133732. onFailureObservable: Observable<SceneOptimizer>;
  133733. /**
  133734. * Gets a boolean indicating if the optimizer is in improvement mode
  133735. */
  133736. readonly isInImprovementMode: boolean;
  133737. /**
  133738. * Gets the current priority level (0 at start)
  133739. */
  133740. readonly currentPriorityLevel: number;
  133741. /**
  133742. * Gets the current frame rate checked by the SceneOptimizer
  133743. */
  133744. readonly currentFrameRate: number;
  133745. /**
  133746. * Gets or sets the current target frame rate (60 by default)
  133747. */
  133748. /**
  133749. * Gets or sets the current target frame rate (60 by default)
  133750. */
  133751. targetFrameRate: number;
  133752. /**
  133753. * Gets or sets the current interval between two checks (every 2000ms by default)
  133754. */
  133755. /**
  133756. * Gets or sets the current interval between two checks (every 2000ms by default)
  133757. */
  133758. trackerDuration: number;
  133759. /**
  133760. * Gets the list of active optimizations
  133761. */
  133762. readonly optimizations: SceneOptimization[];
  133763. /**
  133764. * Creates a new SceneOptimizer
  133765. * @param scene defines the scene to work on
  133766. * @param options defines the options to use with the SceneOptimizer
  133767. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  133768. * @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)
  133769. */
  133770. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  133771. /**
  133772. * Stops the current optimizer
  133773. */
  133774. stop(): void;
  133775. /**
  133776. * Reset the optimizer to initial step (current priority level = 0)
  133777. */
  133778. reset(): void;
  133779. /**
  133780. * Start the optimizer. By default it will try to reach a specific framerate
  133781. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  133782. */
  133783. start(): void;
  133784. private _checkCurrentState;
  133785. /**
  133786. * Release all resources
  133787. */
  133788. dispose(): void;
  133789. /**
  133790. * Helper function to create a SceneOptimizer with one single line of code
  133791. * @param scene defines the scene to work on
  133792. * @param options defines the options to use with the SceneOptimizer
  133793. * @param onSuccess defines a callback to call on success
  133794. * @param onFailure defines a callback to call on failure
  133795. * @returns the new SceneOptimizer object
  133796. */
  133797. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  133798. }
  133799. }
  133800. declare module BABYLON {
  133801. /**
  133802. * Class used to serialize a scene into a string
  133803. */
  133804. export class SceneSerializer {
  133805. /**
  133806. * Clear cache used by a previous serialization
  133807. */
  133808. static ClearCache(): void;
  133809. /**
  133810. * Serialize a scene into a JSON compatible object
  133811. * @param scene defines the scene to serialize
  133812. * @returns a JSON compatible object
  133813. */
  133814. static Serialize(scene: Scene): any;
  133815. /**
  133816. * Serialize a mesh into a JSON compatible object
  133817. * @param toSerialize defines the mesh to serialize
  133818. * @param withParents defines if parents must be serialized as well
  133819. * @param withChildren defines if children must be serialized as well
  133820. * @returns a JSON compatible object
  133821. */
  133822. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  133823. }
  133824. }
  133825. declare module BABYLON {
  133826. /**
  133827. * Class used to host texture specific utilities
  133828. */
  133829. export class TextureTools {
  133830. /**
  133831. * Uses the GPU to create a copy texture rescaled at a given size
  133832. * @param texture Texture to copy from
  133833. * @param width defines the desired width
  133834. * @param height defines the desired height
  133835. * @param useBilinearMode defines if bilinear mode has to be used
  133836. * @return the generated texture
  133837. */
  133838. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  133839. }
  133840. }
  133841. declare module BABYLON {
  133842. /**
  133843. * This represents the different options available for the video capture.
  133844. */
  133845. export interface VideoRecorderOptions {
  133846. /** Defines the mime type of the video. */
  133847. mimeType: string;
  133848. /** Defines the FPS the video should be recorded at. */
  133849. fps: number;
  133850. /** Defines the chunk size for the recording data. */
  133851. recordChunckSize: number;
  133852. /** The audio tracks to attach to the recording. */
  133853. audioTracks?: MediaStreamTrack[];
  133854. }
  133855. /**
  133856. * This can help with recording videos from BabylonJS.
  133857. * This is based on the available WebRTC functionalities of the browser.
  133858. *
  133859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  133860. */
  133861. export class VideoRecorder {
  133862. private static readonly _defaultOptions;
  133863. /**
  133864. * Returns whether or not the VideoRecorder is available in your browser.
  133865. * @param engine Defines the Babylon Engine.
  133866. * @returns true if supported otherwise false.
  133867. */
  133868. static IsSupported(engine: Engine): boolean;
  133869. private readonly _options;
  133870. private _canvas;
  133871. private _mediaRecorder;
  133872. private _recordedChunks;
  133873. private _fileName;
  133874. private _resolve;
  133875. private _reject;
  133876. /**
  133877. * True when a recording is already in progress.
  133878. */
  133879. readonly isRecording: boolean;
  133880. /**
  133881. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  133882. * @param engine Defines the BabylonJS Engine you wish to record.
  133883. * @param options Defines options that can be used to customize the capture.
  133884. */
  133885. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  133886. /**
  133887. * Stops the current recording before the default capture timeout passed in the startRecording function.
  133888. */
  133889. stopRecording(): void;
  133890. /**
  133891. * Starts recording the canvas for a max duration specified in parameters.
  133892. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  133893. * If null no automatic download will start and you can rely on the promise to get the data back.
  133894. * @param maxDuration Defines the maximum recording time in seconds.
  133895. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  133896. * @return A promise callback at the end of the recording with the video data in Blob.
  133897. */
  133898. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  133899. /**
  133900. * Releases internal resources used during the recording.
  133901. */
  133902. dispose(): void;
  133903. private _handleDataAvailable;
  133904. private _handleError;
  133905. private _handleStop;
  133906. }
  133907. }
  133908. declare module BABYLON {
  133909. /**
  133910. * Class containing a set of static utilities functions for screenshots
  133911. */
  133912. export class ScreenshotTools {
  133913. /**
  133914. * Captures a screenshot of the current rendering
  133915. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133916. * @param engine defines the rendering engine
  133917. * @param camera defines the source camera
  133918. * @param size This parameter can be set to a single number or to an object with the
  133919. * following (optional) properties: precision, width, height. If a single number is passed,
  133920. * it will be used for both width and height. If an object is passed, the screenshot size
  133921. * will be derived from the parameters. The precision property is a multiplier allowing
  133922. * rendering at a higher or lower resolution
  133923. * @param successCallback defines the callback receives a single parameter which contains the
  133924. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133925. * src parameter of an <img> to display it
  133926. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133927. * Check your browser for supported MIME types
  133928. */
  133929. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  133930. /**
  133931. * Captures a screenshot of the current rendering
  133932. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133933. * @param engine defines the rendering engine
  133934. * @param camera defines the source camera
  133935. * @param size This parameter can be set to a single number or to an object with the
  133936. * following (optional) properties: precision, width, height. If a single number is passed,
  133937. * it will be used for both width and height. If an object is passed, the screenshot size
  133938. * will be derived from the parameters. The precision property is a multiplier allowing
  133939. * rendering at a higher or lower resolution
  133940. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  133941. * Check your browser for supported MIME types
  133942. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133943. * to the src parameter of an <img> to display it
  133944. */
  133945. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  133946. /**
  133947. * Generates an image screenshot from the specified camera.
  133948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133949. * @param engine The engine to use for rendering
  133950. * @param camera The camera to use for rendering
  133951. * @param size This parameter can be set to a single number or to an object with the
  133952. * following (optional) properties: precision, width, height. If a single number is passed,
  133953. * it will be used for both width and height. If an object is passed, the screenshot size
  133954. * will be derived from the parameters. The precision property is a multiplier allowing
  133955. * rendering at a higher or lower resolution
  133956. * @param successCallback The callback receives a single parameter which contains the
  133957. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  133958. * src parameter of an <img> to display it
  133959. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133960. * Check your browser for supported MIME types
  133961. * @param samples Texture samples (default: 1)
  133962. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133963. * @param fileName A name for for the downloaded file.
  133964. */
  133965. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  133966. /**
  133967. * Generates an image screenshot from the specified camera.
  133968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  133969. * @param engine The engine to use for rendering
  133970. * @param camera The camera to use for rendering
  133971. * @param size This parameter can be set to a single number or to an object with the
  133972. * following (optional) properties: precision, width, height. If a single number is passed,
  133973. * it will be used for both width and height. If an object is passed, the screenshot size
  133974. * will be derived from the parameters. The precision property is a multiplier allowing
  133975. * rendering at a higher or lower resolution
  133976. * @param mimeType The MIME type of the screenshot image (default: image/png).
  133977. * Check your browser for supported MIME types
  133978. * @param samples Texture samples (default: 1)
  133979. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  133980. * @param fileName A name for for the downloaded file.
  133981. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  133982. * to the src parameter of an <img> to display it
  133983. */
  133984. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  133985. /**
  133986. * Gets height and width for screenshot size
  133987. * @private
  133988. */
  133989. private static _getScreenshotSize;
  133990. }
  133991. }
  133992. declare module BABYLON {
  133993. /**
  133994. * Interface for a data buffer
  133995. */
  133996. export interface IDataBuffer {
  133997. /**
  133998. * Reads bytes from the data buffer.
  133999. * @param byteOffset The byte offset to read
  134000. * @param byteLength The byte length to read
  134001. * @returns A promise that resolves when the bytes are read
  134002. */
  134003. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134004. /**
  134005. * The byte length of the buffer.
  134006. */
  134007. readonly byteLength: number;
  134008. }
  134009. /**
  134010. * Utility class for reading from a data buffer
  134011. */
  134012. export class DataReader {
  134013. /**
  134014. * The data buffer associated with this data reader.
  134015. */
  134016. readonly buffer: IDataBuffer;
  134017. /**
  134018. * The current byte offset from the beginning of the data buffer.
  134019. */
  134020. byteOffset: number;
  134021. private _dataView;
  134022. private _dataByteOffset;
  134023. /**
  134024. * Constructor
  134025. * @param buffer The buffer to read
  134026. */
  134027. constructor(buffer: IDataBuffer);
  134028. /**
  134029. * Loads the given byte length.
  134030. * @param byteLength The byte length to load
  134031. * @returns A promise that resolves when the load is complete
  134032. */
  134033. loadAsync(byteLength: number): Promise<void>;
  134034. /**
  134035. * Read a unsigned 32-bit integer from the currently loaded data range.
  134036. * @returns The 32-bit integer read
  134037. */
  134038. readUint32(): number;
  134039. /**
  134040. * Read a byte array from the currently loaded data range.
  134041. * @param byteLength The byte length to read
  134042. * @returns The byte array read
  134043. */
  134044. readUint8Array(byteLength: number): Uint8Array;
  134045. /**
  134046. * Read a string from the currently loaded data range.
  134047. * @param byteLength The byte length to read
  134048. * @returns The string read
  134049. */
  134050. readString(byteLength: number): string;
  134051. /**
  134052. * Skips the given byte length the currently loaded data range.
  134053. * @param byteLength The byte length to skip
  134054. */
  134055. skipBytes(byteLength: number): void;
  134056. }
  134057. }
  134058. declare module BABYLON {
  134059. /**
  134060. * A cursor which tracks a point on a path
  134061. */
  134062. export class PathCursor {
  134063. private path;
  134064. /**
  134065. * Stores path cursor callbacks for when an onchange event is triggered
  134066. */
  134067. private _onchange;
  134068. /**
  134069. * The value of the path cursor
  134070. */
  134071. value: number;
  134072. /**
  134073. * The animation array of the path cursor
  134074. */
  134075. animations: Animation[];
  134076. /**
  134077. * Initializes the path cursor
  134078. * @param path The path to track
  134079. */
  134080. constructor(path: Path2);
  134081. /**
  134082. * Gets the cursor point on the path
  134083. * @returns A point on the path cursor at the cursor location
  134084. */
  134085. getPoint(): Vector3;
  134086. /**
  134087. * Moves the cursor ahead by the step amount
  134088. * @param step The amount to move the cursor forward
  134089. * @returns This path cursor
  134090. */
  134091. moveAhead(step?: number): PathCursor;
  134092. /**
  134093. * Moves the cursor behind by the step amount
  134094. * @param step The amount to move the cursor back
  134095. * @returns This path cursor
  134096. */
  134097. moveBack(step?: number): PathCursor;
  134098. /**
  134099. * Moves the cursor by the step amount
  134100. * If the step amount is greater than one, an exception is thrown
  134101. * @param step The amount to move the cursor
  134102. * @returns This path cursor
  134103. */
  134104. move(step: number): PathCursor;
  134105. /**
  134106. * Ensures that the value is limited between zero and one
  134107. * @returns This path cursor
  134108. */
  134109. private ensureLimits;
  134110. /**
  134111. * Runs onchange callbacks on change (used by the animation engine)
  134112. * @returns This path cursor
  134113. */
  134114. private raiseOnChange;
  134115. /**
  134116. * Executes a function on change
  134117. * @param f A path cursor onchange callback
  134118. * @returns This path cursor
  134119. */
  134120. onchange(f: (cursor: PathCursor) => void): PathCursor;
  134121. }
  134122. }
  134123. declare module BABYLON {
  134124. /** @hidden */
  134125. export var blurPixelShader: {
  134126. name: string;
  134127. shader: string;
  134128. };
  134129. }
  134130. declare module BABYLON {
  134131. /** @hidden */
  134132. export var pointCloudVertexDeclaration: {
  134133. name: string;
  134134. shader: string;
  134135. };
  134136. }
  134137. // Mixins
  134138. interface Window {
  134139. mozIndexedDB: IDBFactory;
  134140. webkitIndexedDB: IDBFactory;
  134141. msIndexedDB: IDBFactory;
  134142. webkitURL: typeof URL;
  134143. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  134144. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  134145. WebGLRenderingContext: WebGLRenderingContext;
  134146. MSGesture: MSGesture;
  134147. CANNON: any;
  134148. AudioContext: AudioContext;
  134149. webkitAudioContext: AudioContext;
  134150. PointerEvent: any;
  134151. Math: Math;
  134152. Uint8Array: Uint8ArrayConstructor;
  134153. Float32Array: Float32ArrayConstructor;
  134154. mozURL: typeof URL;
  134155. msURL: typeof URL;
  134156. VRFrameData: any; // WebVR, from specs 1.1
  134157. DracoDecoderModule: any;
  134158. setImmediate(handler: (...args: any[]) => void): number;
  134159. }
  134160. interface HTMLCanvasElement {
  134161. requestPointerLock(): void;
  134162. msRequestPointerLock?(): void;
  134163. mozRequestPointerLock?(): void;
  134164. webkitRequestPointerLock?(): void;
  134165. /** Track wether a record is in progress */
  134166. isRecording: boolean;
  134167. /** Capture Stream method defined by some browsers */
  134168. captureStream(fps?: number): MediaStream;
  134169. }
  134170. interface CanvasRenderingContext2D {
  134171. msImageSmoothingEnabled: boolean;
  134172. }
  134173. interface MouseEvent {
  134174. mozMovementX: number;
  134175. mozMovementY: number;
  134176. webkitMovementX: number;
  134177. webkitMovementY: number;
  134178. msMovementX: number;
  134179. msMovementY: number;
  134180. }
  134181. interface Navigator {
  134182. mozGetVRDevices: (any: any) => any;
  134183. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134184. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134185. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  134186. webkitGetGamepads(): Gamepad[];
  134187. msGetGamepads(): Gamepad[];
  134188. webkitGamepads(): Gamepad[];
  134189. }
  134190. interface HTMLVideoElement {
  134191. mozSrcObject: any;
  134192. }
  134193. interface Math {
  134194. fround(x: number): number;
  134195. imul(a: number, b: number): number;
  134196. }
  134197. interface WebGLRenderingContext {
  134198. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  134199. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  134200. vertexAttribDivisor(index: number, divisor: number): void;
  134201. createVertexArray(): any;
  134202. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  134203. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  134204. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  134205. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  134206. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  134207. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  134208. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  134209. // Queries
  134210. createQuery(): WebGLQuery;
  134211. deleteQuery(query: WebGLQuery): void;
  134212. beginQuery(target: number, query: WebGLQuery): void;
  134213. endQuery(target: number): void;
  134214. getQueryParameter(query: WebGLQuery, pname: number): any;
  134215. getQuery(target: number, pname: number): any;
  134216. MAX_SAMPLES: number;
  134217. RGBA8: number;
  134218. READ_FRAMEBUFFER: number;
  134219. DRAW_FRAMEBUFFER: number;
  134220. UNIFORM_BUFFER: number;
  134221. HALF_FLOAT_OES: number;
  134222. RGBA16F: number;
  134223. RGBA32F: number;
  134224. R32F: number;
  134225. RG32F: number;
  134226. RGB32F: number;
  134227. R16F: number;
  134228. RG16F: number;
  134229. RGB16F: number;
  134230. RED: number;
  134231. RG: number;
  134232. R8: number;
  134233. RG8: number;
  134234. UNSIGNED_INT_24_8: number;
  134235. DEPTH24_STENCIL8: number;
  134236. MIN: number;
  134237. MAX: number;
  134238. /* Multiple Render Targets */
  134239. drawBuffers(buffers: number[]): void;
  134240. readBuffer(src: number): void;
  134241. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  134242. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  134243. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  134244. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  134245. // Occlusion Query
  134246. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  134247. ANY_SAMPLES_PASSED: number;
  134248. QUERY_RESULT_AVAILABLE: number;
  134249. QUERY_RESULT: number;
  134250. }
  134251. interface WebGLProgram {
  134252. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  134253. }
  134254. interface EXT_disjoint_timer_query {
  134255. QUERY_COUNTER_BITS_EXT: number;
  134256. TIME_ELAPSED_EXT: number;
  134257. TIMESTAMP_EXT: number;
  134258. GPU_DISJOINT_EXT: number;
  134259. QUERY_RESULT_EXT: number;
  134260. QUERY_RESULT_AVAILABLE_EXT: number;
  134261. queryCounterEXT(query: WebGLQuery, target: number): void;
  134262. createQueryEXT(): WebGLQuery;
  134263. beginQueryEXT(target: number, query: WebGLQuery): void;
  134264. endQueryEXT(target: number): void;
  134265. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  134266. deleteQueryEXT(query: WebGLQuery): void;
  134267. }
  134268. interface WebGLUniformLocation {
  134269. _currentState: any;
  134270. }
  134271. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  134272. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  134273. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  134274. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134275. interface WebGLRenderingContext {
  134276. readonly RASTERIZER_DISCARD: number;
  134277. readonly DEPTH_COMPONENT24: number;
  134278. readonly TEXTURE_3D: number;
  134279. readonly TEXTURE_2D_ARRAY: number;
  134280. readonly TEXTURE_COMPARE_FUNC: number;
  134281. readonly TEXTURE_COMPARE_MODE: number;
  134282. readonly COMPARE_REF_TO_TEXTURE: number;
  134283. readonly TEXTURE_WRAP_R: number;
  134284. readonly HALF_FLOAT: number;
  134285. readonly RGB8: number;
  134286. readonly RED_INTEGER: number;
  134287. readonly RG_INTEGER: number;
  134288. readonly RGB_INTEGER: number;
  134289. readonly RGBA_INTEGER: number;
  134290. readonly R8_SNORM: number;
  134291. readonly RG8_SNORM: number;
  134292. readonly RGB8_SNORM: number;
  134293. readonly RGBA8_SNORM: number;
  134294. readonly R8I: number;
  134295. readonly RG8I: number;
  134296. readonly RGB8I: number;
  134297. readonly RGBA8I: number;
  134298. readonly R8UI: number;
  134299. readonly RG8UI: number;
  134300. readonly RGB8UI: number;
  134301. readonly RGBA8UI: number;
  134302. readonly R16I: number;
  134303. readonly RG16I: number;
  134304. readonly RGB16I: number;
  134305. readonly RGBA16I: number;
  134306. readonly R16UI: number;
  134307. readonly RG16UI: number;
  134308. readonly RGB16UI: number;
  134309. readonly RGBA16UI: number;
  134310. readonly R32I: number;
  134311. readonly RG32I: number;
  134312. readonly RGB32I: number;
  134313. readonly RGBA32I: number;
  134314. readonly R32UI: number;
  134315. readonly RG32UI: number;
  134316. readonly RGB32UI: number;
  134317. readonly RGBA32UI: number;
  134318. readonly RGB10_A2UI: number;
  134319. readonly R11F_G11F_B10F: number;
  134320. readonly RGB9_E5: number;
  134321. readonly RGB10_A2: number;
  134322. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  134323. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  134324. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  134325. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  134326. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  134327. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  134328. 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;
  134329. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  134330. readonly TRANSFORM_FEEDBACK: number;
  134331. readonly INTERLEAVED_ATTRIBS: number;
  134332. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  134333. createTransformFeedback(): WebGLTransformFeedback;
  134334. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  134335. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  134336. beginTransformFeedback(primitiveMode: number): void;
  134337. endTransformFeedback(): void;
  134338. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  134339. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134340. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134341. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  134342. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  134343. }
  134344. interface ImageBitmap {
  134345. readonly width: number;
  134346. readonly height: number;
  134347. close(): void;
  134348. }
  134349. interface WebGLQuery extends WebGLObject {
  134350. }
  134351. declare var WebGLQuery: {
  134352. prototype: WebGLQuery;
  134353. new(): WebGLQuery;
  134354. };
  134355. interface WebGLSampler extends WebGLObject {
  134356. }
  134357. declare var WebGLSampler: {
  134358. prototype: WebGLSampler;
  134359. new(): WebGLSampler;
  134360. };
  134361. interface WebGLSync extends WebGLObject {
  134362. }
  134363. declare var WebGLSync: {
  134364. prototype: WebGLSync;
  134365. new(): WebGLSync;
  134366. };
  134367. interface WebGLTransformFeedback extends WebGLObject {
  134368. }
  134369. declare var WebGLTransformFeedback: {
  134370. prototype: WebGLTransformFeedback;
  134371. new(): WebGLTransformFeedback;
  134372. };
  134373. interface WebGLVertexArrayObject extends WebGLObject {
  134374. }
  134375. declare var WebGLVertexArrayObject: {
  134376. prototype: WebGLVertexArrayObject;
  134377. new(): WebGLVertexArrayObject;
  134378. };
  134379. // Type definitions for WebVR API
  134380. // Project: https://w3c.github.io/webvr/
  134381. // Definitions by: six a <https://github.com/lostfictions>
  134382. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  134383. interface VRDisplay extends EventTarget {
  134384. /**
  134385. * Dictionary of capabilities describing the VRDisplay.
  134386. */
  134387. readonly capabilities: VRDisplayCapabilities;
  134388. /**
  134389. * z-depth defining the far plane of the eye view frustum
  134390. * enables mapping of values in the render target depth
  134391. * attachment to scene coordinates. Initially set to 10000.0.
  134392. */
  134393. depthFar: number;
  134394. /**
  134395. * z-depth defining the near plane of the eye view frustum
  134396. * enables mapping of values in the render target depth
  134397. * attachment to scene coordinates. Initially set to 0.01.
  134398. */
  134399. depthNear: number;
  134400. /**
  134401. * An identifier for this distinct VRDisplay. Used as an
  134402. * association point in the Gamepad API.
  134403. */
  134404. readonly displayId: number;
  134405. /**
  134406. * A display name, a user-readable name identifying it.
  134407. */
  134408. readonly displayName: string;
  134409. readonly isConnected: boolean;
  134410. readonly isPresenting: boolean;
  134411. /**
  134412. * If this VRDisplay supports room-scale experiences, the optional
  134413. * stage attribute contains details on the room-scale parameters.
  134414. */
  134415. readonly stageParameters: VRStageParameters | null;
  134416. /**
  134417. * Passing the value returned by `requestAnimationFrame` to
  134418. * `cancelAnimationFrame` will unregister the callback.
  134419. * @param handle Define the hanle of the request to cancel
  134420. */
  134421. cancelAnimationFrame(handle: number): void;
  134422. /**
  134423. * Stops presenting to the VRDisplay.
  134424. * @returns a promise to know when it stopped
  134425. */
  134426. exitPresent(): Promise<void>;
  134427. /**
  134428. * Return the current VREyeParameters for the given eye.
  134429. * @param whichEye Define the eye we want the parameter for
  134430. * @returns the eye parameters
  134431. */
  134432. getEyeParameters(whichEye: string): VREyeParameters;
  134433. /**
  134434. * Populates the passed VRFrameData with the information required to render
  134435. * the current frame.
  134436. * @param frameData Define the data structure to populate
  134437. * @returns true if ok otherwise false
  134438. */
  134439. getFrameData(frameData: VRFrameData): boolean;
  134440. /**
  134441. * Get the layers currently being presented.
  134442. * @returns the list of VR layers
  134443. */
  134444. getLayers(): VRLayer[];
  134445. /**
  134446. * Return a VRPose containing the future predicted pose of the VRDisplay
  134447. * when the current frame will be presented. The value returned will not
  134448. * change until JavaScript has returned control to the browser.
  134449. *
  134450. * The VRPose will contain the position, orientation, velocity,
  134451. * and acceleration of each of these properties.
  134452. * @returns the pose object
  134453. */
  134454. getPose(): VRPose;
  134455. /**
  134456. * Return the current instantaneous pose of the VRDisplay, with no
  134457. * prediction applied.
  134458. * @returns the current instantaneous pose
  134459. */
  134460. getImmediatePose(): VRPose;
  134461. /**
  134462. * The callback passed to `requestAnimationFrame` will be called
  134463. * any time a new frame should be rendered. When the VRDisplay is
  134464. * presenting the callback will be called at the native refresh
  134465. * rate of the HMD. When not presenting this function acts
  134466. * identically to how window.requestAnimationFrame acts. Content should
  134467. * make no assumptions of frame rate or vsync behavior as the HMD runs
  134468. * asynchronously from other displays and at differing refresh rates.
  134469. * @param callback Define the eaction to run next frame
  134470. * @returns the request handle it
  134471. */
  134472. requestAnimationFrame(callback: FrameRequestCallback): number;
  134473. /**
  134474. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  134475. * Repeat calls while already presenting will update the VRLayers being displayed.
  134476. * @param layers Define the list of layer to present
  134477. * @returns a promise to know when the request has been fulfilled
  134478. */
  134479. requestPresent(layers: VRLayer[]): Promise<void>;
  134480. /**
  134481. * Reset the pose for this display, treating its current position and
  134482. * orientation as the "origin/zero" values. VRPose.position,
  134483. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  134484. * updated when calling resetPose(). This should be called in only
  134485. * sitting-space experiences.
  134486. */
  134487. resetPose(): void;
  134488. /**
  134489. * The VRLayer provided to the VRDisplay will be captured and presented
  134490. * in the HMD. Calling this function has the same effect on the source
  134491. * canvas as any other operation that uses its source image, and canvases
  134492. * created without preserveDrawingBuffer set to true will be cleared.
  134493. * @param pose Define the pose to submit
  134494. */
  134495. submitFrame(pose?: VRPose): void;
  134496. }
  134497. declare var VRDisplay: {
  134498. prototype: VRDisplay;
  134499. new(): VRDisplay;
  134500. };
  134501. interface VRLayer {
  134502. leftBounds?: number[] | Float32Array | null;
  134503. rightBounds?: number[] | Float32Array | null;
  134504. source?: HTMLCanvasElement | null;
  134505. }
  134506. interface VRDisplayCapabilities {
  134507. readonly canPresent: boolean;
  134508. readonly hasExternalDisplay: boolean;
  134509. readonly hasOrientation: boolean;
  134510. readonly hasPosition: boolean;
  134511. readonly maxLayers: number;
  134512. }
  134513. interface VREyeParameters {
  134514. /** @deprecated */
  134515. readonly fieldOfView: VRFieldOfView;
  134516. readonly offset: Float32Array;
  134517. readonly renderHeight: number;
  134518. readonly renderWidth: number;
  134519. }
  134520. interface VRFieldOfView {
  134521. readonly downDegrees: number;
  134522. readonly leftDegrees: number;
  134523. readonly rightDegrees: number;
  134524. readonly upDegrees: number;
  134525. }
  134526. interface VRFrameData {
  134527. readonly leftProjectionMatrix: Float32Array;
  134528. readonly leftViewMatrix: Float32Array;
  134529. readonly pose: VRPose;
  134530. readonly rightProjectionMatrix: Float32Array;
  134531. readonly rightViewMatrix: Float32Array;
  134532. readonly timestamp: number;
  134533. }
  134534. interface VRPose {
  134535. readonly angularAcceleration: Float32Array | null;
  134536. readonly angularVelocity: Float32Array | null;
  134537. readonly linearAcceleration: Float32Array | null;
  134538. readonly linearVelocity: Float32Array | null;
  134539. readonly orientation: Float32Array | null;
  134540. readonly position: Float32Array | null;
  134541. readonly timestamp: number;
  134542. }
  134543. interface VRStageParameters {
  134544. sittingToStandingTransform?: Float32Array;
  134545. sizeX?: number;
  134546. sizeY?: number;
  134547. }
  134548. interface Navigator {
  134549. getVRDisplays(): Promise<VRDisplay[]>;
  134550. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  134551. }
  134552. interface Window {
  134553. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  134554. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  134555. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  134556. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134557. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  134558. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  134559. }
  134560. interface Gamepad {
  134561. readonly displayId: number;
  134562. }
  134563. type XRSessionMode =
  134564. | "inline"
  134565. | "immersive-vr"
  134566. | "immersive-ar";
  134567. type XRReferenceSpaceType =
  134568. | "viewer"
  134569. | "local"
  134570. | "local-floor"
  134571. | "bounded-floor"
  134572. | "unbounded";
  134573. type XREnvironmentBlendMode =
  134574. | "opaque"
  134575. | "additive"
  134576. | "alpha-blend";
  134577. type XRVisibilityState =
  134578. | "visible"
  134579. | "visible-blurred"
  134580. | "hidden";
  134581. type XRHandedness =
  134582. | "none"
  134583. | "left"
  134584. | "right";
  134585. type XRTargetRayMode =
  134586. | "gaze"
  134587. | "tracked-pointer"
  134588. | "screen";
  134589. type XREye =
  134590. | "none"
  134591. | "left"
  134592. | "right";
  134593. interface XRSpace extends EventTarget {
  134594. }
  134595. interface XRRenderState {
  134596. depthNear?: number;
  134597. depthFar?: number;
  134598. inlineVerticalFieldOfView?: number;
  134599. baseLayer?: XRWebGLLayer;
  134600. }
  134601. interface XRInputSource {
  134602. handedness: XRHandedness;
  134603. targetRayMode: XRTargetRayMode;
  134604. targetRaySpace: XRSpace;
  134605. gripSpace: XRSpace | undefined;
  134606. gamepad: Gamepad | undefined;
  134607. profiles: Array<string>;
  134608. }
  134609. interface XRSession {
  134610. addEventListener: Function;
  134611. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  134612. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  134613. requestAnimationFrame: Function;
  134614. end(): Promise<void>;
  134615. renderState: XRRenderState;
  134616. inputSources: Array<XRInputSource>;
  134617. }
  134618. interface XRReferenceSpace extends XRSpace {
  134619. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  134620. onreset: any;
  134621. }
  134622. interface XRFrame {
  134623. session: XRSession;
  134624. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  134625. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  134626. }
  134627. interface XRViewerPose extends XRPose {
  134628. views: Array<XRView>;
  134629. }
  134630. interface XRPose {
  134631. transform: XRRigidTransform;
  134632. emulatedPosition: boolean;
  134633. }
  134634. interface XRWebGLLayerOptions {
  134635. antialias ?: boolean;
  134636. depth ?: boolean;
  134637. stencil ?: boolean;
  134638. alpha ?: boolean;
  134639. multiview ?: boolean;
  134640. framebufferScaleFactor ?: number;
  134641. }
  134642. declare var XRWebGLLayer: {
  134643. prototype: XRWebGLLayer;
  134644. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  134645. };
  134646. interface XRWebGLLayer {
  134647. framebuffer: WebGLFramebuffer;
  134648. framebufferWidth: number;
  134649. framebufferHeight: number;
  134650. getViewport: Function;
  134651. }
  134652. interface XRRigidTransform {
  134653. position: DOMPointReadOnly;
  134654. orientation: DOMPointReadOnly;
  134655. matrix: Float32Array;
  134656. inverse: XRRigidTransform;
  134657. }
  134658. interface XRView {
  134659. eye: XREye;
  134660. projectionMatrix: Float32Array;
  134661. transform: XRRigidTransform;
  134662. }
  134663. interface XRInputSourceChangeEvent {
  134664. session: XRSession;
  134665. removed: Array<XRInputSource>;
  134666. added: Array<XRInputSource>;
  134667. }